From bc0a57f5cd9073eb2d360dcccd1fb3d770a1cee9 Mon Sep 17 00:00:00 2001 From: fushen Date: Wed, 11 Nov 2020 20:09:18 +0800 Subject: [PATCH 1/3] chore: remove rax-compile-config --- .../src/components/BuggyCounter/index.tsx | 3 ++- examples/with-rax/src/pages/Home/index.tsx | 2 +- .../create-app-shared/src/appLifeCycles.ts | 1 + packages/plugin-rax-web/package.json | 5 +++-- .../src/DocumentPlugin/index.js | 5 ++--- packages/plugin-rax-web/src/setEntry.js | 4 +--- packages/plugin-rax-weex/package.json | 4 ++-- packages/plugin-rax-weex/src/setEntry.js | 3 +-- packages/plugin-ssr/package.json | 4 ++-- packages/plugin-ssr/src/web/setDev.js | 4 +--- yarn.lock | 22 ++++++++++++++++++- 11 files changed, 37 insertions(+), 20 deletions(-) diff --git a/examples/with-rax/src/components/BuggyCounter/index.tsx b/examples/with-rax/src/components/BuggyCounter/index.tsx index 40804a1865..857426eff1 100644 --- a/examples/with-rax/src/components/BuggyCounter/index.tsx +++ b/examples/with-rax/src/components/BuggyCounter/index.tsx @@ -1,4 +1,5 @@ import { createElement, Component } from 'rax'; +import Text from 'rax-text'; class BuggyCounter extends Component { constructor(props) { @@ -18,7 +19,7 @@ class BuggyCounter extends Component { // Simulate a JS error throw new Error('I crashed!'); } - return

{this.state.counter}

; + return {this.state.counter}; } } diff --git a/examples/with-rax/src/pages/Home/index.tsx b/examples/with-rax/src/pages/Home/index.tsx index c74490e40f..b50de7a4b4 100644 --- a/examples/with-rax/src/pages/Home/index.tsx +++ b/examples/with-rax/src/pages/Home/index.tsx @@ -27,7 +27,7 @@ export default function Home(props) { {props?.data?.title || 'Welcome to Your Rax App'} {props?.data?.info || 'More information about Rax'} - history.push('/about?id=1')}>Go About + history.push('/about', { id: 1 })}>Go About ); } diff --git a/packages/create-app-shared/src/appLifeCycles.ts b/packages/create-app-shared/src/appLifeCycles.ts index edc6dd6bba..795cf74477 100644 --- a/packages/create-app-shared/src/appLifeCycles.ts +++ b/packages/create-app-shared/src/appLifeCycles.ts @@ -75,6 +75,7 @@ if (isMiniAppPlatform) { const globalEvent = __weex_require__('@weex-module/globalEvent'); globalEvent.addEventListener('WXApplicationDidBecomeActiveEvent', function() { router.current.visibiltyState = true; + console.error(11111); // Emit app show emit(SHOW); // Emit page show diff --git a/packages/plugin-rax-web/package.json b/packages/plugin-rax-web/package.json index 12f0841a28..06144c18ab 100644 --- a/packages/plugin-rax-web/package.json +++ b/packages/plugin-rax-web/package.json @@ -22,10 +22,11 @@ "fs-extra": "^9.0.1", "klaw-sync": "^6.0.0", "qs": "^6.9.4", - "rax-compile-config": "^0.2.16", "rax-server-renderer": "^1.2.0", "webpack-sources": "^2.0.0", "webpack": "^4.0.0", - "@builder/app-helpers": "1.0.0-0" + "@builder/app-helpers": "1.0.0-0", + "react-dev-utils": "^10.0.0", + "chalk": "^4.1.0" } } diff --git a/packages/plugin-rax-web/src/DocumentPlugin/index.js b/packages/plugin-rax-web/src/DocumentPlugin/index.js index 16a3765a29..fc586dc924 100644 --- a/packages/plugin-rax-web/src/DocumentPlugin/index.js +++ b/packages/plugin-rax-web/src/DocumentPlugin/index.js @@ -3,7 +3,6 @@ const path = require('path'); const fs = require('fs-extra'); const webpack = require('webpack'); const { RawSource } = require('webpack-sources'); -const { handleWebpackErr } = require('rax-compile-config'); const { parse, print } = require('error-stack-tracey'); const PLUGIN_NAME = 'DocumentPlugin'; @@ -126,7 +125,7 @@ module.exports = class DocumentPlugin { // Run as child to get child compilation childCompiler.runAsChild((err, entries, childCompilation) => { if (err) { - handleWebpackErr(err); + console.log(err); } else { fileDependencies = childCompilation.fileDependencies; } @@ -182,7 +181,7 @@ async function generateHtml(compilation, options) { const errorStack = await parse(error, documentContent); // Prevent print duplicate error info if (!hasPrintError) { - print(error.message, errorStack); + print(error.message, errorStack.reverse()); hasPrintError = true; } diff --git a/packages/plugin-rax-web/src/setEntry.js b/packages/plugin-rax-web/src/setEntry.js index 9fbcccb9e1..e966b380ec 100644 --- a/packages/plugin-rax-web/src/setEntry.js +++ b/packages/plugin-rax-web/src/setEntry.js @@ -1,8 +1,6 @@ const path = require('path'); const fs = require('fs-extra'); -const { hmrClient } = require('rax-compile-config'); - module.exports = (config, context) => { const { rootDir, command } = context; const isDev = command === 'start'; @@ -15,7 +13,7 @@ module.exports = (config, context) => { .use('loader'); if (isDev) { - entryConfig.add(hmrClient); + entryConfig.add(require.resolve('react-dev-utils/webpackHotDevClient')); } entryConfig.add(appEntry); }; diff --git a/packages/plugin-rax-weex/package.json b/packages/plugin-rax-weex/package.json index e31d9fcc21..70e49c78dd 100644 --- a/packages/plugin-rax-weex/package.json +++ b/packages/plugin-rax-weex/package.json @@ -19,8 +19,8 @@ "dependencies": { "@builder/mpa-config": "1.0.0-0", "fs-extra": "^9.0.1", - "rax-compile-config": "^0.2.16", "webpack-sources": "^2.0.0", - "@builder/app-helpers": "1.0.0-0" + "@builder/app-helpers": "1.0.0-0", + "react-dev-utils": "^10.0.0" } } diff --git a/packages/plugin-rax-weex/src/setEntry.js b/packages/plugin-rax-weex/src/setEntry.js index 381963d027..442c90c2cf 100644 --- a/packages/plugin-rax-weex/src/setEntry.js +++ b/packages/plugin-rax-weex/src/setEntry.js @@ -1,4 +1,3 @@ -const { hmrClient } = require('rax-compile-config'); const fs = require('fs-extra'); const path = require('path'); @@ -11,7 +10,7 @@ module.exports = (config, context) => { const entryConfig = config.entry('index'); if (isDev) { - entryConfig.add(hmrClient); + entryConfig.add(require.resolve('react-dev-utils/webpackHotDevClient')); } entryConfig.add(appEntry); }; diff --git a/packages/plugin-ssr/package.json b/packages/plugin-ssr/package.json index 2cf803caa8..aab6893dd2 100644 --- a/packages/plugin-ssr/package.json +++ b/packages/plugin-ssr/package.json @@ -26,10 +26,10 @@ "dependencies": { "@builder/mpa-config": "1.0.0-0", "chalk": "^4.1.0", - "rax-compile-config": "^0.2.16", "fs-extra": "^9.0.1", "error-stack-tracey": "^0.1.3", "qs": "^6.9.4", - "@builder/app-helpers": "1.0.0-0" + "@builder/app-helpers": "1.0.0-0", + "react-dev-utils": "^10.0.0" } } diff --git a/packages/plugin-ssr/src/web/setDev.js b/packages/plugin-ssr/src/web/setDev.js index ce3e1884d6..1cab0ef29e 100644 --- a/packages/plugin-ssr/src/web/setDev.js +++ b/packages/plugin-ssr/src/web/setDev.js @@ -1,12 +1,10 @@ -const { hmrClient } = require('rax-compile-config'); - module.exports = (config) => { const allEntries = config.entryPoints.entries(); // eslint-disable-next-line for (const entryName in allEntries) { if (Object.prototype.hasOwnProperty.call(allEntries, entryName)) { // remove hmrClient - config.entry(entryName).delete(hmrClient); + config.entry(entryName).delete(require.resolve('react-dev-utils/webpackHotDevClient')); } } diff --git a/yarn.lock b/yarn.lock index 9fa567f2d3..38376fdd0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5005,6 +5005,26 @@ build-plugin-app-core@0.1.23-0: react-app-renderer "0.1.10" universal-env "^3.0.0" +build-plugin-miniapp@0.1.6: + version "0.1.6" + resolved "https://registry.npm.taobao.org/build-plugin-miniapp/download/build-plugin-miniapp-0.1.6.tgz#b349e1b51617a190088e0aab3ce215f1351d46b6" + integrity sha1-s0nhtRYXoZAIjgqrPOIV8TUdRrY= + dependencies: + miniapp-builder-shared "^0.1.1" + miniapp-runtime-config "^0.1.1" + +build-plugin-rax-miniapp@1.0.4-1: + version "1.0.4-1" + resolved "https://registry.npm.taobao.org/build-plugin-rax-miniapp/download/build-plugin-rax-miniapp-1.0.4-1.tgz#706dd883bf82531c9795b37eedc2f7bb8c588c62" + integrity sha1-cG3Yg7+CUxyXlbN+7cL3u4xYjGI= + dependencies: + copy-webpack-plugin "^5.0.4" + fs-extra "^9.0.1" + miniapp-builder-shared "^0.1.6" + miniapp-compile-config "^0.1.3" + miniapp-runtime-config "^0.1.3" + webpack-sources "^2.0.0" + builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.npm.taobao.org/builtin-status-codes/download/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" @@ -15158,7 +15178,7 @@ rc@^1.2.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-dev-utils@^10.2.1: +react-dev-utils@^10.0.0, react-dev-utils@^10.2.1: version "10.2.1" resolved "https://registry.npm.taobao.org/react-dev-utils/download/react-dev-utils-10.2.1.tgz#f6de325ae25fa4d546d09df4bb1befdc6dd19c19" integrity sha1-9t4yWuJfpNVG0J30uxvv3G3RnBk= From 0ed7b5b207b1494309072b34a88e95f8f3260f91 Mon Sep 17 00:00:00 2001 From: fushen Date: Thu, 12 Nov 2020 11:12:55 +0800 Subject: [PATCH 2/3] chore: use rax-platform-loader instead of rax-compile-config --- packages/plugin-rax-app/package.json | 2 +- packages/plugin-rax-app/src/base.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-rax-app/package.json b/packages/plugin-rax-app/package.json index b90d3c87a9..9f0fbcc3b0 100644 --- a/packages/plugin-rax-app/package.json +++ b/packages/plugin-rax-app/package.json @@ -16,7 +16,7 @@ "rax-webpack-config": "1.0.1-2", "rax-babel-config": "1.0.1-0", "rax-jest-config": "^1.0.0", - "rax-compile-config": "^0.2.16", + "rax-platform-loader": "^1.0.0", "@builder/user-config": "0.1.0-1", "@builder/app-helpers": "1.0.0-0", "chalk": "^4.0.0", diff --git a/packages/plugin-rax-app/src/base.js b/packages/plugin-rax-app/src/base.js index b885ae2b0f..74b2f78a20 100644 --- a/packages/plugin-rax-app/src/base.js +++ b/packages/plugin-rax-app/src/base.js @@ -39,7 +39,7 @@ module.exports = (api, { target, babelConfigOptions, progressOptions = {} }) => enhancedWebpackConfig.module .rule(ruleName) .use('platform-loader') - .loader(require.resolve('rax-compile-config/src/platformLoader')) + .loader(require.resolve('rax-platform-loader')) .options({ platform: target }); From c6d8df3d7cdf72148198f1ba4cdf356cc020b87d Mon Sep 17 00:00:00 2001 From: fushen Date: Thu, 12 Nov 2020 11:15:05 +0800 Subject: [PATCH 3/3] chore: remove useless code --- packages/create-app-shared/src/appLifeCycles.ts | 1 - packages/plugin-rax-app/package.json | 2 +- packages/plugin-rax-web/src/DocumentPlugin/index.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/create-app-shared/src/appLifeCycles.ts b/packages/create-app-shared/src/appLifeCycles.ts index 795cf74477..edc6dd6bba 100644 --- a/packages/create-app-shared/src/appLifeCycles.ts +++ b/packages/create-app-shared/src/appLifeCycles.ts @@ -75,7 +75,6 @@ if (isMiniAppPlatform) { const globalEvent = __weex_require__('@weex-module/globalEvent'); globalEvent.addEventListener('WXApplicationDidBecomeActiveEvent', function() { router.current.visibiltyState = true; - console.error(11111); // Emit app show emit(SHOW); // Emit page show diff --git a/packages/plugin-rax-app/package.json b/packages/plugin-rax-app/package.json index 9f0fbcc3b0..c71604c24c 100644 --- a/packages/plugin-rax-app/package.json +++ b/packages/plugin-rax-app/package.json @@ -16,7 +16,7 @@ "rax-webpack-config": "1.0.1-2", "rax-babel-config": "1.0.1-0", "rax-jest-config": "^1.0.0", - "rax-platform-loader": "^1.0.0", + "rax-platform-loader": "1.0.0-0", "@builder/user-config": "0.1.0-1", "@builder/app-helpers": "1.0.0-0", "chalk": "^4.0.0", diff --git a/packages/plugin-rax-web/src/DocumentPlugin/index.js b/packages/plugin-rax-web/src/DocumentPlugin/index.js index fc586dc924..777f5cc825 100644 --- a/packages/plugin-rax-web/src/DocumentPlugin/index.js +++ b/packages/plugin-rax-web/src/DocumentPlugin/index.js @@ -181,7 +181,7 @@ async function generateHtml(compilation, options) { const errorStack = await parse(error, documentContent); // Prevent print duplicate error info if (!hasPrintError) { - print(error.message, errorStack.reverse()); + print(error.message, errorStack); hasPrintError = true; }