@modern-js/app-tools 2.3.1-alpha.2 → 2.5.0-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 +115 -0
- package/README.md +14 -18
- package/dist/cjs/analyze/constants.js +100 -0
- package/dist/cjs/analyze/generateCode.js +251 -0
- package/dist/cjs/analyze/getBundleEntry.js +101 -0
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +225 -0
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +221 -0
- package/dist/cjs/analyze/getClientRoutes/index.js +30 -0
- package/dist/cjs/analyze/getClientRoutes/utils.js +58 -0
- package/dist/cjs/analyze/getFileSystemEntry.js +131 -0
- package/dist/cjs/analyze/getHtmlTemplate.js +124 -0
- package/dist/cjs/analyze/getServerRoutes.js +174 -0
- package/dist/cjs/analyze/index.js +294 -0
- package/dist/cjs/analyze/isDefaultExportFunction.js +71 -0
- package/dist/cjs/analyze/makeLegalIdentifier.js +36 -0
- package/dist/cjs/analyze/nestedRoutes.js +179 -0
- package/dist/cjs/analyze/templates.js +330 -0
- package/dist/cjs/analyze/utils.js +152 -0
- package/dist/cjs/builder/builder-rspack/index.js +31 -0
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/cjs/builder/builder-webpack/index.js +78 -0
- package/dist/cjs/builder/builder-webpack/webpackPlugins/RouterPlugin.js +120 -0
- package/dist/cjs/builder/builder-webpack/webpackPlugins/index.js +17 -0
- package/dist/cjs/builder/generator/createBuilderOptions.js +47 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +49 -0
- package/dist/cjs/builder/generator/getBuilderTargets.js +39 -0
- package/dist/cjs/builder/generator/index.js +58 -0
- package/dist/cjs/builder/index.js +46 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterModern.js +230 -0
- package/dist/{js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js → cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +17 -20
- package/dist/{js/node/builder/webpackPlugins/htmlBottomTemplate.js → cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js} +21 -24
- package/dist/{js/node/builder/share.js → cjs/builder/shared/createCopyPattern.js} +3 -3
- package/dist/cjs/builder/shared/index.js +19 -0
- package/dist/{js/node/builder → cjs/builder/shared}/loaders/serverModuleLoader.js +0 -0
- package/dist/cjs/builder/shared/types.js +15 -0
- package/dist/cjs/commands/build.js +75 -0
- package/dist/cjs/commands/deploy.js +31 -0
- package/dist/cjs/commands/dev.js +91 -0
- package/dist/cjs/commands/index.js +19 -0
- package/dist/cjs/commands/inspect.js +41 -0
- package/dist/cjs/commands/serve.js +63 -0
- package/dist/cjs/config/default.js +186 -0
- package/dist/cjs/config/index.js +19 -0
- package/dist/{js/node/config/initial → cjs/config/initialize}/index.js +10 -16
- package/dist/cjs/config/initialize/inits.js +161 -0
- package/dist/{js/node/config/initial → cjs/config/legacy}/createHtmlConfig.js +0 -0
- package/dist/{js/node/config/initial → cjs/config/legacy}/createOutputConfig.js +0 -0
- package/dist/{js/node/config/initial → cjs/config/legacy}/createSourceConfig.js +0 -0
- package/dist/{js/node/config/initial → cjs/config/legacy}/createToolsConfig.js +0 -0
- package/dist/{js/node/config/initial/transformNormalizedConfig.js → cjs/config/legacy/index.js} +8 -3
- package/dist/cjs/defineConfig.js +33 -0
- package/dist/cjs/exports/server.js +27 -0
- package/dist/cjs/hooks.js +54 -0
- package/dist/cjs/index.js +198 -0
- package/dist/cjs/initialize/index.js +102 -0
- package/dist/cjs/locale/en.js +59 -0
- package/dist/cjs/locale/index.js +33 -0
- package/dist/cjs/locale/zh.js +59 -0
- package/dist/cjs/schema/Schema.js +63 -0
- package/dist/cjs/schema/index.js +118 -0
- package/dist/cjs/schema/legacy.js +169 -0
- package/dist/cjs/types/config/deploy.js +15 -0
- package/dist/cjs/types/config/dev.js +15 -0
- package/dist/cjs/types/config/experiments.js +15 -0
- package/dist/cjs/types/config/html.js +15 -0
- package/dist/cjs/types/config/index.js +17 -0
- package/dist/cjs/types/config/output.js +15 -0
- package/dist/cjs/types/config/performance.js +15 -0
- package/dist/cjs/types/config/security.js +15 -0
- package/dist/cjs/types/config/source.js +15 -0
- package/dist/cjs/types/config/tools.js +15 -0
- package/dist/cjs/types/hooks.js +15 -0
- package/dist/cjs/types/index.js +19 -0
- package/dist/cjs/types/legacyConfig/deploy.js +15 -0
- package/dist/cjs/types/legacyConfig/dev.js +15 -0
- package/dist/cjs/types/legacyConfig/index.js +15 -0
- package/dist/cjs/types/legacyConfig/output.js +15 -0
- package/dist/cjs/types/legacyConfig/source.js +15 -0
- package/dist/cjs/types/legacyConfig/tools.js +15 -0
- package/dist/cjs/types/utils.js +15 -0
- package/dist/cjs/utils/config.js +115 -0
- package/dist/cjs/utils/createServer.js +70 -0
- package/dist/cjs/utils/env.js +38 -0
- package/dist/cjs/utils/generateWatchFiles.js +63 -0
- package/dist/cjs/utils/getSelectedEntries.js +61 -0
- package/dist/cjs/utils/getServerInternalPlugins.js +41 -0
- package/dist/cjs/utils/language.js +31 -0
- package/dist/cjs/utils/printInstructions.js +34 -0
- package/dist/cjs/utils/restart.js +45 -0
- package/dist/cjs/utils/routes.js +39 -0
- package/dist/cjs/utils/types.js +15 -0
- package/dist/esm/analyze/constants.js +42 -0
- package/dist/esm/analyze/generateCode.js +486 -0
- package/dist/esm/analyze/getBundleEntry.js +64 -0
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +233 -0
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
- package/dist/esm/analyze/getClientRoutes/index.js +3 -0
- package/dist/esm/analyze/getClientRoutes/utils.js +23 -0
- package/dist/esm/analyze/getFileSystemEntry.js +107 -0
- package/dist/esm/analyze/getHtmlTemplate.js +302 -0
- package/dist/esm/analyze/getServerRoutes.js +224 -0
- package/dist/esm/analyze/index.js +703 -0
- package/dist/esm/analyze/isDefaultExportFunction.js +47 -0
- package/dist/esm/analyze/makeLegalIdentifier.js +13 -0
- package/dist/esm/analyze/nestedRoutes.js +409 -0
- package/dist/esm/analyze/templates.js +466 -0
- package/dist/esm/analyze/utils.js +374 -0
- package/dist/esm/builder/builder-rspack/index.js +6 -0
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/esm/builder/builder-webpack/index.js +301 -0
- package/dist/esm/builder/builder-webpack/webpackPlugins/RouterPlugin.js +346 -0
- package/dist/esm/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/esm/builder/generator/createBuilderOptions.js +41 -0
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +70 -0
- package/dist/esm/builder/generator/getBuilderTargets.js +16 -0
- package/dist/esm/builder/generator/index.js +199 -0
- package/dist/esm/builder/index.js +175 -0
- package/dist/esm/builder/shared/builderPlugins/adapterModern.js +300 -0
- package/dist/{js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js → esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +72 -0
- package/dist/{js/treeshaking/builder/share.js → esm/builder/shared/createCopyPattern.js} +0 -0
- package/dist/esm/builder/shared/index.js +3 -0
- package/dist/{js/treeshaking/builder → esm/builder/shared}/loaders/serverModuleLoader.js +0 -0
- package/dist/esm/builder/shared/types.js +1 -0
- package/dist/esm/commands/build.js +291 -0
- package/dist/esm/commands/deploy.js +154 -0
- package/dist/esm/commands/dev.js +301 -0
- package/dist/esm/commands/index.js +3 -0
- package/dist/esm/commands/inspect.js +149 -0
- package/dist/esm/commands/serve.js +199 -0
- package/dist/esm/config/default.js +210 -0
- package/dist/esm/config/index.js +3 -0
- package/dist/esm/config/initialize/index.js +10 -0
- package/dist/esm/config/initialize/inits.js +211 -0
- package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
- package/dist/esm/config/legacy/createOutputConfig.js +41 -0
- package/dist/esm/config/legacy/createSourceConfig.js +42 -0
- package/dist/esm/config/legacy/createToolsConfig.js +23 -0
- package/dist/{js/treeshaking/config/initial/transformNormalizedConfig.js → esm/config/legacy/index.js} +4 -1
- package/dist/esm/defineConfig.js +61 -0
- package/dist/esm/exports/server.js +2 -0
- package/dist/esm/hooks.js +29 -0
- package/dist/esm/index.js +713 -0
- package/dist/esm/initialize/index.js +284 -0
- package/dist/esm/locale/en.js +38 -0
- package/dist/esm/locale/index.js +9 -0
- package/dist/esm/locale/zh.js +38 -0
- package/dist/esm/schema/Schema.js +273 -0
- package/dist/esm/schema/index.js +181 -0
- package/dist/esm/schema/legacy.js +337 -0
- package/dist/esm/types/config/deploy.js +1 -0
- package/dist/esm/types/config/dev.js +1 -0
- package/dist/esm/types/config/experiments.js +1 -0
- package/dist/esm/types/config/html.js +1 -0
- package/dist/esm/types/config/index.js +1 -0
- package/dist/esm/types/config/output.js +1 -0
- package/dist/esm/types/config/performance.js +1 -0
- package/dist/esm/types/config/security.js +1 -0
- package/dist/esm/types/config/source.js +1 -0
- package/dist/esm/types/config/tools.js +1 -0
- package/dist/esm/types/hooks.js +1 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/legacyConfig/deploy.js +1 -0
- package/dist/esm/types/legacyConfig/dev.js +1 -0
- package/dist/esm/types/legacyConfig/index.js +1 -0
- package/dist/esm/types/legacyConfig/output.js +1 -0
- package/dist/esm/types/legacyConfig/source.js +1 -0
- package/dist/esm/types/legacyConfig/tools.js +1 -0
- package/dist/esm/types/utils.js +1 -0
- package/dist/esm/utils/config.js +302 -0
- package/dist/esm/utils/createServer.js +258 -0
- package/dist/esm/utils/env.js +13 -0
- package/dist/esm/utils/generateWatchFiles.js +214 -0
- package/dist/esm/utils/getSelectedEntries.js +186 -0
- package/dist/esm/utils/getServerInternalPlugins.js +210 -0
- package/dist/esm/utils/language.js +6 -0
- package/dist/esm/utils/printInstructions.js +152 -0
- package/dist/esm/utils/restart.js +187 -0
- package/dist/esm/utils/routes.js +153 -0
- package/dist/esm/utils/types.js +1 -0
- package/dist/esm-node/analyze/constants.js +56 -0
- package/dist/esm-node/analyze/generateCode.js +227 -0
- package/dist/esm-node/analyze/getBundleEntry.js +77 -0
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +201 -0
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +197 -0
- package/dist/esm-node/analyze/getClientRoutes/index.js +6 -0
- package/dist/esm-node/analyze/getClientRoutes/utils.js +31 -0
- package/dist/esm-node/analyze/getFileSystemEntry.js +109 -0
- package/dist/esm-node/analyze/getHtmlTemplate.js +95 -0
- package/dist/esm-node/analyze/getServerRoutes.js +154 -0
- package/dist/esm-node/analyze/index.js +285 -0
- package/dist/esm-node/analyze/isDefaultExportFunction.js +42 -0
- package/dist/esm-node/analyze/makeLegalIdentifier.js +13 -0
- package/dist/esm-node/analyze/nestedRoutes.js +150 -0
- package/dist/esm-node/analyze/templates.js +297 -0
- package/dist/esm-node/analyze/utils.js +121 -0
- package/dist/esm-node/builder/builder-rspack/index.js +8 -0
- package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
- package/dist/esm-node/builder/builder-webpack/index.js +51 -0
- package/dist/esm-node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +96 -0
- package/dist/esm-node/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/esm-node/builder/generator/createBuilderOptions.js +24 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +26 -0
- package/dist/esm-node/builder/generator/getBuilderTargets.js +21 -0
- package/dist/esm-node/builder/generator/index.js +29 -0
- package/dist/esm-node/builder/index.js +17 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterModern.js +202 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
- package/dist/{js/modern/builder/share.js → esm-node/builder/shared/createCopyPattern.js} +0 -0
- package/dist/esm-node/builder/shared/index.js +3 -0
- package/dist/{js/modern/builder → esm-node/builder/shared}/loaders/serverModuleLoader.js +0 -0
- package/dist/esm-node/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +52 -0
- package/dist/esm-node/commands/deploy.js +8 -0
- package/dist/esm-node/commands/dev.js +72 -0
- package/dist/esm-node/commands/index.js +3 -0
- package/dist/esm-node/commands/inspect.js +18 -0
- package/dist/esm-node/commands/serve.js +34 -0
- package/dist/esm-node/config/default.js +162 -0
- package/dist/esm-node/config/index.js +3 -0
- package/dist/esm-node/config/initialize/index.js +12 -0
- package/dist/esm-node/config/initialize/inits.js +136 -0
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createHtmlConfig.js +0 -0
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createOutputConfig.js +0 -0
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createSourceConfig.js +0 -0
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createToolsConfig.js +0 -0
- package/dist/{js/modern/config/initial/transformNormalizedConfig.js → esm-node/config/legacy/index.js} +4 -0
- package/dist/esm-node/defineConfig.js +9 -0
- package/dist/esm-node/exports/server.js +4 -0
- package/dist/esm-node/hooks.js +35 -0
- package/dist/esm-node/index.js +172 -0
- package/dist/esm-node/initialize/index.js +91 -0
- package/dist/esm-node/locale/en.js +36 -0
- package/dist/esm-node/locale/index.js +9 -0
- package/dist/esm-node/locale/zh.js +36 -0
- package/dist/esm-node/schema/Schema.js +40 -0
- package/dist/esm-node/schema/index.js +88 -0
- package/dist/esm-node/schema/legacy.js +148 -0
- package/dist/esm-node/types/config/deploy.js +0 -0
- package/dist/esm-node/types/config/dev.js +0 -0
- package/dist/esm-node/types/config/experiments.js +0 -0
- package/dist/esm-node/types/config/html.js +0 -0
- package/dist/esm-node/types/config/index.js +1 -0
- package/dist/esm-node/types/config/output.js +0 -0
- package/dist/esm-node/types/config/performance.js +0 -0
- package/dist/esm-node/types/config/security.js +0 -0
- package/dist/esm-node/types/config/source.js +0 -0
- package/dist/esm-node/types/config/tools.js +0 -0
- package/dist/esm-node/types/hooks.js +0 -0
- package/dist/esm-node/types/index.js +3 -0
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
- package/dist/esm-node/types/legacyConfig/dev.js +0 -0
- package/dist/esm-node/types/legacyConfig/index.js +0 -0
- package/dist/esm-node/types/legacyConfig/output.js +0 -0
- package/dist/esm-node/types/legacyConfig/source.js +0 -0
- package/dist/esm-node/types/legacyConfig/tools.js +0 -0
- package/dist/esm-node/types/utils.js +0 -0
- package/dist/esm-node/utils/config.js +88 -0
- package/dist/esm-node/utils/createServer.js +37 -0
- package/dist/esm-node/utils/env.js +15 -0
- package/dist/esm-node/utils/generateWatchFiles.js +33 -0
- package/dist/esm-node/utils/getSelectedEntries.js +38 -0
- package/dist/esm-node/utils/getServerInternalPlugins.js +18 -0
- package/dist/esm-node/utils/language.js +8 -0
- package/dist/esm-node/utils/printInstructions.js +11 -0
- package/dist/esm-node/utils/restart.js +22 -0
- package/dist/esm-node/utils/routes.js +10 -0
- package/dist/esm-node/utils/types.js +0 -0
- package/dist/js/modern/analyze/index.js +45 -48
- package/dist/js/modern/analyze/nestedRoutes.js +1 -10
- package/dist/js/modern/builder/builder-rspack/index.js +8 -0
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
- package/dist/js/modern/builder/builder-webpack/index.js +93 -0
- package/dist/js/modern/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/modern/builder/generator/createBuilderOptions.js +24 -0
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +39 -0
- package/dist/js/modern/builder/generator/getBuilderTargets.js +12 -0
- package/dist/js/modern/builder/generator/index.js +53 -0
- package/dist/js/modern/builder/index.js +13 -133
- package/dist/js/modern/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +81 -111
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
- package/dist/js/modern/builder/shared/createCopyPattern.js +46 -0
- package/dist/js/modern/builder/shared/index.js +3 -0
- package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/config/default.js +2 -2
- package/dist/js/modern/config/index.js +3 -8
- package/dist/js/modern/config/initialize/index.js +12 -0
- package/dist/js/modern/config/{initial → initialize}/inits.js +4 -2
- package/dist/js/modern/config/legacy/createHtmlConfig.js +35 -0
- package/dist/js/modern/config/legacy/createOutputConfig.js +68 -0
- package/dist/js/modern/config/legacy/createSourceConfig.js +39 -0
- package/dist/js/modern/config/legacy/createToolsConfig.js +42 -0
- package/dist/js/modern/config/legacy/index.js +51 -0
- package/dist/js/modern/index.js +18 -8
- package/dist/js/modern/initialize/index.js +36 -28
- package/dist/js/modern/locale/zh.js +1 -1
- package/dist/js/modern/types/utils.js +0 -0
- package/dist/js/node/analyze/index.js +46 -49
- package/dist/js/node/analyze/nestedRoutes.js +1 -10
- package/dist/js/node/builder/builder-rspack/index.js +31 -0
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/node/builder/builder-webpack/index.js +118 -0
- package/dist/js/node/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +7 -5
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +17 -0
- package/dist/js/node/builder/generator/createBuilderOptions.js +47 -0
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +60 -0
- package/dist/js/node/builder/generator/getBuilderTargets.js +35 -0
- package/dist/js/node/builder/generator/index.js +82 -0
- package/dist/js/node/builder/index.js +14 -123
- package/dist/js/node/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +86 -115
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +50 -0
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +57 -0
- package/dist/js/node/builder/shared/createCopyPattern.js +75 -0
- package/dist/js/node/builder/shared/index.js +19 -0
- package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +28 -0
- package/dist/js/node/builder/shared/types.js +15 -0
- package/dist/js/node/config/default.js +2 -2
- package/dist/js/node/config/index.js +4 -19
- package/dist/js/node/config/initialize/index.js +35 -0
- package/dist/js/node/config/{initial → initialize}/inits.js +4 -2
- package/dist/js/node/config/legacy/createHtmlConfig.js +58 -0
- package/dist/js/node/config/legacy/createOutputConfig.js +91 -0
- package/dist/js/node/config/legacy/createSourceConfig.js +62 -0
- package/dist/js/node/config/legacy/createToolsConfig.js +65 -0
- package/dist/js/node/config/legacy/index.js +75 -0
- package/dist/js/node/index.js +18 -8
- package/dist/js/node/initialize/index.js +35 -28
- package/dist/js/node/locale/zh.js +1 -1
- package/dist/js/node/types/utils.js +15 -0
- package/dist/js/treeshaking/analyze/index.js +135 -130
- package/dist/js/treeshaking/analyze/nestedRoutes.js +1 -10
- package/dist/js/treeshaking/builder/builder-rspack/index.js +6 -0
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/treeshaking/builder/builder-webpack/index.js +301 -0
- package/dist/js/treeshaking/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +41 -0
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +70 -0
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +12 -0
- package/dist/js/treeshaking/builder/generator/index.js +199 -0
- package/dist/js/treeshaking/builder/index.js +29 -228
- package/dist/js/treeshaking/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +103 -156
- package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +110 -0
- package/dist/js/treeshaking/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +0 -0
- package/dist/js/treeshaking/builder/shared/createCopyPattern.js +40 -0
- package/dist/js/treeshaking/builder/shared/index.js +3 -0
- package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/shared/types.js +1 -0
- package/dist/js/treeshaking/config/default.js +2 -2
- package/dist/js/treeshaking/config/index.js +3 -3
- package/dist/js/treeshaking/config/initialize/index.js +10 -0
- package/dist/js/treeshaking/config/{initial → initialize}/inits.js +4 -2
- package/dist/js/treeshaking/config/{initial → legacy}/createHtmlConfig.js +0 -0
- package/dist/js/treeshaking/config/{initial → legacy}/createOutputConfig.js +0 -0
- package/dist/js/treeshaking/config/{initial → legacy}/createSourceConfig.js +0 -0
- package/dist/js/treeshaking/config/{initial → legacy}/createToolsConfig.js +0 -0
- package/dist/js/treeshaking/config/legacy/index.js +38 -0
- package/dist/js/treeshaking/index.js +19 -12
- package/dist/js/treeshaking/initialize/index.js +34 -26
- package/dist/js/treeshaking/locale/zh.js +1 -1
- package/dist/js/treeshaking/types/utils.js +1 -0
- package/dist/types/analyze/generateCode.d.ts +1 -1
- package/dist/types/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
- package/dist/types/analyze/getServerRoutes.d.ts +1 -1
- package/dist/types/analyze/index.d.ts +5 -1
- package/dist/types/analyze/templates.d.ts +3 -1
- package/dist/types/builder/builder-rspack/index.d.ts +2 -0
- package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +4 -0
- package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
- package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
- package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
- package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
- package/dist/types/builder/generator/index.d.ts +17 -0
- package/dist/types/builder/index.d.ts +1 -18
- package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
- package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
- package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
- package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
- package/dist/types/builder/shared/index.d.ts +3 -0
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
- package/dist/types/builder/shared/types.d.ts +16 -0
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/commands/deploy.d.ts +1 -1
- package/dist/types/commands/dev.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/commands/serve.d.ts +1 -1
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/index.d.ts +3 -2
- package/dist/types/config/initialize/index.d.ts +2 -0
- package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
- package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
- package/dist/types/config/legacy/index.d.ts +3 -0
- package/dist/types/defineConfig.d.ts +2 -2
- package/dist/types/index.d.ts +7 -3
- package/dist/types/initialize/index.d.ts +6 -2
- package/dist/types/types/config/deploy.d.ts +1 -2
- package/dist/types/types/config/dev.d.ts +2 -3
- package/dist/types/types/config/experiments.d.ts +1 -2
- package/dist/types/types/config/html.d.ts +5 -3
- package/dist/types/types/config/index.d.ts +41 -48
- package/dist/types/types/config/output.d.ts +8 -3
- package/dist/types/types/config/performance.d.ts +6 -3
- package/dist/types/types/config/security.d.ts +3 -3
- package/dist/types/types/config/source.d.ts +7 -3
- package/dist/types/types/config/tools.d.ts +10 -4
- package/dist/types/types/hooks.d.ts +6 -4
- package/dist/types/types/index.d.ts +19 -7
- package/dist/types/types/utils.d.ts +7 -0
- package/dist/types/utils/config.d.ts +1 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
- package/dist/types/utils/printInstructions.d.ts +1 -1
- package/package.json +40 -32
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
- package/dist/js/modern/config/initial/index.js +0 -16
- package/dist/js/treeshaking/config/initial/index.js +0 -12
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
- package/dist/types/config/initial/index.d.ts +0 -4
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
var __async = (__this, __arguments, generator) => {
|
|
21
2
|
return new Promise((resolve, reject) => {
|
|
22
3
|
var fulfilled = (value) => {
|
|
@@ -37,123 +18,22 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
18
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
19
|
});
|
|
39
20
|
};
|
|
40
|
-
|
|
41
|
-
createBuilder
|
|
42
|
-
} from "@modern-js/builder";
|
|
43
|
-
import {
|
|
44
|
-
builderWebpackProvider
|
|
45
|
-
} from "@modern-js/builder-webpack-provider";
|
|
46
|
-
import {
|
|
47
|
-
applyOptionsChain,
|
|
48
|
-
isProd,
|
|
49
|
-
isSSR,
|
|
50
|
-
isUseSSRBundle
|
|
51
|
-
} from "@modern-js/utils";
|
|
52
|
-
import {
|
|
53
|
-
PluginCompatModern
|
|
54
|
-
} from "./builderPlugins/compatModern";
|
|
55
|
-
import { createCopyPattern } from "./share";
|
|
56
|
-
function getBuilderTargets(normalizedConfig) {
|
|
57
|
-
const targets = ["web"];
|
|
58
|
-
const useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
|
|
59
|
-
if (useNodeTarget) {
|
|
60
|
-
targets.push("node");
|
|
61
|
-
}
|
|
62
|
-
return targets;
|
|
63
|
-
}
|
|
64
|
-
function createBuilderForModern(_0) {
|
|
65
|
-
return __async(this, arguments, function* ({
|
|
66
|
-
normalizedConfig,
|
|
67
|
-
appContext,
|
|
68
|
-
compatPluginConfig
|
|
69
|
-
}) {
|
|
70
|
-
const builderConfig = createBuilderProviderConfig(
|
|
71
|
-
normalizedConfig,
|
|
72
|
-
appContext
|
|
73
|
-
);
|
|
74
|
-
const webpackProvider = builderWebpackProvider({
|
|
75
|
-
builderConfig
|
|
76
|
-
});
|
|
77
|
-
const target = getBuilderTargets(normalizedConfig);
|
|
78
|
-
const builderOptions = createBuilderOptions(target, appContext);
|
|
79
|
-
const builder = yield createBuilder(webpackProvider, builderOptions);
|
|
80
|
-
yield applyBuilderPlugins(
|
|
81
|
-
builder,
|
|
82
|
-
normalizedConfig,
|
|
83
|
-
appContext,
|
|
84
|
-
compatPluginConfig
|
|
85
|
-
);
|
|
86
|
-
return builder;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
90
|
-
const output = createOutputConfig(normalizedConfig, appContext);
|
|
91
|
-
const htmlConfig = __spreadValues({}, normalizedConfig.html);
|
|
92
|
-
if (!htmlConfig.template) {
|
|
93
|
-
htmlConfig.templateByEntries = __spreadValues(__spreadValues({}, htmlConfig.templateByEntries), appContext.htmlTemplates);
|
|
94
|
-
}
|
|
95
|
-
return __spreadProps(__spreadValues({}, normalizedConfig), {
|
|
96
|
-
output,
|
|
97
|
-
dev: __spreadProps(__spreadValues({}, normalizedConfig.dev), {
|
|
98
|
-
port: appContext.port
|
|
99
|
-
}),
|
|
100
|
-
html: htmlConfig
|
|
101
|
-
});
|
|
102
|
-
function createOutputConfig(config, appContext2) {
|
|
103
|
-
const defaultCopyPattern = createCopyPattern(appContext2, config, "upload");
|
|
104
|
-
const { copy } = config.output;
|
|
105
|
-
const copyOptions = Array.isArray(copy) ? copy : copy == null ? void 0 : copy.patterns;
|
|
106
|
-
const builderCopy = [...copyOptions || [], defaultCopyPattern];
|
|
107
|
-
return __spreadProps(__spreadValues({}, config.output), {
|
|
108
|
-
copy: builderCopy,
|
|
109
|
-
cleanDistPath: false
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function createBuilderOptions(target, appContext) {
|
|
114
|
-
const entries = {};
|
|
115
|
-
const { entrypoints = [], checkedEntries } = appContext;
|
|
116
|
-
for (const { entryName, entry } of entrypoints) {
|
|
117
|
-
if (checkedEntries && !checkedEntries.includes(entryName)) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
if (entryName in entries) {
|
|
121
|
-
entries[entryName].push(entry);
|
|
122
|
-
} else {
|
|
123
|
-
entries[entryName] = [entry];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
cwd: appContext.appDirectory,
|
|
128
|
-
target,
|
|
129
|
-
configPath: appContext.configFile || void 0,
|
|
130
|
-
entry: entries,
|
|
131
|
-
framework: appContext.metaName
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function applyBuilderPlugins(builder, normalizedConfig, appContext, compatPluginConfig) {
|
|
21
|
+
function createBuilderGenerator(bundler) {
|
|
135
22
|
return __async(this, null, function* () {
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
loader: false,
|
|
146
|
-
minimize: applyOptionsChain({}, esbuildOptions)
|
|
147
|
-
})
|
|
148
|
-
]);
|
|
23
|
+
if (bundler === "rspack") {
|
|
24
|
+
try {
|
|
25
|
+
const { createRspackBuilderForModern } = yield import("./builder-rspack");
|
|
26
|
+
return createRspackBuilderForModern;
|
|
27
|
+
} catch (_) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
"Failed to use rspack, please check if you have `@modern-js/builder-rspack-provider` installed"
|
|
30
|
+
);
|
|
31
|
+
}
|
|
149
32
|
}
|
|
150
|
-
builder
|
|
151
|
-
|
|
152
|
-
]);
|
|
33
|
+
const { createWebpackBuilderForModern } = yield import("./builder-webpack");
|
|
34
|
+
return createWebpackBuilderForModern;
|
|
153
35
|
});
|
|
154
36
|
}
|
|
155
37
|
export {
|
|
156
|
-
|
|
157
|
-
createBuilderOptions,
|
|
158
|
-
createBuilderProviderConfig
|
|
38
|
+
createBuilderGenerator
|
|
159
39
|
};
|
|
@@ -17,22 +17,35 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { join } from "path";
|
|
21
20
|
import {
|
|
22
21
|
mergeBuilderConfig
|
|
23
22
|
} from "@modern-js/builder-shared";
|
|
24
|
-
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
25
|
-
import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
|
|
26
23
|
import { getEntryOptions } from "@modern-js/utils";
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import
|
|
31
|
-
const
|
|
32
|
-
|
|
24
|
+
import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
|
|
25
|
+
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
26
|
+
import { HtmlAsyncChunkPlugin } from "../bundlerPlugins/HtmlAsyncChunkPlugin";
|
|
27
|
+
import { BottomTemplatePlugin } from "../bundlerPlugins/HtmlBottomTemplate";
|
|
28
|
+
const isStreamingSSR = (userConfig) => {
|
|
29
|
+
const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
30
|
+
const { server } = userConfig;
|
|
31
|
+
if (isStreaming(server.ssr)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
35
|
+
for (const name of Object.keys(server.ssrByEntries)) {
|
|
36
|
+
if (isStreaming(server.ssrByEntries[name])) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
};
|
|
43
|
+
const builderPluginAdapterModern = (options) => ({
|
|
44
|
+
name: "builder-plugin-adapter-modern",
|
|
33
45
|
setup(api) {
|
|
46
|
+
const { normalizedConfig, appContext } = options;
|
|
34
47
|
api.modifyBuilderConfig((config) => {
|
|
35
|
-
if (isStreamingSSR(
|
|
48
|
+
if (isStreamingSSR(normalizedConfig)) {
|
|
36
49
|
return mergeBuilderConfig(config, {
|
|
37
50
|
html: {
|
|
38
51
|
inject: "body"
|
|
@@ -41,9 +54,8 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
41
54
|
}
|
|
42
55
|
return config;
|
|
43
56
|
});
|
|
44
|
-
api.
|
|
45
|
-
|
|
46
|
-
const builderNormalizedConfig = api.getNormalizedConfig();
|
|
57
|
+
api.modifyBundlerChain((chain, { target, CHAIN_ID, isProd }) => {
|
|
58
|
+
const builderConfig = api.getNormalizedConfig();
|
|
47
59
|
if (target === "node") {
|
|
48
60
|
chain.name("server");
|
|
49
61
|
} else if (target === "modern-web") {
|
|
@@ -51,61 +63,33 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
51
63
|
} else {
|
|
52
64
|
chain.name("client");
|
|
53
65
|
}
|
|
54
|
-
chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
|
|
55
66
|
if (target === "node") {
|
|
56
|
-
applyNodeCompat(chain,
|
|
67
|
+
applyNodeCompat(chain, normalizedConfig, isProd);
|
|
57
68
|
}
|
|
58
|
-
if (isHtmlEnabled(
|
|
59
|
-
|
|
69
|
+
if (isHtmlEnabled(builderConfig, target)) {
|
|
70
|
+
applyBottomHtmlPlugin({
|
|
60
71
|
api,
|
|
61
72
|
chain,
|
|
62
|
-
|
|
73
|
+
modernConfig: normalizedConfig,
|
|
63
74
|
appContext,
|
|
64
|
-
|
|
75
|
+
CHAIN_ID
|
|
65
76
|
});
|
|
66
77
|
applyAsyncChunkHtmlPlugin({
|
|
67
78
|
chain,
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
modernConfig: normalizedConfig,
|
|
80
|
+
CHAIN_ID
|
|
70
81
|
});
|
|
71
82
|
}
|
|
72
|
-
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
73
|
-
const defaultCopyPattern = createCopyPattern(
|
|
74
|
-
appContext,
|
|
75
|
-
modernConfig,
|
|
76
|
-
"public",
|
|
77
|
-
chain
|
|
78
|
-
);
|
|
79
|
-
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
|
80
|
-
var _a2;
|
|
81
|
-
return [
|
|
82
|
-
{
|
|
83
|
-
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
|
84
|
-
}
|
|
85
|
-
];
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
const { entrypoints } = appContext;
|
|
89
|
-
const existNestedRoutes = entrypoints.some(
|
|
90
|
-
(entrypoint) => entrypoint.nestedRoutesEntry
|
|
91
|
-
);
|
|
92
|
-
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
|
93
|
-
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
|
94
|
-
if (existNestedRoutes || routerManifest) {
|
|
95
|
-
chain.plugin("route-plugin").use(RouterPlugin);
|
|
96
|
-
}
|
|
97
83
|
if (target !== "node") {
|
|
98
84
|
const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
99
85
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
100
86
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
101
87
|
}
|
|
102
|
-
function isHtmlEnabled(config, target2) {
|
|
103
|
-
var _a2;
|
|
104
|
-
return ((_a2 = config.tools) == null ? void 0 : _a2.htmlPlugin) !== false && target2 !== "node" && target2 !== "web-worker";
|
|
105
|
-
}
|
|
106
88
|
});
|
|
107
|
-
|
|
108
|
-
|
|
89
|
+
applyCallbacks(api, options);
|
|
90
|
+
function isHtmlEnabled(config, target) {
|
|
91
|
+
var _a;
|
|
92
|
+
return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "web-worker";
|
|
109
93
|
}
|
|
110
94
|
}
|
|
111
95
|
});
|
|
@@ -119,6 +103,49 @@ function applyCallbacks(api, options) {
|
|
|
119
103
|
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
120
104
|
options.onExit && api.onExit(options.onExit);
|
|
121
105
|
}
|
|
106
|
+
function applyBottomHtmlPlugin({
|
|
107
|
+
api,
|
|
108
|
+
chain,
|
|
109
|
+
modernConfig,
|
|
110
|
+
appContext,
|
|
111
|
+
CHAIN_ID
|
|
112
|
+
}) {
|
|
113
|
+
for (const entryName of Object.keys(api.context.entry)) {
|
|
114
|
+
const baseTemplateParams = __spreadValues({
|
|
115
|
+
entryName,
|
|
116
|
+
title: getEntryOptions(
|
|
117
|
+
entryName,
|
|
118
|
+
modernConfig.html.title,
|
|
119
|
+
modernConfig.html.titleByEntries,
|
|
120
|
+
appContext.packageName
|
|
121
|
+
),
|
|
122
|
+
mountId: modernConfig.html.mountId
|
|
123
|
+
}, getEntryOptions(
|
|
124
|
+
entryName,
|
|
125
|
+
modernConfig.html.templateParameters,
|
|
126
|
+
modernConfig.html.templateParametersByEntries,
|
|
127
|
+
appContext.packageName
|
|
128
|
+
));
|
|
129
|
+
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
|
|
130
|
+
__spreadProps(__spreadValues({}, args[0] || {}), {
|
|
131
|
+
__internal__: true,
|
|
132
|
+
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && lodashTemplate(appContext.htmlTemplates[`__${entryName}-bottom__`])(
|
|
133
|
+
baseTemplateParams
|
|
134
|
+
)
|
|
135
|
+
})
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [HtmlWebpackPlugin]);
|
|
139
|
+
}
|
|
140
|
+
function applyAsyncChunkHtmlPlugin({
|
|
141
|
+
chain,
|
|
142
|
+
modernConfig,
|
|
143
|
+
CHAIN_ID
|
|
144
|
+
}) {
|
|
145
|
+
if (isStreamingSSR(modernConfig)) {
|
|
146
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [HtmlWebpackPlugin]);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
122
149
|
function applyNodeCompat(chain, modernConfig, isProd) {
|
|
123
150
|
for (const ext of [
|
|
124
151
|
".node.js",
|
|
@@ -170,64 +197,7 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
170
197
|
});
|
|
171
198
|
}
|
|
172
199
|
}
|
|
173
|
-
function applyBottomHtmlWebpackPlugin({
|
|
174
|
-
api,
|
|
175
|
-
chain,
|
|
176
|
-
modernConfig,
|
|
177
|
-
appContext,
|
|
178
|
-
CHAIN_ID
|
|
179
|
-
}) {
|
|
180
|
-
for (const entryName of Object.keys(api.context.entry)) {
|
|
181
|
-
const baseTemplateParams = __spreadValues({
|
|
182
|
-
entryName,
|
|
183
|
-
title: getEntryOptions(
|
|
184
|
-
entryName,
|
|
185
|
-
modernConfig.html.title,
|
|
186
|
-
modernConfig.html.titleByEntries,
|
|
187
|
-
appContext.packageName
|
|
188
|
-
),
|
|
189
|
-
mountId: modernConfig.html.mountId
|
|
190
|
-
}, getEntryOptions(
|
|
191
|
-
entryName,
|
|
192
|
-
modernConfig.html.templateParameters,
|
|
193
|
-
modernConfig.html.templateParametersByEntries,
|
|
194
|
-
appContext.packageName
|
|
195
|
-
));
|
|
196
|
-
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
|
|
197
|
-
__spreadProps(__spreadValues({}, args[0] || {}), {
|
|
198
|
-
__internal__: true,
|
|
199
|
-
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && lodashTemplate(appContext.htmlTemplates[`__${entryName}-bottom__`])(
|
|
200
|
-
baseTemplateParams
|
|
201
|
-
)
|
|
202
|
-
})
|
|
203
|
-
]);
|
|
204
|
-
}
|
|
205
|
-
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [HtmlWebpackPlugin]);
|
|
206
|
-
}
|
|
207
|
-
const isStreamingSSR = (userConfig) => {
|
|
208
|
-
const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
209
|
-
const { server } = userConfig;
|
|
210
|
-
if (isStreaming(server.ssr)) {
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
214
|
-
for (const name of Object.keys(server.ssrByEntries)) {
|
|
215
|
-
if (isStreaming(server.ssrByEntries[name])) {
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return false;
|
|
221
|
-
};
|
|
222
|
-
function applyAsyncChunkHtmlPlugin({
|
|
223
|
-
chain,
|
|
224
|
-
modernConfig,
|
|
225
|
-
CHAIN_ID
|
|
226
|
-
}) {
|
|
227
|
-
if (isStreamingSSR(modernConfig)) {
|
|
228
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [HtmlWebpackPlugin]);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
200
|
export {
|
|
232
|
-
|
|
201
|
+
applyCallbacks,
|
|
202
|
+
builderPluginAdapterModern
|
|
233
203
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class HtmlAsyncChunkPlugin {
|
|
2
|
+
constructor(htmlWebpackPlugin) {
|
|
3
|
+
this.name = "HtmlAsyncChunkPlugin";
|
|
4
|
+
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
|
5
|
+
}
|
|
6
|
+
apply(compiler) {
|
|
7
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
8
|
+
const hooks = this.htmlWebpackPlugin.getHooks(compilation);
|
|
9
|
+
hooks.alterAssetTagGroups.tap(this.name, (assets) => {
|
|
10
|
+
const tags = [...assets.headTags, ...assets.bodyTags];
|
|
11
|
+
for (const tag of tags) {
|
|
12
|
+
if (tag.tagName === "script") {
|
|
13
|
+
const { attributes } = tag;
|
|
14
|
+
if (attributes && attributes.defer === true) {
|
|
15
|
+
attributes.async = true;
|
|
16
|
+
delete attributes.defer;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return assets;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
HtmlAsyncChunkPlugin
|
|
27
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class BottomTemplatePlugin {
|
|
2
|
+
constructor(htmlWebpackPlugin) {
|
|
3
|
+
this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
|
|
4
|
+
this.bodyRegExp = /(<\/\s*body\s*>)/i;
|
|
5
|
+
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
|
6
|
+
this.name = "bottom-template";
|
|
7
|
+
}
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
10
|
+
this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(this.name, (data) => {
|
|
11
|
+
var _a;
|
|
12
|
+
if (!((_a = data.plugin.options) == null ? void 0 : _a.__internal__)) {
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
if (this.bottomTemplateReg.test(data.html)) {
|
|
16
|
+
data.html = data.html.replace(this.bottomTemplateReg, "");
|
|
17
|
+
const { bottomTemplate } = data.plugin.options;
|
|
18
|
+
if (bottomTemplate) {
|
|
19
|
+
data.html = data.html.replace(
|
|
20
|
+
this.bodyRegExp,
|
|
21
|
+
(match) => `
|
|
22
|
+
${bottomTemplate}
|
|
23
|
+
${match}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return data;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
BottomTemplatePlugin
|
|
34
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { removeTailSlash } from "@modern-js/utils";
|
|
3
|
+
function createCopyPattern(appContext, config, patternsType, chain) {
|
|
4
|
+
const configDir = path.resolve(
|
|
5
|
+
appContext.appDirectory,
|
|
6
|
+
config.source.configDir || "./config"
|
|
7
|
+
);
|
|
8
|
+
const uploadDir = path.posix.join(configDir.replace(/\\/g, "/"), "upload");
|
|
9
|
+
const publicDir = path.posix.join(configDir.replace(/\\/g, "/"), "public");
|
|
10
|
+
const minifiedJsRexExp = /\.min\.js/;
|
|
11
|
+
const info = (file) => ({
|
|
12
|
+
minimized: minifiedJsRexExp.test(file.sourceFilename)
|
|
13
|
+
});
|
|
14
|
+
if (patternsType === "public") {
|
|
15
|
+
if (!chain) {
|
|
16
|
+
throw new Error("expect get a webpackChain, but receive 'undefined'");
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
info,
|
|
20
|
+
from: "**/*",
|
|
21
|
+
to: "public",
|
|
22
|
+
context: publicDir,
|
|
23
|
+
noErrorOnMissing: true,
|
|
24
|
+
transform: (content, absoluteFrom) => {
|
|
25
|
+
if (!/\.html?$/.test(absoluteFrom)) {
|
|
26
|
+
return content;
|
|
27
|
+
}
|
|
28
|
+
return content.toString("utf8").replace(
|
|
29
|
+
/<%=\s*assetPrefix\s*%>/g,
|
|
30
|
+
removeTailSlash(chain.output.get("publicPath"))
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
} else {
|
|
35
|
+
return {
|
|
36
|
+
info,
|
|
37
|
+
from: "**/*",
|
|
38
|
+
to: "upload",
|
|
39
|
+
context: uploadDir,
|
|
40
|
+
noErrorOnMissing: true
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
createCopyPattern
|
|
46
|
+
};
|
|
File without changes
|
|
@@ -18,12 +18,11 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
|
|
21
|
-
function createDefaultConfig(appContext) {
|
|
21
|
+
function createDefaultConfig(appContext, bundler) {
|
|
22
22
|
const defaultBuilderConfig = createDefaultBuilderConfig();
|
|
23
23
|
const dev = __spreadProps(__spreadValues({}, defaultBuilderConfig.dev), {
|
|
24
24
|
port: void 0
|
|
25
25
|
});
|
|
26
|
-
const tools = __spreadValues({}, defaultBuilderConfig.tools);
|
|
27
26
|
const output = __spreadProps(__spreadValues({}, defaultBuilderConfig.output), {
|
|
28
27
|
disableNodePolyfill: true
|
|
29
28
|
});
|
|
@@ -61,6 +60,7 @@ function createDefaultConfig(appContext) {
|
|
|
61
60
|
baseUrl: "/",
|
|
62
61
|
port: 8080
|
|
63
62
|
};
|
|
63
|
+
const tools = bundler === "webpack" ? __spreadValues({}, defaultBuilderConfig.tools) : void 0;
|
|
64
64
|
return {
|
|
65
65
|
source,
|
|
66
66
|
output,
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
checkIsLegacyConfig,
|
|
5
|
-
createDefaultConfig,
|
|
6
|
-
createLegacyDefaultConfig,
|
|
7
|
-
initialNormalizedConfig
|
|
8
|
-
};
|
|
1
|
+
export * from "./legacy";
|
|
2
|
+
export * from "./initialize";
|
|
3
|
+
export * from "./default";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { initHtmlConfig, initSourceConfig, initToolsConfig } from "./inits";
|
|
2
|
+
function initialNormalizedConfig(config, appContext, bundler) {
|
|
3
|
+
initHtmlConfig(config, appContext);
|
|
4
|
+
initSourceConfig(config, appContext, bundler);
|
|
5
|
+
if (bundler === "webpack") {
|
|
6
|
+
initToolsConfig(config);
|
|
7
|
+
}
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
initialNormalizedConfig
|
|
12
|
+
};
|
|
@@ -59,10 +59,12 @@ function initHtmlConfig(config, appContext) {
|
|
|
59
59
|
return favicon || defaultFavicon || void 0;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function initSourceConfig(config, appContext) {
|
|
62
|
+
function initSourceConfig(config, appContext, bundler) {
|
|
63
63
|
config.source.include = createBuilderInclude(config, appContext);
|
|
64
|
-
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
65
64
|
config.source.globalVars = createBuilderGlobalVars(config, appContext);
|
|
65
|
+
if (bundler === "webpack") {
|
|
66
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
67
|
+
}
|
|
66
68
|
function createBuilderGlobalVars(config2, appContext2) {
|
|
67
69
|
const { globalVars = {} } = config2.source;
|
|
68
70
|
const publicEnv = getAutoInjectEnv(appContext2);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function createHtmlConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
disableHtmlFolder,
|
|
4
|
+
favicon,
|
|
5
|
+
faviconByEntries,
|
|
6
|
+
inject,
|
|
7
|
+
injectByEntries,
|
|
8
|
+
meta,
|
|
9
|
+
metaByEntries,
|
|
10
|
+
mountId,
|
|
11
|
+
title,
|
|
12
|
+
titleByEntries,
|
|
13
|
+
templateParameters,
|
|
14
|
+
templateParametersByEntries,
|
|
15
|
+
crossorigin
|
|
16
|
+
} = config.output;
|
|
17
|
+
return {
|
|
18
|
+
disableHtmlFolder,
|
|
19
|
+
favicon,
|
|
20
|
+
faviconByEntries,
|
|
21
|
+
inject,
|
|
22
|
+
injectByEntries,
|
|
23
|
+
meta,
|
|
24
|
+
metaByEntries,
|
|
25
|
+
mountId,
|
|
26
|
+
title,
|
|
27
|
+
titleByEntries,
|
|
28
|
+
crossorigin,
|
|
29
|
+
templateParameters,
|
|
30
|
+
templateParametersByEntries
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createHtmlConfig
|
|
35
|
+
};
|