@modern-js/app-tools 2.7.0 → 2.7.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/analyze/generateCode.js +6 -3
- package/dist/cjs/analyze/index.js +14 -1
- package/dist/cjs/analyze/templates.js +6 -4
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +2 -13
- package/dist/cjs/builder/generator/index.js +10 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +101 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +91 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +140 -0
- package/dist/cjs/builder/shared/builderPlugins/index.js +19 -0
- package/dist/cjs/builder/{builder-webpack/webpackPlugins → shared/bundlerPlugins}/RouterPlugin.js +11 -5
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +19 -0
- package/dist/cjs/builder/shared/index.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/locale/en.js +1 -0
- package/dist/cjs/locale/zh.js +1 -0
- package/dist/esm/analyze/generateCode.js +7 -5
- package/dist/esm/analyze/index.js +11 -2
- package/dist/esm/analyze/templates.js +6 -5
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +0 -11
- package/dist/esm/builder/generator/index.js +6 -4
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +101 -0
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +120 -0
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +131 -0
- package/dist/esm/builder/shared/builderPlugins/index.js +3 -0
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +350 -0
- package/dist/esm/builder/shared/bundlerPlugins/index.js +3 -0
- package/dist/esm/builder/shared/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/locale/en.js +1 -0
- package/dist/esm/locale/zh.js +1 -0
- package/dist/esm-node/analyze/generateCode.js +14 -4
- package/dist/esm-node/analyze/index.js +16 -2
- package/dist/esm-node/analyze/templates.js +6 -4
- package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -13
- package/dist/esm-node/builder/generator/index.js +10 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +67 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +67 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +119 -0
- package/dist/esm-node/builder/shared/builderPlugins/index.js +3 -0
- package/dist/esm-node/builder/{builder-webpack/webpackPlugins → shared/bundlerPlugins}/RouterPlugin.js +11 -5
- package/dist/esm-node/builder/shared/bundlerPlugins/index.js +3 -0
- package/dist/esm-node/builder/shared/index.js +1 -1
- package/dist/esm-node/index.js +1 -1
- package/dist/esm-node/locale/en.js +1 -0
- package/dist/esm-node/locale/zh.js +1 -0
- package/dist/js/modern/analyze/constants.js +54 -0
- package/dist/js/modern/analyze/generateCode.js +247 -0
- package/dist/js/modern/analyze/getBundleEntry.js +71 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
- package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +109 -0
- package/dist/js/modern/analyze/getHtmlTemplate.js +115 -0
- package/dist/js/modern/analyze/getServerRoutes.js +175 -0
- package/dist/js/modern/analyze/index.js +332 -0
- package/dist/js/modern/analyze/isDefaultExportFunction.js +42 -0
- package/dist/js/modern/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/modern/analyze/nestedRoutes.js +157 -0
- package/dist/js/modern/analyze/templates.js +334 -0
- package/dist/js/modern/analyze/utils.js +141 -0
- package/dist/{esm-node/builder/shared/builderPlugins/adapterModern.js → js/modern/builder/builderPlugins/compatModern.js} +135 -104
- package/dist/js/modern/builder/index.js +159 -0
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/share.js +46 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
- package/dist/js/modern/commands/build.js +91 -0
- package/dist/js/modern/commands/deploy.js +28 -0
- package/dist/js/modern/commands/dev.js +109 -0
- package/dist/js/modern/commands/index.js +3 -0
- package/dist/js/modern/commands/inspect.js +38 -0
- package/dist/js/modern/commands/serve.js +54 -0
- package/dist/js/modern/config/default.js +175 -0
- package/dist/js/modern/config/index.js +8 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
- package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
- package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
- package/dist/js/modern/config/initial/index.js +16 -0
- package/dist/js/modern/config/initial/inits.js +152 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
- package/dist/js/modern/defineConfig.js +27 -0
- package/dist/js/modern/exports/server.js +4 -0
- package/dist/js/modern/hooks.js +35 -0
- package/dist/js/modern/index.js +211 -0
- package/dist/js/modern/initialize/index.js +124 -0
- package/dist/js/modern/locale/en.js +36 -0
- package/dist/js/modern/locale/index.js +9 -0
- package/dist/js/modern/locale/zh.js +36 -0
- package/dist/js/modern/schema/Schema.js +40 -0
- package/dist/js/modern/schema/index.js +88 -0
- package/dist/js/modern/schema/legacy.js +148 -0
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +1 -0
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +3 -0
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +0 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/utils/config.js +128 -0
- package/dist/js/modern/utils/createServer.js +75 -0
- package/dist/js/modern/utils/env.js +15 -0
- package/dist/js/modern/utils/generateWatchFiles.js +55 -0
- package/dist/js/modern/utils/getSelectedEntries.js +58 -0
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/modern/utils/language.js +8 -0
- package/dist/js/modern/utils/printInstructions.js +31 -0
- package/dist/js/modern/utils/restart.js +44 -0
- package/dist/js/modern/utils/routes.js +30 -0
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +98 -0
- package/dist/js/node/analyze/generateCode.js +271 -0
- package/dist/js/node/analyze/getBundleEntry.js +95 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
- package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +131 -0
- package/dist/js/node/analyze/getHtmlTemplate.js +144 -0
- package/dist/js/node/analyze/getServerRoutes.js +194 -0
- package/dist/js/node/analyze/index.js +339 -0
- package/dist/js/node/analyze/isDefaultExportFunction.js +71 -0
- package/dist/js/node/analyze/makeLegalIdentifier.js +36 -0
- package/dist/js/node/analyze/nestedRoutes.js +184 -0
- package/dist/js/node/analyze/templates.js +365 -0
- package/dist/js/node/analyze/utils.js +172 -0
- package/dist/{cjs/builder/shared/builderPlugins/adapterModern.js → js/node/builder/builderPlugins/compatModern.js} +137 -113
- package/dist/js/node/builder/index.js +177 -0
- package/dist/js/node/builder/loaders/routerLoader.js +38 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
- package/dist/js/node/builder/share.js +75 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
- package/dist/js/node/commands/build.js +112 -0
- package/dist/js/node/commands/deploy.js +51 -0
- package/dist/js/node/commands/dev.js +126 -0
- package/dist/js/node/commands/index.js +19 -0
- package/dist/js/node/commands/inspect.js +61 -0
- package/dist/js/node/commands/serve.js +83 -0
- package/dist/js/node/config/default.js +197 -0
- package/dist/js/node/config/index.js +34 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
- package/dist/js/node/config/initial/createOutputConfig.js +91 -0
- package/dist/js/node/config/initial/createSourceConfig.js +62 -0
- package/dist/js/node/config/initial/createToolsConfig.js +65 -0
- package/dist/js/node/config/initial/index.js +41 -0
- package/dist/js/node/config/initial/inits.js +175 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
- package/dist/js/node/defineConfig.js +49 -0
- package/dist/js/node/exports/server.js +27 -0
- package/dist/js/node/hooks.js +54 -0
- package/dist/js/node/index.js +235 -0
- package/dist/js/node/initialize/index.js +134 -0
- package/dist/js/node/locale/en.js +59 -0
- package/dist/js/node/locale/index.js +33 -0
- package/dist/js/node/locale/zh.js +59 -0
- package/dist/js/node/schema/Schema.js +63 -0
- package/dist/js/node/schema/index.js +118 -0
- package/dist/js/node/schema/legacy.js +169 -0
- package/dist/js/node/types/config/deploy.js +15 -0
- package/dist/js/node/types/config/dev.js +15 -0
- package/dist/js/node/types/config/experiments.js +15 -0
- package/dist/js/node/types/config/html.js +15 -0
- package/dist/{cjs/builder/builder-webpack/webpackPlugins → js/node/types/config}/index.js +3 -3
- package/dist/js/node/types/config/output.js +15 -0
- package/dist/js/node/types/config/performance.js +15 -0
- package/dist/js/node/types/config/security.js +15 -0
- package/dist/js/node/types/config/source.js +15 -0
- package/dist/js/node/types/config/tools.js +15 -0
- package/dist/js/node/types/hooks.js +15 -0
- package/dist/js/node/types/index.js +19 -0
- package/dist/js/node/types/legacyConfig/deploy.js +15 -0
- package/dist/js/node/types/legacyConfig/dev.js +15 -0
- package/dist/js/node/types/legacyConfig/index.js +15 -0
- package/dist/js/node/types/legacyConfig/output.js +15 -0
- package/dist/js/node/types/legacyConfig/source.js +15 -0
- package/dist/js/node/types/legacyConfig/tools.js +15 -0
- package/dist/js/node/utils/config.js +153 -0
- package/dist/js/node/utils/createServer.js +106 -0
- package/dist/js/node/utils/env.js +38 -0
- package/dist/js/node/utils/generateWatchFiles.js +85 -0
- package/dist/js/node/utils/getSelectedEntries.js +81 -0
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/language.js +31 -0
- package/dist/js/node/utils/printInstructions.js +54 -0
- package/dist/js/node/utils/restart.js +67 -0
- package/dist/js/node/utils/routes.js +59 -0
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/constants.js +40 -0
- package/dist/js/treeshaking/analyze/generateCode.js +485 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +62 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
- package/dist/js/treeshaking/analyze/index.js +697 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +384 -0
- package/dist/js/treeshaking/analyze/templates.js +468 -0
- package/dist/js/treeshaking/analyze/utils.js +374 -0
- package/dist/{esm/builder/shared/builderPlugins/adapterModern.js → js/treeshaking/builder/builderPlugins/compatModern.js} +142 -138
- package/dist/js/treeshaking/builder/index.js +374 -0
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/share.js +40 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
- package/dist/{esm/builder/builder-webpack/webpackPlugins/RouterPlugin.js → js/treeshaking/builder/webpackPlugins/routerPlugin.js} +3 -6
- package/dist/js/treeshaking/commands/build.js +291 -0
- package/dist/js/treeshaking/commands/deploy.js +154 -0
- package/dist/js/treeshaking/commands/dev.js +301 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +149 -0
- package/dist/js/treeshaking/commands/serve.js +199 -0
- package/dist/js/treeshaking/config/default.js +210 -0
- package/dist/js/treeshaking/config/index.js +3 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
- package/dist/js/treeshaking/config/initial/index.js +12 -0
- package/dist/js/treeshaking/config/initial/inits.js +209 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
- package/dist/js/treeshaking/defineConfig.js +61 -0
- package/dist/js/treeshaking/exports/server.js +2 -0
- package/dist/js/treeshaking/hooks.js +29 -0
- package/dist/js/treeshaking/index.js +706 -0
- package/dist/js/treeshaking/initialize/index.js +276 -0
- package/dist/js/treeshaking/locale/en.js +38 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +38 -0
- package/dist/js/treeshaking/schema/Schema.js +273 -0
- package/dist/js/treeshaking/schema/index.js +181 -0
- package/dist/js/treeshaking/schema/legacy.js +337 -0
- package/dist/js/treeshaking/types/config/deploy.js +1 -0
- package/dist/js/treeshaking/types/config/dev.js +1 -0
- package/dist/js/treeshaking/types/config/experiments.js +1 -0
- package/dist/js/treeshaking/types/config/html.js +1 -0
- package/dist/js/treeshaking/types/config/index.js +1 -0
- package/dist/js/treeshaking/types/config/output.js +1 -0
- package/dist/js/treeshaking/types/config/performance.js +1 -0
- package/dist/js/treeshaking/types/config/security.js +1 -0
- package/dist/js/treeshaking/types/config/source.js +1 -0
- package/dist/js/treeshaking/types/config/tools.js +1 -0
- package/dist/js/treeshaking/types/hooks.js +1 -0
- package/dist/js/treeshaking/types/index.js +3 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
- package/dist/js/treeshaking/utils/config.js +302 -0
- package/dist/js/treeshaking/utils/createServer.js +258 -0
- package/dist/js/treeshaking/utils/env.js +13 -0
- package/dist/js/treeshaking/utils/generateWatchFiles.js +214 -0
- package/dist/js/treeshaking/utils/getSelectedEntries.js +186 -0
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/js/treeshaking/utils/language.js +6 -0
- package/dist/js/treeshaking/utils/printInstructions.js +152 -0
- package/dist/js/treeshaking/utils/restart.js +187 -0
- package/dist/js/treeshaking/utils/routes.js +153 -0
- package/dist/js/treeshaking/utils/types.js +1 -0
- package/dist/types/analyze/templates.d.ts +3 -1
- package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +7 -0
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +5 -0
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +4 -0
- package/dist/types/builder/shared/builderPlugins/index.d.ts +3 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +5 -0
- package/dist/types/builder/shared/bundlerPlugins/index.d.ts +3 -0
- package/dist/types/builder/shared/index.d.ts +1 -1
- package/dist/types/builder/shared/types.d.ts +7 -4
- package/dist/types/locale/en.d.ts +1 -0
- package/dist/types/locale/index.d.ts +2 -0
- package/dist/types/locale/zh.d.ts +1 -0
- package/dist/types/types/config/output.d.ts +3 -15
- package/package.json +12 -12
- package/dist/esm/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/esm-node/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/types/builder/builder-webpack/webpackPlugins/RouterPlugin.d.ts +0 -4
- package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +0 -1
- package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +0 -13
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function _arrayLikeToArray(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _arrayWithoutHoles(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
8
|
+
}
|
|
1
9
|
function _defineProperty(obj, key, value) {
|
|
2
10
|
if (key in obj) {
|
|
3
11
|
Object.defineProperty(obj, key, {
|
|
@@ -11,6 +19,12 @@ function _defineProperty(obj, key, value) {
|
|
|
11
19
|
}
|
|
12
20
|
return obj;
|
|
13
21
|
}
|
|
22
|
+
function _iterableToArray(iter) {
|
|
23
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
24
|
+
}
|
|
25
|
+
function _nonIterableSpread() {
|
|
26
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
27
|
+
}
|
|
14
28
|
function _objectSpread(target) {
|
|
15
29
|
for(var i = 1; i < arguments.length; i++){
|
|
16
30
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -50,57 +64,32 @@ function _objectSpreadProps(target, source) {
|
|
|
50
64
|
}
|
|
51
65
|
return target;
|
|
52
66
|
}
|
|
67
|
+
function _toConsumableArray(arr) {
|
|
68
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
69
|
+
}
|
|
70
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
71
|
+
if (!o) return;
|
|
72
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
73
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
74
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
75
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
76
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
77
|
+
}
|
|
78
|
+
import { join } from "path";
|
|
53
79
|
import { mergeBuilderConfig } from "@modern-js/builder-shared";
|
|
54
|
-
import { getEntryOptions } from "@modern-js/utils";
|
|
55
|
-
import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
|
|
56
80
|
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
57
|
-
import
|
|
58
|
-
import {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (isStreaming(server.ssr)) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
68
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
69
|
-
try {
|
|
70
|
-
for(var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
71
|
-
var name = _step.value;
|
|
72
|
-
if (isStreaming(server.ssrByEntries[name])) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} catch (err) {
|
|
77
|
-
_didIteratorError = true;
|
|
78
|
-
_iteratorError = err;
|
|
79
|
-
} finally{
|
|
80
|
-
try {
|
|
81
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
82
|
-
_iterator.return();
|
|
83
|
-
}
|
|
84
|
-
} finally{
|
|
85
|
-
if (_didIteratorError) {
|
|
86
|
-
throw _iteratorError;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
};
|
|
93
|
-
var builderPluginAdapterModern = function(options) {
|
|
81
|
+
import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
|
|
82
|
+
import { getEntryOptions } from "@modern-js/utils";
|
|
83
|
+
import { BottomTemplatePlugin } from "../webpackPlugins/htmlBottomTemplate";
|
|
84
|
+
import { HtmlAsyncChunkPlugin } from "../webpackPlugins/htmlAsyncChunkPlugin";
|
|
85
|
+
import { createCopyPattern } from "../share";
|
|
86
|
+
import RouterPlugin from "../webpackPlugins/routerPlugin";
|
|
87
|
+
var PluginCompatModern = function(appContext, modernConfig, options) {
|
|
94
88
|
return {
|
|
95
|
-
name: "builder-plugin-
|
|
89
|
+
name: "builder-plugin-compat-modern",
|
|
96
90
|
setup: function setup(api) {
|
|
97
|
-
var isHtmlEnabled = function isHtmlEnabled(config, target) {
|
|
98
|
-
var _config_tools;
|
|
99
|
-
return ((_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : _config_tools.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
100
|
-
};
|
|
101
|
-
var normalizedConfig = options.normalizedConfig, appContext = options.appContext;
|
|
102
91
|
api.modifyBuilderConfig(function(config) {
|
|
103
|
-
if (isStreamingSSR(
|
|
92
|
+
if (isStreamingSSR(modernConfig)) {
|
|
104
93
|
return mergeBuilderConfig(config, {
|
|
105
94
|
html: {
|
|
106
95
|
inject: "body"
|
|
@@ -109,44 +98,70 @@ var builderPluginAdapterModern = function(options) {
|
|
|
109
98
|
}
|
|
110
99
|
return config;
|
|
111
100
|
});
|
|
112
|
-
api.
|
|
101
|
+
api.modifyWebpackChain(function(chain, param) {
|
|
113
102
|
var target = param.target, CHAIN_ID = param.CHAIN_ID, isProd = param.isProd;
|
|
114
|
-
var
|
|
103
|
+
var isHtmlEnabled = function isHtmlEnabled(config, target2) {
|
|
104
|
+
var ref;
|
|
105
|
+
return ((ref = config.tools) === null || ref === void 0 ? void 0 : ref.htmlPlugin) !== false && target2 !== "node" && target2 !== "web-worker";
|
|
106
|
+
};
|
|
107
|
+
var ref;
|
|
108
|
+
var builderNormalizedConfig = api.getNormalizedConfig();
|
|
115
109
|
if (target === "node") {
|
|
116
110
|
chain.name("server");
|
|
117
|
-
} else if (target === "service-worker") {
|
|
118
|
-
chain.name("service-worker");
|
|
119
|
-
} else if (target === "web-worker") {
|
|
120
|
-
chain.name("worker");
|
|
121
111
|
} else if (target === "modern-web") {
|
|
122
112
|
chain.name("modern");
|
|
123
113
|
} else {
|
|
124
114
|
chain.name("client");
|
|
125
115
|
}
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
|
|
117
|
+
if (target === "node") {
|
|
118
|
+
applyNodeCompat(chain, modernConfig, isProd);
|
|
128
119
|
}
|
|
129
|
-
if (isHtmlEnabled(
|
|
130
|
-
|
|
120
|
+
if (isHtmlEnabled(builderNormalizedConfig, target)) {
|
|
121
|
+
applyBottomHtmlWebpackPlugin({
|
|
131
122
|
api: api,
|
|
132
123
|
chain: chain,
|
|
133
|
-
|
|
124
|
+
CHAIN_ID: CHAIN_ID,
|
|
134
125
|
appContext: appContext,
|
|
135
|
-
|
|
126
|
+
modernConfig: modernConfig
|
|
136
127
|
});
|
|
137
128
|
applyAsyncChunkHtmlPlugin({
|
|
138
129
|
chain: chain,
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
CHAIN_ID: CHAIN_ID,
|
|
131
|
+
modernConfig: modernConfig
|
|
141
132
|
});
|
|
142
133
|
}
|
|
143
|
-
if (
|
|
134
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
135
|
+
var defaultCopyPattern = createCopyPattern(appContext, modernConfig, "public", chain);
|
|
136
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(function(args) {
|
|
137
|
+
var ref;
|
|
138
|
+
return [
|
|
139
|
+
{
|
|
140
|
+
patterns: _toConsumableArray(((ref = args[0]) === null || ref === void 0 ? void 0 : ref.patterns) || []).concat([
|
|
141
|
+
defaultCopyPattern
|
|
142
|
+
])
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
var entrypoints = appContext.entrypoints;
|
|
148
|
+
var existNestedRoutes = entrypoints.some(function(entrypoint) {
|
|
149
|
+
return entrypoint.nestedRoutesEntry;
|
|
150
|
+
});
|
|
151
|
+
var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.runtime) === null || ref === void 0 ? void 0 : ref.router;
|
|
152
|
+
var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
|
|
153
|
+
if (existNestedRoutes || routerManifest) {
|
|
154
|
+
chain.plugin("route-plugin").use(RouterPlugin);
|
|
155
|
+
}
|
|
156
|
+
if (target !== "node") {
|
|
144
157
|
var bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
145
158
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
146
159
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
147
160
|
}
|
|
148
161
|
});
|
|
149
|
-
|
|
162
|
+
if (options) {
|
|
163
|
+
applyCallbacks(api, options);
|
|
164
|
+
}
|
|
150
165
|
}
|
|
151
166
|
};
|
|
152
167
|
};
|
|
@@ -160,58 +175,11 @@ function applyCallbacks(api, options) {
|
|
|
160
175
|
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
161
176
|
options.onExit && api.onExit(options.onExit);
|
|
162
177
|
}
|
|
163
|
-
function
|
|
164
|
-
var api = param.api, chain = param.chain, modernConfig = param.modernConfig, appContext = param.appContext, CHAIN_ID = param.CHAIN_ID;
|
|
165
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
166
|
-
try {
|
|
167
|
-
var _loop = function() {
|
|
168
|
-
var entryName = _step.value;
|
|
169
|
-
var baseTemplateParams = _objectSpread({
|
|
170
|
-
entryName: entryName,
|
|
171
|
-
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
172
|
-
mountId: modernConfig.html.mountId
|
|
173
|
-
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
174
|
-
chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function(args) {
|
|
175
|
-
return [
|
|
176
|
-
_objectSpreadProps(_objectSpread({}, args[0] || {}), {
|
|
177
|
-
__internal__: true,
|
|
178
|
-
bottomTemplate: appContext.htmlTemplates["__".concat(entryName, "-bottom__")] && lodashTemplate(appContext.htmlTemplates["__".concat(entryName, "-bottom__")])(baseTemplateParams)
|
|
179
|
-
})
|
|
180
|
-
];
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
for(var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
184
|
-
} catch (err) {
|
|
185
|
-
_didIteratorError = true;
|
|
186
|
-
_iteratorError = err;
|
|
187
|
-
} finally{
|
|
188
|
-
try {
|
|
189
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
190
|
-
_iterator.return();
|
|
191
|
-
}
|
|
192
|
-
} finally{
|
|
193
|
-
if (_didIteratorError) {
|
|
194
|
-
throw _iteratorError;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [
|
|
199
|
-
HtmlWebpackPlugin
|
|
200
|
-
]);
|
|
201
|
-
}
|
|
202
|
-
function applyAsyncChunkHtmlPlugin(param) {
|
|
203
|
-
var chain = param.chain, modernConfig = param.modernConfig, CHAIN_ID = param.CHAIN_ID;
|
|
204
|
-
if (isStreamingSSR(modernConfig)) {
|
|
205
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
|
|
206
|
-
HtmlWebpackPlugin
|
|
207
|
-
]);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
178
|
+
function applyNodeCompat(chain, modernConfig, isProd) {
|
|
211
179
|
var filterEntriesBySSRConfig = function filterEntriesBySSRConfig(isProd2, chain2, serverConfig, outputConfig) {
|
|
212
|
-
var
|
|
180
|
+
var ref;
|
|
213
181
|
var entries = chain2.entryPoints.entries();
|
|
214
|
-
if (isProd2 && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (
|
|
182
|
+
if (isProd2 && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (ref = outputConfig.ssg) === null || ref === void 0 ? void 0 : ref[0]) === "function")) {
|
|
215
183
|
return;
|
|
216
184
|
}
|
|
217
185
|
if (typeof entries === "undefined") {
|
|
@@ -230,14 +198,14 @@ function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
|
230
198
|
}
|
|
231
199
|
});
|
|
232
200
|
}
|
|
233
|
-
var
|
|
201
|
+
var ref1 = serverConfig || {}, ssr = ref1.ssr, ssrByEntries = ref1.ssrByEntries;
|
|
234
202
|
entryNames.forEach(function(name) {
|
|
235
203
|
if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
|
|
236
204
|
chain2.entryPoints.delete(name);
|
|
237
205
|
}
|
|
238
206
|
});
|
|
239
207
|
};
|
|
240
|
-
var
|
|
208
|
+
for(var _i = 0, _iter = [
|
|
241
209
|
".node.js",
|
|
242
210
|
".node.jsx",
|
|
243
211
|
".node.ts",
|
|
@@ -246,19 +214,33 @@ function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
|
246
214
|
".server.ts",
|
|
247
215
|
".server.ts",
|
|
248
216
|
".server.tsx"
|
|
249
|
-
];
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
217
|
+
]; _i < _iter.length; _i++){
|
|
218
|
+
var ext = _iter[_i];
|
|
219
|
+
chain.resolve.extensions.prepend(ext);
|
|
220
|
+
}
|
|
221
|
+
filterEntriesBySSRConfig(isProd, chain, modernConfig.server, modernConfig.output);
|
|
222
|
+
}
|
|
223
|
+
function applyBottomHtmlWebpackPlugin(param) {
|
|
224
|
+
var api = param.api, chain = param.chain, modernConfig = param.modernConfig, appContext = param.appContext, CHAIN_ID = param.CHAIN_ID;
|
|
256
225
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
257
226
|
try {
|
|
258
|
-
|
|
259
|
-
var
|
|
260
|
-
|
|
261
|
-
|
|
227
|
+
var _loop = function() {
|
|
228
|
+
var entryName = _step.value;
|
|
229
|
+
var baseTemplateParams = _objectSpread({
|
|
230
|
+
entryName: entryName,
|
|
231
|
+
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
232
|
+
mountId: modernConfig.html.mountId
|
|
233
|
+
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
234
|
+
chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function(args) {
|
|
235
|
+
return [
|
|
236
|
+
_objectSpreadProps(_objectSpread({}, args[0] || {}), {
|
|
237
|
+
__internal__: true,
|
|
238
|
+
bottomTemplate: appContext.htmlTemplates["__".concat(entryName, "-bottom__")] && lodashTemplate(appContext.htmlTemplates["__".concat(entryName, "-bottom__")])(baseTemplateParams)
|
|
239
|
+
})
|
|
240
|
+
];
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
for(var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
262
244
|
} catch (err) {
|
|
263
245
|
_didIteratorError = true;
|
|
264
246
|
_iteratorError = err;
|
|
@@ -273,28 +255,50 @@ function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
|
273
255
|
}
|
|
274
256
|
}
|
|
275
257
|
}
|
|
276
|
-
|
|
277
|
-
|
|
258
|
+
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [
|
|
259
|
+
HtmlWebpackPlugin
|
|
260
|
+
]);
|
|
261
|
+
}
|
|
262
|
+
var isStreamingSSR = function(userConfig) {
|
|
263
|
+
var isStreaming = function(ssr) {
|
|
264
|
+
return ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
265
|
+
};
|
|
266
|
+
var server = userConfig.server;
|
|
267
|
+
if (isStreaming(server.ssr)) {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
271
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
278
272
|
try {
|
|
279
|
-
for(var
|
|
280
|
-
var
|
|
281
|
-
|
|
273
|
+
for(var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
274
|
+
var name = _step.value;
|
|
275
|
+
if (isStreaming(server.ssrByEntries[name])) {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
282
278
|
}
|
|
283
279
|
} catch (err) {
|
|
284
|
-
|
|
285
|
-
|
|
280
|
+
_didIteratorError = true;
|
|
281
|
+
_iteratorError = err;
|
|
286
282
|
} finally{
|
|
287
283
|
try {
|
|
288
|
-
if (!
|
|
289
|
-
|
|
284
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
285
|
+
_iterator.return();
|
|
290
286
|
}
|
|
291
287
|
} finally{
|
|
292
|
-
if (
|
|
293
|
-
throw
|
|
288
|
+
if (_didIteratorError) {
|
|
289
|
+
throw _iteratorError;
|
|
294
290
|
}
|
|
295
291
|
}
|
|
296
292
|
}
|
|
297
293
|
}
|
|
298
|
-
|
|
294
|
+
return false;
|
|
295
|
+
};
|
|
296
|
+
function applyAsyncChunkHtmlPlugin(param) {
|
|
297
|
+
var chain = param.chain, modernConfig = param.modernConfig, CHAIN_ID = param.CHAIN_ID;
|
|
298
|
+
if (isStreamingSSR(modernConfig)) {
|
|
299
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
|
|
300
|
+
HtmlWebpackPlugin
|
|
301
|
+
]);
|
|
302
|
+
}
|
|
299
303
|
}
|
|
300
|
-
export {
|
|
304
|
+
export { PluginCompatModern };
|