From 83154949c4be42cc4a37fd116ca82fd14f953064 Mon Sep 17 00:00:00 2001 From: huangchengjiu Date: Tue, 24 Nov 2020 21:13:40 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat(mini-runner/mini-split-chunks):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E6=A8=A1=E5=9D=97=E6=8F=92=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E4=B8=BB=E5=8C=85=E6=B2=A1=E6=9C=89=E5=BC=95=E7=94=A8=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E4=B8=94=E5=88=86=E5=8C=85=E5=86=85=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E7=9A=84module=E6=8F=90=E5=8F=96=E5=88=B0=E5=88=86=E5=8C=85?= =?UTF-8?q?=E4=B8=8Bvendors=EF=BC=8C=E8=B7=A8=E5=88=86=E5=8C=85=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E7=9A=84module=E6=8F=90=E5=8F=96=E5=88=B0=E5=88=86?= =?UTF-8?q?=E5=8C=85=E4=B8=8B=EF=BC=8C=E8=BE=BE=E5=88=B0=E4=B8=BB=E5=8C=85?= =?UTF-8?q?=E4=BD=93=E7=A7=AF=E6=9C=80=E4=BC=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-mini-runner/package.json | 2 + .../mini-split-chunks.spec.ts.snap | 1068 +++++++++++++++++ .../mini-split-chunks/babel.config.js | 10 + .../mini-split-chunks/src/app.config.js | 26 + .../fixtures/mini-split-chunks/src/app.css | 0 .../fixtures/mini-split-chunks/src/app.js | 20 + .../fixtures/mini-split-chunks/src/index.html | 19 + .../src/packageA/detail/index.config.js | 3 + .../src/packageA/detail/index.css | 4 + .../src/packageA/detail/index.jsx | 20 + .../src/packageA/my/index.config.js | 3 + .../src/packageA/my/index.jsx | 21 + .../src/packageB/list/index.config.js | 3 + .../src/packageB/list/index.jsx | 19 + .../src/pages/index/index.config.js | 3 + .../src/pages/index/index.jsx | 26 + .../src/utils/consoleLogMain.js | 3 + .../src/utils/consoleLogSubCommon.js | 3 + .../src/utils/consoleLogSubVendors.js | 3 + .../src/__tests__/mini-split-chunks.spec.ts | 30 + .../src/plugins/MiniSplitChunksPlugin.ts | 421 +++++++ .../src/webpack/build.conf.ts | 9 +- .../taro-mini-runner/src/webpack/chain.ts | 6 + packages/taro-mini-runner/yarn.lock | 25 +- packages/taro/types/compile.d.ts | 1 + 25 files changed, 1744 insertions(+), 4 deletions(-) create mode 100644 packages/taro-mini-runner/src/__tests__/__snapshots__/mini-split-chunks.spec.ts.snap create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/babel.config.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/app.config.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/app.css create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/app.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/index.html create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/packageA/detail/index.config.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/packageA/detail/index.css create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/packageA/detail/index.jsx create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/packageA/my/index.config.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/packageA/my/index.jsx create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/packageB/list/index.config.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/packageB/list/index.jsx create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/pages/index/index.config.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/pages/index/index.jsx create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/utils/consoleLogMain.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/utils/consoleLogSubCommon.js create mode 100644 packages/taro-mini-runner/src/__tests__/fixtures/mini-split-chunks/src/utils/consoleLogSubVendors.js create mode 100644 packages/taro-mini-runner/src/__tests__/mini-split-chunks.spec.ts create mode 100644 packages/taro-mini-runner/src/plugins/MiniSplitChunksPlugin.ts diff --git a/packages/taro-mini-runner/package.json b/packages/taro-mini-runner/package.json index c243cb8ef44a..4f3ec4f4b136 100644 --- a/packages/taro-mini-runner/package.json +++ b/packages/taro-mini-runner/package.json @@ -58,9 +58,11 @@ "less-loader": "^5.0.0", "loader-utils": "^1.2.3", "lodash": "^4.17.11", + "md5": "^2.3.0", "micromatch": "^4.0.2", "mini-css-extract-plugin": "0.8.0", "miniprogram-simulate": "^1.1.5", + "mkdirp": "^1.0.4", "node-sass": "^4.12.0", "ora": "^3.4.0", "postcss-import": "12.0.1", diff --git a/packages/taro-mini-runner/src/__tests__/__snapshots__/mini-split-chunks.spec.ts.snap b/packages/taro-mini-runner/src/__tests__/__snapshots__/mini-split-chunks.spec.ts.snap new file mode 100644 index 000000000000..619a84aa80d4 --- /dev/null +++ b/packages/taro-mini-runner/src/__tests__/__snapshots__/mini-split-chunks.spec.ts.snap @@ -0,0 +1,1068 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`mini-split-chunks should process mini-split-chunks 1`] = `26`; + +exports[`mini-split-chunks should process mini-split-chunks 2`] = ` +" +/** filePath: dist/app.js **/ +require(\\"./runtime\\"); + +require(\\"./common\\"); + +require(\\"./vendors\\"); + +require(\\"./taro\\"); + +(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 6 ], { + 12: function(module, __webpack_exports__, __webpack_require__) { + \\"use strict\\"; + var _babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); + var _babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4); + var _babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5); + var _babel_runtime_helpers_esm_createSuper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6); + var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(0); + var _app_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29); + var _app_css__WEBPACK_IMPORTED_MODULE_5___default = __webpack_require__.n(_app_css__WEBPACK_IMPORTED_MODULE_5__); + var App = function(_Component) { + Object(_babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_2__[\\"a\\"])(App, _Component); + var _super = Object(_babel_runtime_helpers_esm_createSuper__WEBPACK_IMPORTED_MODULE_3__[\\"a\\"])(App); + function App() { + Object(_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__[\\"a\\"])(this, App); + return _super.apply(this, arguments); + } + Object(_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__[\\"a\\"])(App, [ { + key: \\"componentDidMount\\", + value: function componentDidMount() {} + }, { + key: \\"componentDidShow\\", + value: function componentDidShow() {} + }, { + key: \\"componentDidHide\\", + value: function componentDidHide() {} + }, { + key: \\"componentDidCatchError\\", + value: function componentDidCatchError() {} + }, { + key: \\"render\\", + value: function render() { + return this.props.children; + } + } ]); + return App; + }(react__WEBPACK_IMPORTED_MODULE_4__[\\"Component\\"]); + __webpack_exports__[\\"a\\"] = App; + }, + 28: function(module, __webpack_exports__, __webpack_require__) { + \\"use strict\\"; + __webpack_require__.r(__webpack_exports__); + var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); + var _node_modules_babel_loader_lib_index_js_app_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12); + var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0); + var react_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18); + var config = { + pages: [ \\"pages/index/index\\" ], + window: { + backgroundTextStyle: \\"light\\", + navigationBarBackgroundColor: \\"#fff\\", + navigationBarTitleText: \\"WeChat\\", + navigationBarTextStyle: \\"black\\" + }, + subpackages: [ { + root: \\"packageA\\", + pages: [ \\"detail/index\\", \\"my/index\\" ] + }, { + root: \\"packageB\\", + pages: [ \\"list/index\\" ] + } ] + }; + _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__[\\"window\\"].__taroAppConfig = config; + var inst = App(Object(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__[\\"createReactApp\\"])(_node_modules_babel_loader_lib_index_js_app_js__WEBPACK_IMPORTED_MODULE_1__[\\"a\\"], react__WEBPACK_IMPORTED_MODULE_2__, react_dom__WEBPACK_IMPORTED_MODULE_3__[\\"a\\"], config)); + }, + 29: function(module, exports, __webpack_require__) {} +}, [ [ 28, 0, 1, 3, 2 ] ] ]); + + + +/** filePath: dist/app.json **/ +{\\"pages\\":[\\"pages/index/index\\"],\\"window\\":{\\"backgroundTextStyle\\":\\"light\\",\\"navigationBarBackgroundColor\\":\\"#fff\\",\\"navigationBarTitleText\\":\\"WeChat\\",\\"navigationBarTextStyle\\":\\"black\\"},\\"subpackages\\":[{\\"root\\":\\"packageA\\",\\"pages\\":[\\"detail/index\\",\\"my/index\\"]},{\\"root\\":\\"packageB\\",\\"pages\\":[\\"list/index\\"]}]} + +/** filePath: dist/app.wxss **/ + + +/** filePath: dist/base.wxml **/ + +