@modern-js/app-tools 2.6.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/CHANGELOG.md +52 -0
- package/README.md +2 -2
- package/dist/cjs/analyze/generateCode.js +7 -7
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/cjs/analyze/index.js +20 -2
- package/dist/cjs/analyze/nestedRoutes.js +1 -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/commands/dev.js +6 -0
- package/dist/cjs/commands/serve.js +17 -0
- 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/cjs/schema/index.js +4 -0
- package/dist/esm/analyze/generateCode.js +8 -9
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/esm/analyze/index.js +15 -3
- package/dist/esm/analyze/nestedRoutes.js +1 -1
- 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/commands/dev.js +6 -0
- package/dist/esm/commands/serve.js +6 -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/schema/index.js +7 -0
- package/dist/esm-node/analyze/generateCode.js +14 -9
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/esm-node/analyze/index.js +22 -3
- package/dist/esm-node/analyze/nestedRoutes.js +1 -1
- 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/commands/dev.js +6 -0
- package/dist/esm-node/commands/serve.js +18 -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/esm-node/schema/index.js +4 -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 +5 -3
- 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/lib/types.d.ts +1 -1
- package/package.json +28 -28
- 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
package/dist/cjs/builder/{builder-webpack/webpackPlugins → shared/bundlerPlugins}/RouterPlugin.js
RENAMED
|
@@ -65,7 +65,7 @@ class RouterPlugin {
|
|
|
65
65
|
chunkGroups: true,
|
|
66
66
|
chunks: true
|
|
67
67
|
});
|
|
68
|
-
const { publicPath } = stats;
|
|
68
|
+
const { publicPath, chunks = [] } = stats;
|
|
69
69
|
const routeAssets = {};
|
|
70
70
|
const { namedChunkGroups, assetsByChunkName } = stats;
|
|
71
71
|
if (!namedChunkGroups || !assetsByChunkName) {
|
|
@@ -98,17 +98,23 @@ class RouterPlugin {
|
|
|
98
98
|
const entryChunkIds = entrypointsArray.map(
|
|
99
99
|
(entrypoint) => entrypoint[0]
|
|
100
100
|
);
|
|
101
|
-
const entryChunks = [...
|
|
102
|
-
|
|
101
|
+
const entryChunks = [...chunks].filter((chunk) => {
|
|
102
|
+
var _a;
|
|
103
|
+
return (_a = chunk.names) == null ? void 0 : _a.some((name) => entryChunkIds.includes(name));
|
|
103
104
|
});
|
|
104
105
|
const entryChunkFiles = entryChunks.map(
|
|
105
|
-
(chunk) => [...chunk.files].find((fname) => fname.includes(".js"))
|
|
106
|
+
(chunk) => [...chunk.files || []].find((fname) => fname.includes(".js"))
|
|
106
107
|
);
|
|
107
108
|
for (const file of entryChunkFiles) {
|
|
108
109
|
const asset = compilation.assets[file];
|
|
109
110
|
const newContent = `${injectedContent}${asset.source().toString()}`;
|
|
110
111
|
newAssetsMap.set(import_path.default.join(outputPath, file), newContent);
|
|
111
|
-
compilation.updateAsset(
|
|
112
|
+
compilation.updateAsset(
|
|
113
|
+
file,
|
|
114
|
+
new RawSource(newContent),
|
|
115
|
+
// FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
116
|
+
void 0
|
|
117
|
+
);
|
|
112
118
|
}
|
|
113
119
|
const filename = import_path.default.join(outputPath, import_utils.ROUTE_MINIFEST_FILE);
|
|
114
120
|
await import_utils.fs.ensureFile(filename);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var bundlerPlugins_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(bundlerPlugins_exports);
|
|
17
|
+
__reExport(bundlerPlugins_exports, require("./HtmlAsyncChunkPlugin"), module.exports);
|
|
18
|
+
__reExport(bundlerPlugins_exports, require("./HtmlBottomTemplate"), module.exports);
|
|
19
|
+
__reExport(bundlerPlugins_exports, require("./RouterPlugin"), module.exports);
|
|
@@ -16,4 +16,4 @@ var shared_exports = {};
|
|
|
16
16
|
module.exports = __toCommonJS(shared_exports);
|
|
17
17
|
__reExport(shared_exports, require("./createCopyPattern"), module.exports);
|
|
18
18
|
__reExport(shared_exports, require("./types"), module.exports);
|
|
19
|
-
__reExport(shared_exports, require("./builderPlugins
|
|
19
|
+
__reExport(shared_exports, require("./builderPlugins"), module.exports);
|
package/dist/cjs/commands/dev.js
CHANGED
|
@@ -63,6 +63,12 @@ const dev = async (api, options) => {
|
|
|
63
63
|
host: normalizedConfig.dev.host,
|
|
64
64
|
...(_a = normalizedConfig.tools) == null ? void 0 : _a.devServer
|
|
65
65
|
},
|
|
66
|
+
appContext: {
|
|
67
|
+
appDirectory: appContext.appDirectory,
|
|
68
|
+
sharedDirectory: appContext.sharedDirectory,
|
|
69
|
+
apiDirectory: appContext.apiDirectory,
|
|
70
|
+
lambdaDirectory: appContext.lambdaDirectory
|
|
71
|
+
},
|
|
66
72
|
pwd: appDirectory,
|
|
67
73
|
config: normalizedConfig,
|
|
68
74
|
serverConfigFile,
|
|
@@ -50,6 +50,23 @@ const start = async (api) => {
|
|
|
50
50
|
const app = await (0, import_prod_server.default)({
|
|
51
51
|
pwd: appDirectory,
|
|
52
52
|
config: userConfig,
|
|
53
|
+
appContext: {
|
|
54
|
+
sharedDirectory: (0, import_utils.getTargetDir)(
|
|
55
|
+
appContext.sharedDirectory,
|
|
56
|
+
appContext.appDirectory,
|
|
57
|
+
appContext.distDirectory
|
|
58
|
+
),
|
|
59
|
+
apiDirectory: (0, import_utils.getTargetDir)(
|
|
60
|
+
appContext.apiDirectory,
|
|
61
|
+
appContext.appDirectory,
|
|
62
|
+
appContext.distDirectory
|
|
63
|
+
),
|
|
64
|
+
lambdaDirectory: (0, import_utils.getTargetDir)(
|
|
65
|
+
appContext.lambdaDirectory,
|
|
66
|
+
appContext.appDirectory,
|
|
67
|
+
appContext.distDirectory
|
|
68
|
+
)
|
|
69
|
+
},
|
|
53
70
|
serverConfigFile,
|
|
54
71
|
internalPlugins: (0, import_createServer.injectDataLoaderPlugin)(serverInternalPlugins),
|
|
55
72
|
apiOnly
|
package/dist/cjs/index.js
CHANGED
|
@@ -53,7 +53,7 @@ const upgradeModel = import_utils.Import.lazy(
|
|
|
53
53
|
const devCommand = async (program, api) => {
|
|
54
54
|
const runner = api.useHookRunners();
|
|
55
55
|
const devToolMetas = await runner.registerDev();
|
|
56
|
-
const devProgram = program.command("dev").alias("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).action(async (options) => {
|
|
56
|
+
const devProgram = program.command("dev").alias("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).option("--web-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.webOnly)).action(async (options) => {
|
|
57
57
|
const { dev } = await Promise.resolve().then(() => __toESM(require("./commands/dev")));
|
|
58
58
|
await dev(api, options);
|
|
59
59
|
});
|
package/dist/cjs/locale/en.js
CHANGED
|
@@ -30,6 +30,7 @@ const EN_LOCALE = {
|
|
|
30
30
|
describe: "start dev server",
|
|
31
31
|
entry: "compiler by entry",
|
|
32
32
|
apiOnly: "start api server only",
|
|
33
|
+
webOnly: "start web server only",
|
|
33
34
|
selectEntry: "Please select the entry that needs to be built",
|
|
34
35
|
requireEntry: "You must choose at least one entry"
|
|
35
36
|
},
|
package/dist/cjs/locale/zh.js
CHANGED
package/dist/cjs/schema/index.js
CHANGED
|
@@ -148,8 +148,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
import path from "path";
|
|
151
|
-
import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
|
|
152
|
-
import { useResolvedConfigContext } from "@modern-js/core";
|
|
151
|
+
import { fs, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
153
152
|
import * as templates from "./templates";
|
|
154
153
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
155
154
|
import { FILE_SYSTEM_ROUTES_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_BOOTSTRAP_FILE_NAME } from "./constants";
|
|
@@ -246,7 +245,7 @@ var generateCode = function() {
|
|
|
246
245
|
}
|
|
247
246
|
function _generateEntryCode() {
|
|
248
247
|
_generateEntryCode = _asyncToGenerator(function(entrypoint) {
|
|
249
|
-
var entryName, isAutoMount, customBootstrap, fileSystemRoutes, initialRoutes, nestedRoute, routes, config2, ssr, mode, hasPageRoute, _ref, code2, _, _tmp, routesServerFile, code3, _ref1, importStatements, plugins, _ref2, renderFunction, exportStatement, code, entryFile, _ref3, asyncEntryCode, bootstrapFile;
|
|
248
|
+
var entryName, isAutoMount, customBootstrap, fileSystemRoutes, _config2_output, initialRoutes, nestedRoute, routes, config2, ssr, useSSG, mode, hasPageRoute, _ref, code2, _, _tmp, routesServerFile, code3, _ref1, importStatements, plugins, _ref2, renderFunction, exportStatement, code, entryFile, _ref3, asyncEntryCode, bootstrapFile;
|
|
250
249
|
return __generator(this, function(_state) {
|
|
251
250
|
switch(_state.label){
|
|
252
251
|
case 0:
|
|
@@ -297,12 +296,11 @@ var generateCode = function() {
|
|
|
297
296
|
];
|
|
298
297
|
case 3:
|
|
299
298
|
routes = _state.sent().routes;
|
|
300
|
-
config2 = useResolvedConfigContext();
|
|
299
|
+
config2 = api.useResolvedConfigContext();
|
|
301
300
|
ssr = getEntryOptions(entryName, config2.server.ssr, config2.server.ssrByEntries, packageName);
|
|
301
|
+
useSSG = isSSGEntry(config2, entryName, entrypoints);
|
|
302
302
|
if (ssr) {
|
|
303
303
|
mode = typeof ssr === "object" ? ssr.mode || "string" : "string";
|
|
304
|
-
} else {
|
|
305
|
-
mode = false;
|
|
306
304
|
}
|
|
307
305
|
if (mode === "stream") {
|
|
308
306
|
hasPageRoute = routes.some(function(route) {
|
|
@@ -321,10 +319,11 @@ var generateCode = function() {
|
|
|
321
319
|
4,
|
|
322
320
|
templates.fileSystemRoutes({
|
|
323
321
|
routes: routes,
|
|
324
|
-
ssrMode: mode,
|
|
322
|
+
ssrMode: useSSG ? "string" : mode,
|
|
325
323
|
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
326
324
|
entryName: entrypoint.entryName,
|
|
327
|
-
internalDirectory: internalDirectory
|
|
325
|
+
internalDirectory: internalDirectory,
|
|
326
|
+
splitRoutesChunks: config2 === null || config2 === void 0 ? void 0 : (_config2_output = config2.output) === null || _config2_output === void 0 ? void 0 : _config2_output.splitRoutesChunks
|
|
328
327
|
})
|
|
329
328
|
];
|
|
330
329
|
case 4:
|
|
@@ -336,7 +335,7 @@ var generateCode = function() {
|
|
|
336
335
|
];
|
|
337
336
|
case 5:
|
|
338
337
|
_ref = _state.sent(), code2 = _ref.code;
|
|
339
|
-
if (!(entrypoint.nestedRoutesEntry &&
|
|
338
|
+
if (!(entrypoint.nestedRoutesEntry && isUseSSRBundle(config2))) return [
|
|
340
339
|
3,
|
|
341
340
|
8
|
|
342
341
|
];
|
|
@@ -111,7 +111,7 @@ var recursiveReadDir = function(param) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
var route1 = {
|
|
114
|
-
path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1]).concat(dynamicRouteMatched[2]) : filename),
|
|
114
|
+
path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1].replace(/\$$/, "?")).concat(dynamicRouteMatched[2]) : filename),
|
|
115
115
|
_component: alias1,
|
|
116
116
|
component: componentName1,
|
|
117
117
|
parent: parent,
|
|
@@ -111,7 +111,7 @@ var recursiveReadDirLegacy = function(param) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
var route1 = {
|
|
114
|
-
path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1]).concat(dynamicRouteMatched[2]) : filename),
|
|
114
|
+
path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1].replace(/\$$/, "?")).concat(dynamicRouteMatched[2]) : filename),
|
|
115
115
|
_component: alias1,
|
|
116
116
|
component: componentName1,
|
|
117
117
|
exact: true,
|
|
@@ -221,8 +221,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
import * as path from "path";
|
|
224
|
-
import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist, getCommand, isDevCommand } from "@modern-js/utils";
|
|
224
|
+
import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist, getCommand, isDevCommand, isSSGEntry } from "@modern-js/utils";
|
|
225
225
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
226
|
+
import { createVirtualModule } from "@modern-js/builder-shared";
|
|
226
227
|
import { printInstructions } from "../utils/printInstructions";
|
|
227
228
|
import { generateRoutes } from "../utils/routes";
|
|
228
229
|
import { emitResolvedConfig } from "../utils/config";
|
|
@@ -553,9 +554,12 @@ var analyze_default = function(param) {
|
|
|
553
554
|
entrypoints.forEach(function(entrypoint) {
|
|
554
555
|
var entryName = entrypoint.entryName;
|
|
555
556
|
var ssr = getEntryOptions(entryName, resolvedConfig.server.ssr, resolvedConfig.server.ssrByEntries, packageName);
|
|
556
|
-
|
|
557
|
+
var useSSG = isSSGEntry(resolvedConfig, entryName, entrypoints);
|
|
558
|
+
if (entrypoint.nestedRoutesEntry && (ssr || useSSG) && name === "server") {
|
|
559
|
+
var serverLoaderRuntime = require.resolve("@modern-js/plugin-data-loader/runtime");
|
|
557
560
|
var serverLoadersFile = getServerLoadersFile(internalDirectory, entryName);
|
|
558
|
-
|
|
561
|
+
var combinedModule = createVirtualModule('export * from "'.concat(serverLoaderRuntime, '"; export * from "').concat(serverLoadersFile, '"'));
|
|
562
|
+
chain.entry("".concat(entryName, "-server-loaders")).add(combinedModule);
|
|
559
563
|
}
|
|
560
564
|
});
|
|
561
565
|
}
|
|
@@ -658,6 +662,14 @@ var analyze_default = function(param) {
|
|
|
658
662
|
});
|
|
659
663
|
})();
|
|
660
664
|
},
|
|
665
|
+
validateSchema: function validateSchema() {
|
|
666
|
+
return {
|
|
667
|
+
target: "output.splitRoutesChunks",
|
|
668
|
+
schema: {
|
|
669
|
+
type: "boolean"
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
},
|
|
661
673
|
fileChange: function fileChange(e) {
|
|
662
674
|
return _asyncToGenerator(function() {
|
|
663
675
|
var appContext, appDirectory, filename, eventType, isPageFile, absoluteFilePath, isRouteComponent, resolvedConfig, generateCode, entrypoints;
|
|
@@ -297,15 +297,16 @@ var routesForServer = function(param) {
|
|
|
297
297
|
};
|
|
298
298
|
var fileSystemRoutes = function() {
|
|
299
299
|
var _ref = _asyncToGenerator(function(param) {
|
|
300
|
-
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo;
|
|
300
|
+
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, _param_splitRoutesChunks, splitRoutesChunks, loadings, errors, loaders, loadersMap, webpackMode, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo;
|
|
301
301
|
return __generator(this, function(_state) {
|
|
302
302
|
switch(_state.label){
|
|
303
303
|
case 0:
|
|
304
|
-
routes = param.routes, ssrMode = param.ssrMode, nestedRoutesEntry = param.nestedRoutesEntry, entryName = param.entryName, internalDirectory = param.internalDirectory;
|
|
304
|
+
routes = param.routes, ssrMode = param.ssrMode, nestedRoutesEntry = param.nestedRoutesEntry, entryName = param.entryName, internalDirectory = param.internalDirectory, _param_splitRoutesChunks = param.splitRoutesChunks, splitRoutesChunks = _param_splitRoutesChunks === void 0 ? true : _param_splitRoutesChunks;
|
|
305
305
|
loadings = [];
|
|
306
306
|
errors = [];
|
|
307
307
|
loaders = [];
|
|
308
308
|
loadersMap = {};
|
|
309
|
+
webpackMode = splitRoutesChunks ? "lazy" : "eager";
|
|
309
310
|
loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "map.json");
|
|
310
311
|
importLazyCode = '\n import { lazy } from "react";\n import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"\n ';
|
|
311
312
|
rootLayoutCode = "";
|
|
@@ -354,15 +355,15 @@ var fileSystemRoutes = function() {
|
|
|
354
355
|
rootLayoutCode = "import RootLayout from '".concat(route._component, "'");
|
|
355
356
|
component = "RootLayout";
|
|
356
357
|
} else if (ssrMode === "string") {
|
|
357
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
|
|
358
|
+
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, '" */ /* webpackMode: "').concat(webpackMode, "\" */ '").concat(route._component, "')");
|
|
358
359
|
component = "loadable(".concat(lazyImport, ")");
|
|
359
360
|
} else {
|
|
360
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
|
|
361
|
+
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, '" */ /* webpackMode: "').concat(webpackMode, "\" */ '").concat(route._component, "')");
|
|
361
362
|
component = "lazy(".concat(lazyImport, ")");
|
|
362
363
|
}
|
|
363
364
|
}
|
|
364
365
|
} else if (route._component) {
|
|
365
|
-
lazyImport =
|
|
366
|
+
lazyImport = '() => import( /* webpackMode: "'.concat(webpackMode, "\" */ '").concat(route._component, "')");
|
|
366
367
|
component = "loadable(".concat(lazyImport, ")");
|
|
367
368
|
}
|
|
368
369
|
var finalRoute = _objectSpreadProps(_objectSpread({}, route), {
|
|
@@ -25,7 +25,6 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
25
25
|
}
|
|
26
26
|
import { join } from "path";
|
|
27
27
|
import { createCopyPattern } from "../../shared";
|
|
28
|
-
import { RouterPlugin } from "../webpackPlugins";
|
|
29
28
|
var builderPluginCompatModern = function(options) {
|
|
30
29
|
return {
|
|
31
30
|
name: "builder-plugin-compat-modern",
|
|
@@ -33,7 +32,6 @@ var builderPluginCompatModern = function(options) {
|
|
|
33
32
|
var modernConfig = options.normalizedConfig, appContext = options.appContext;
|
|
34
33
|
api.modifyWebpackChain(function(chain, param) {
|
|
35
34
|
var CHAIN_ID = param.CHAIN_ID;
|
|
36
|
-
var _modernConfig_runtime;
|
|
37
35
|
chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
|
|
38
36
|
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
39
37
|
var defaultCopyPattern = createCopyPattern(appContext, modernConfig, "public", chain);
|
|
@@ -48,15 +46,6 @@ var builderPluginCompatModern = function(options) {
|
|
|
48
46
|
];
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
var entrypoints = appContext.entrypoints;
|
|
52
|
-
var existNestedRoutes = entrypoints.some(function(entrypoint) {
|
|
53
|
-
return entrypoint.nestedRoutesEntry;
|
|
54
|
-
});
|
|
55
|
-
var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_runtime = modernConfig.runtime) === null || _modernConfig_runtime === void 0 ? void 0 : _modernConfig_runtime.router;
|
|
56
|
-
var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
|
|
57
|
-
if (existNestedRoutes || routerManifest) {
|
|
58
|
-
chain.plugin("route-plugin").use(RouterPlugin);
|
|
59
|
-
}
|
|
60
49
|
});
|
|
61
50
|
}
|
|
62
51
|
};
|
|
@@ -175,18 +175,20 @@ function applyBuilderPlugins(builder, options) {
|
|
|
175
175
|
}
|
|
176
176
|
function _applyBuilderPlugins() {
|
|
177
177
|
_applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
|
|
178
|
-
var
|
|
178
|
+
var _ref, builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR;
|
|
179
179
|
return __generator(this, function(_state) {
|
|
180
180
|
switch(_state.label){
|
|
181
181
|
case 0:
|
|
182
182
|
return [
|
|
183
183
|
4,
|
|
184
|
-
import("../shared/builderPlugins
|
|
184
|
+
import("../shared/builderPlugins")
|
|
185
185
|
];
|
|
186
186
|
case 1:
|
|
187
|
-
|
|
187
|
+
_ref = _state.sent(), builderPluginAdapterBasic = _ref.builderPluginAdapterBasic, builderPluginAdapterHtml = _ref.builderPluginAdapterHtml, builderPluginAdapterSSR = _ref.builderPluginAdapterSSR;
|
|
188
188
|
builder.addPlugins([
|
|
189
|
-
|
|
189
|
+
builderPluginAdapterBasic(options),
|
|
190
|
+
builderPluginAdapterSSR(options),
|
|
191
|
+
builderPluginAdapterHtml(options)
|
|
190
192
|
]);
|
|
191
193
|
return [
|
|
192
194
|
2
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var builderPluginAdapterBasic = function(options) {
|
|
2
|
+
return {
|
|
3
|
+
name: "builder-plugin-adapter-modern-basic",
|
|
4
|
+
setup: function setup(api) {
|
|
5
|
+
api.modifyBundlerChain(function(chain, param) {
|
|
6
|
+
var target = param.target, CHAIN_ID = param.CHAIN_ID;
|
|
7
|
+
if (target === "node") {
|
|
8
|
+
chain.name("server");
|
|
9
|
+
} else if (target === "service-worker") {
|
|
10
|
+
chain.name("service-worker");
|
|
11
|
+
} else if (target === "web-worker") {
|
|
12
|
+
chain.name("worker");
|
|
13
|
+
} else if (target === "modern-web") {
|
|
14
|
+
chain.name("modern");
|
|
15
|
+
} else {
|
|
16
|
+
chain.name("client");
|
|
17
|
+
}
|
|
18
|
+
if (target === "node" || target === "service-worker") {
|
|
19
|
+
applyNodeCompat(target, chain);
|
|
20
|
+
}
|
|
21
|
+
if (target === "web" || target === "modern-web") {
|
|
22
|
+
var bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
23
|
+
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
24
|
+
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
applyCallbacks(api, options);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
function applyCallbacks(api, options) {
|
|
32
|
+
options.onAfterBuild && api.onAfterBuild(options.onAfterBuild);
|
|
33
|
+
options.onAfterCreateCompiler && api.onAfterCreateCompiler(options.onAfterCreateCompiler);
|
|
34
|
+
options.onAfterStartDevServer && api.onAfterStartDevServer(options.onAfterStartDevServer);
|
|
35
|
+
options.onBeforeBuild && api.onBeforeBuild(options.onBeforeBuild);
|
|
36
|
+
options.onBeforeCreateCompiler && api.onBeforeCreateCompiler(options.onBeforeCreateCompiler);
|
|
37
|
+
options.onBeforeStartDevServer && api.onBeforeStartDevServer(options.onBeforeStartDevServer);
|
|
38
|
+
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
39
|
+
options.onExit && api.onExit(options.onExit);
|
|
40
|
+
}
|
|
41
|
+
function applyNodeCompat(target, chain) {
|
|
42
|
+
var nodeExts = [
|
|
43
|
+
".node.js",
|
|
44
|
+
".node.jsx",
|
|
45
|
+
".node.ts",
|
|
46
|
+
".node.tsx",
|
|
47
|
+
".server.js",
|
|
48
|
+
".server.ts",
|
|
49
|
+
".server.ts",
|
|
50
|
+
".server.tsx"
|
|
51
|
+
];
|
|
52
|
+
var webWorkerExts = [
|
|
53
|
+
".worker.js",
|
|
54
|
+
".worker.jsx",
|
|
55
|
+
".worker.ts",
|
|
56
|
+
".worker.tsx"
|
|
57
|
+
];
|
|
58
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
59
|
+
try {
|
|
60
|
+
for(var _iterator = nodeExts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
61
|
+
var ext = _step.value;
|
|
62
|
+
chain.resolve.extensions.prepend(ext);
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
_didIteratorError = true;
|
|
66
|
+
_iteratorError = err;
|
|
67
|
+
} finally{
|
|
68
|
+
try {
|
|
69
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
70
|
+
_iterator.return();
|
|
71
|
+
}
|
|
72
|
+
} finally{
|
|
73
|
+
if (_didIteratorError) {
|
|
74
|
+
throw _iteratorError;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (target === "service-worker") {
|
|
79
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
80
|
+
try {
|
|
81
|
+
for(var _iterator1 = webWorkerExts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
82
|
+
var ext1 = _step1.value;
|
|
83
|
+
chain.resolve.extensions.prepend(ext1);
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_didIteratorError1 = true;
|
|
87
|
+
_iteratorError1 = err;
|
|
88
|
+
} finally{
|
|
89
|
+
try {
|
|
90
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
91
|
+
_iterator1.return();
|
|
92
|
+
}
|
|
93
|
+
} finally{
|
|
94
|
+
if (_didIteratorError1) {
|
|
95
|
+
throw _iteratorError1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export { applyCallbacks, builderPluginAdapterBasic };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _objectSpread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_defineProperty(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _objectSpreadProps(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import { getEntryOptions } from "@modern-js/utils";
|
|
54
|
+
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
55
|
+
import { BottomTemplatePlugin } from "../bundlerPlugins";
|
|
56
|
+
function isHtmlEnabled(config, target) {
|
|
57
|
+
var _config_tools;
|
|
58
|
+
return ((_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : _config_tools.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
59
|
+
}
|
|
60
|
+
var builderPluginAdapterHtml = function(options) {
|
|
61
|
+
return {
|
|
62
|
+
name: "builder-plugin-adpater-modern-html",
|
|
63
|
+
setup: function setup(api) {
|
|
64
|
+
api.modifyBundlerChain(function(chain, param) {
|
|
65
|
+
var CHAIN_ID = param.CHAIN_ID, target = param.target, HtmlBundlerPlugin = param.HtmlPlugin;
|
|
66
|
+
var builderConfig = api.getNormalizedConfig();
|
|
67
|
+
if (isHtmlEnabled(builderConfig, target)) {
|
|
68
|
+
applyBottomHtmlPlugin({
|
|
69
|
+
api: api,
|
|
70
|
+
options: options,
|
|
71
|
+
chain: chain,
|
|
72
|
+
CHAIN_ID: CHAIN_ID,
|
|
73
|
+
HtmlBundlerPlugin: HtmlBundlerPlugin
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
function applyBottomHtmlPlugin(param) {
|
|
81
|
+
var api = param.api, chain = param.chain, options = param.options, CHAIN_ID = param.CHAIN_ID, HtmlBundlerPlugin = param.HtmlBundlerPlugin;
|
|
82
|
+
var modernConfig = options.normalizedConfig, appContext = options.appContext;
|
|
83
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
84
|
+
try {
|
|
85
|
+
var _loop = function() {
|
|
86
|
+
var entryName = _step.value;
|
|
87
|
+
var baseTemplateParams = _objectSpread({
|
|
88
|
+
entryName: entryName,
|
|
89
|
+
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
90
|
+
mountId: modernConfig.html.mountId
|
|
91
|
+
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
92
|
+
chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function(args) {
|
|
93
|
+
return [
|
|
94
|
+
_objectSpreadProps(_objectSpread({}, args[0] || {}), {
|
|
95
|
+
__internal__: true,
|
|
96
|
+
bottomTemplate: appContext.htmlTemplates["__".concat(entryName, "-bottom__")] && lodashTemplate(appContext.htmlTemplates["__".concat(entryName, "-bottom__")])(baseTemplateParams)
|
|
97
|
+
})
|
|
98
|
+
];
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
for(var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
102
|
+
} catch (err) {
|
|
103
|
+
_didIteratorError = true;
|
|
104
|
+
_iteratorError = err;
|
|
105
|
+
} finally{
|
|
106
|
+
try {
|
|
107
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
108
|
+
_iterator.return();
|
|
109
|
+
}
|
|
110
|
+
} finally{
|
|
111
|
+
if (_didIteratorError) {
|
|
112
|
+
throw _iteratorError;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [
|
|
117
|
+
HtmlBundlerPlugin
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
export { builderPluginAdapterHtml, isHtmlEnabled };
|