@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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function createOutputConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
assetPrefix,
|
|
4
|
+
copy,
|
|
5
|
+
cssModuleLocalIdentName,
|
|
6
|
+
cssPath,
|
|
7
|
+
jsPath,
|
|
8
|
+
htmlPath,
|
|
9
|
+
mediaPath,
|
|
10
|
+
enableTsLoader,
|
|
11
|
+
path,
|
|
12
|
+
disableInlineRuntimeChunk,
|
|
13
|
+
disableCssExtract,
|
|
14
|
+
disableMinimize,
|
|
15
|
+
disableSourceMap,
|
|
16
|
+
disableTsChecker,
|
|
17
|
+
enableCssModuleTSDeclaration,
|
|
18
|
+
enableInlineScripts,
|
|
19
|
+
enableInlineStyles,
|
|
20
|
+
polyfill,
|
|
21
|
+
dataUriLimit,
|
|
22
|
+
disableAssetsCache,
|
|
23
|
+
enableLatestDecorators,
|
|
24
|
+
disableCssModuleExtension,
|
|
25
|
+
ssg,
|
|
26
|
+
disableNodePolyfill
|
|
27
|
+
} = config.output;
|
|
28
|
+
return {
|
|
29
|
+
assetPrefix,
|
|
30
|
+
copy,
|
|
31
|
+
distPath: {
|
|
32
|
+
root: path,
|
|
33
|
+
css: cssPath,
|
|
34
|
+
js: jsPath,
|
|
35
|
+
html: htmlPath,
|
|
36
|
+
svg: mediaPath || "media",
|
|
37
|
+
image: mediaPath || "media",
|
|
38
|
+
font: mediaPath || "media",
|
|
39
|
+
media: mediaPath || "media"
|
|
40
|
+
},
|
|
41
|
+
dataUriLimit: {
|
|
42
|
+
svg: dataUriLimit,
|
|
43
|
+
image: dataUriLimit,
|
|
44
|
+
font: dataUriLimit,
|
|
45
|
+
media: dataUriLimit
|
|
46
|
+
},
|
|
47
|
+
cssModuleLocalIdentName,
|
|
48
|
+
disableCssExtract,
|
|
49
|
+
disableCssModuleExtension,
|
|
50
|
+
disableInlineRuntimeChunk,
|
|
51
|
+
disableMinimize,
|
|
52
|
+
disableSourceMap,
|
|
53
|
+
disableTsChecker: disableTsChecker || enableTsLoader,
|
|
54
|
+
enableCssModuleTSDeclaration,
|
|
55
|
+
enableInlineScripts,
|
|
56
|
+
enableInlineStyles,
|
|
57
|
+
polyfill,
|
|
58
|
+
disableFilenameHash: disableAssetsCache,
|
|
59
|
+
enableLatestDecorators,
|
|
60
|
+
ssg,
|
|
61
|
+
enableAssetFallback: true,
|
|
62
|
+
enableAssetManifest: true,
|
|
63
|
+
disableNodePolyfill
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
createOutputConfig
|
|
68
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function createSourceConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
alias,
|
|
4
|
+
envVars,
|
|
5
|
+
globalVars,
|
|
6
|
+
include,
|
|
7
|
+
moduleScopes,
|
|
8
|
+
preEntry,
|
|
9
|
+
entries,
|
|
10
|
+
enableAsyncEntry,
|
|
11
|
+
disableDefaultEntries,
|
|
12
|
+
entriesDir,
|
|
13
|
+
configDir
|
|
14
|
+
} = config.source;
|
|
15
|
+
const builderGlobalVars = globalVars || {};
|
|
16
|
+
for (const envVar of envVars || []) {
|
|
17
|
+
const envVarValue = process.env[envVar];
|
|
18
|
+
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
alias,
|
|
22
|
+
moduleScopes,
|
|
23
|
+
globalVars: builderGlobalVars,
|
|
24
|
+
include,
|
|
25
|
+
preEntry,
|
|
26
|
+
entries,
|
|
27
|
+
enableAsyncEntry,
|
|
28
|
+
disableDefaultEntries,
|
|
29
|
+
entriesDir,
|
|
30
|
+
configDir,
|
|
31
|
+
resolveExtensionPrefix: {
|
|
32
|
+
web: ".web",
|
|
33
|
+
node: ".node"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
createSourceConfig
|
|
39
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function createToolsConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
autoprefixer,
|
|
4
|
+
babel,
|
|
5
|
+
minifyCss,
|
|
6
|
+
terser,
|
|
7
|
+
webpack,
|
|
8
|
+
webpackChain,
|
|
9
|
+
tsLoader,
|
|
10
|
+
styledComponents,
|
|
11
|
+
sass,
|
|
12
|
+
postcss,
|
|
13
|
+
less,
|
|
14
|
+
htmlPlugin,
|
|
15
|
+
devServer,
|
|
16
|
+
tailwindcss,
|
|
17
|
+
jest,
|
|
18
|
+
esbuild
|
|
19
|
+
} = config.tools;
|
|
20
|
+
const { enableTsLoader } = config.output;
|
|
21
|
+
return {
|
|
22
|
+
tsLoader: enableTsLoader ? tsLoader : void 0,
|
|
23
|
+
autoprefixer,
|
|
24
|
+
babel,
|
|
25
|
+
minifyCss,
|
|
26
|
+
terser,
|
|
27
|
+
webpack,
|
|
28
|
+
webpackChain,
|
|
29
|
+
styledComponents,
|
|
30
|
+
sass,
|
|
31
|
+
postcss,
|
|
32
|
+
less,
|
|
33
|
+
htmlPlugin,
|
|
34
|
+
devServer,
|
|
35
|
+
tailwindcss,
|
|
36
|
+
jest,
|
|
37
|
+
esbuild
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
createToolsConfig
|
|
42
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createToolsConfig } from "./createToolsConfig";
|
|
2
|
+
import { createSourceConfig } from "./createSourceConfig";
|
|
3
|
+
import { createOutputConfig } from "./createOutputConfig";
|
|
4
|
+
import { createHtmlConfig } from "./createHtmlConfig";
|
|
5
|
+
function transformNormalizedConfig(config) {
|
|
6
|
+
const html = createHtmlConfig(config);
|
|
7
|
+
const output = createOutputConfig(config);
|
|
8
|
+
const source = createSourceConfig(config);
|
|
9
|
+
const tools = createToolsConfig(config);
|
|
10
|
+
const {
|
|
11
|
+
bff,
|
|
12
|
+
dev,
|
|
13
|
+
deploy,
|
|
14
|
+
runtime,
|
|
15
|
+
runtimeByEntries,
|
|
16
|
+
server,
|
|
17
|
+
cliOptions,
|
|
18
|
+
plugins,
|
|
19
|
+
testing
|
|
20
|
+
} = config;
|
|
21
|
+
return {
|
|
22
|
+
source,
|
|
23
|
+
html,
|
|
24
|
+
output,
|
|
25
|
+
tools,
|
|
26
|
+
bff,
|
|
27
|
+
dev,
|
|
28
|
+
deploy,
|
|
29
|
+
runtime,
|
|
30
|
+
runtimeByEntries,
|
|
31
|
+
server,
|
|
32
|
+
cliOptions,
|
|
33
|
+
testing,
|
|
34
|
+
builderPlugins: [],
|
|
35
|
+
plugins,
|
|
36
|
+
security: {},
|
|
37
|
+
_raw: {},
|
|
38
|
+
experiments: {},
|
|
39
|
+
autoLoadPlugins: true,
|
|
40
|
+
performance: {
|
|
41
|
+
removeMomentLocale: true
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function checkIsLegacyConfig(config) {
|
|
46
|
+
return Boolean(config.legacy);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
checkIsLegacyConfig,
|
|
50
|
+
transformNormalizedConfig
|
|
51
|
+
};
|
package/dist/js/modern/index.js
CHANGED
|
@@ -103,7 +103,9 @@ const buildCommand = (program, api) => __async(void 0, null, function* () {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
-
var src_default = (
|
|
106
|
+
var src_default = (options = {
|
|
107
|
+
bundler: "webpack"
|
|
108
|
+
}) => ({
|
|
107
109
|
name: "@modern-js/app-tools",
|
|
108
110
|
post: [
|
|
109
111
|
"@modern-js/plugin-initialize",
|
|
@@ -116,7 +118,15 @@ var src_default = () => ({
|
|
|
116
118
|
"@modern-js/plugin-polyfill"
|
|
117
119
|
],
|
|
118
120
|
registerHook: hooks,
|
|
119
|
-
usePlugins: [
|
|
121
|
+
usePlugins: [
|
|
122
|
+
initializePlugin({
|
|
123
|
+
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
124
|
+
}),
|
|
125
|
+
analyzePlugin({
|
|
126
|
+
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
127
|
+
}),
|
|
128
|
+
lintPlugin()
|
|
129
|
+
],
|
|
120
130
|
setup: (api) => {
|
|
121
131
|
const locale = getLocaleLanguage();
|
|
122
132
|
i18n.changeLanguage({ locale });
|
|
@@ -135,19 +145,19 @@ var src_default = () => ({
|
|
|
135
145
|
program.command("deploy").usage("[options]").option(
|
|
136
146
|
"-c --config <config>",
|
|
137
147
|
i18n.t(localeKeys.command.shared.config)
|
|
138
|
-
).description(i18n.t(localeKeys.command.deploy.describe)).action((
|
|
148
|
+
).description(i18n.t(localeKeys.command.deploy.describe)).action((options2) => __async(this, null, function* () {
|
|
139
149
|
const { build } = yield import("./commands/build");
|
|
140
150
|
yield build(api);
|
|
141
151
|
const { deploy } = yield import("./commands/deploy");
|
|
142
|
-
yield deploy(api,
|
|
152
|
+
yield deploy(api, options2);
|
|
143
153
|
process.exit(0);
|
|
144
154
|
}));
|
|
145
155
|
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option(
|
|
146
156
|
"-c, --config <config>",
|
|
147
157
|
i18n.t(localeKeys.command.new.config)
|
|
148
|
-
).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action((
|
|
158
|
+
).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action((options2) => __async(this, null, function* () {
|
|
149
159
|
const { MWANewAction } = yield import("@modern-js/new-action");
|
|
150
|
-
yield MWANewAction(__spreadProps(__spreadValues({},
|
|
160
|
+
yield MWANewAction(__spreadProps(__spreadValues({}, options2), { locale: options2.lang || locale }));
|
|
151
161
|
}));
|
|
152
162
|
program.command("inspect").description("inspect internal webpack config").option(
|
|
153
163
|
`--env <env>`,
|
|
@@ -160,9 +170,9 @@ var src_default = () => ({
|
|
|
160
170
|
).option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option(
|
|
161
171
|
"-c --config <config>",
|
|
162
172
|
i18n.t(localeKeys.command.shared.config)
|
|
163
|
-
).action((
|
|
173
|
+
).action((options2) => __async(this, null, function* () {
|
|
164
174
|
const { inspect } = yield import("./commands/inspect");
|
|
165
|
-
inspect(api,
|
|
175
|
+
inspect(api, options2);
|
|
166
176
|
}));
|
|
167
177
|
upgradeModel.defineCommand(program.command("upgrade"));
|
|
168
178
|
});
|
|
@@ -44,19 +44,21 @@ import {
|
|
|
44
44
|
isDevCommand
|
|
45
45
|
} from "@modern-js/utils";
|
|
46
46
|
import { legacySchema, schema } from "../schema";
|
|
47
|
-
import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
|
|
48
47
|
import {
|
|
49
48
|
checkIsLegacyConfig,
|
|
50
49
|
createDefaultConfig,
|
|
51
|
-
createLegacyDefaultConfig
|
|
50
|
+
createLegacyDefaultConfig,
|
|
51
|
+
transformNormalizedConfig
|
|
52
52
|
} from "../config";
|
|
53
|
-
var initialize_default = (
|
|
53
|
+
var initialize_default = ({
|
|
54
|
+
bundler
|
|
55
|
+
}) => ({
|
|
54
56
|
name: "@modern-js/plugin-initialize",
|
|
55
57
|
setup(api) {
|
|
56
58
|
const config = () => {
|
|
57
59
|
const appContext = api.useAppContext();
|
|
58
60
|
const userConfig = api.useConfigContext();
|
|
59
|
-
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
|
|
61
|
+
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
|
|
60
62
|
};
|
|
61
63
|
const validateSchema = () => {
|
|
62
64
|
const userConfig = api.useConfigContext();
|
|
@@ -81,35 +83,41 @@ var initialize_default = () => ({
|
|
|
81
83
|
});
|
|
82
84
|
api.setAppContext(appContext);
|
|
83
85
|
const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
86
|
+
resolved._raw = userConfig;
|
|
87
|
+
resolved.server = __spreadProps(__spreadValues({}, normalizedConfig.server || {}), {
|
|
88
|
+
port
|
|
89
|
+
});
|
|
90
|
+
resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
|
|
91
|
+
stabilizeConfig(resolved, normalizedConfig, [
|
|
92
|
+
"source",
|
|
93
|
+
"bff",
|
|
94
|
+
"dev",
|
|
95
|
+
"html",
|
|
96
|
+
"output",
|
|
97
|
+
"tools",
|
|
98
|
+
"testing",
|
|
99
|
+
"plugins",
|
|
100
|
+
"builderPlugins",
|
|
101
|
+
"runtime",
|
|
102
|
+
"runtimeByEntries",
|
|
103
|
+
"deploy",
|
|
104
|
+
"performance"
|
|
105
|
+
]);
|
|
106
|
+
if (bundler === "webpack") {
|
|
107
|
+
resolved.security = normalizedConfig.security || {};
|
|
108
|
+
resolved.experiments = normalizedConfig.experiments;
|
|
109
|
+
}
|
|
110
|
+
return { resolved };
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
115
|
});
|
|
116
|
+
function stabilizeConfig(resolve, config, keys) {
|
|
117
|
+
keys.forEach((key) => {
|
|
118
|
+
resolve[key] = config[key] || {};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
113
121
|
function getServerPort(config) {
|
|
114
122
|
return __async(this, null, function* () {
|
|
115
123
|
const prodPort = config.server.port || 8080;
|
|
@@ -17,7 +17,7 @@ const ZH_LOCALE = {
|
|
|
17
17
|
serve: { describe: "应用启动命令" },
|
|
18
18
|
deploy: { describe: "部署应用命令" },
|
|
19
19
|
new: {
|
|
20
|
-
describe: "
|
|
20
|
+
describe: "Web App 项目中执行生成器",
|
|
21
21
|
debug: "开启 Debug 模式,打印调试日志信息",
|
|
22
22
|
config: "生成器运行默认配置(JSON 字符串)",
|
|
23
23
|
distTag: "生成器使用特殊的 npm Tag 版本",
|
|
File without changes
|
|
@@ -66,16 +66,18 @@ module.exports = __toCommonJS(analyze_exports);
|
|
|
66
66
|
var path = __toESM(require("path"));
|
|
67
67
|
var import_utils = require("@modern-js/utils");
|
|
68
68
|
var import_lodash = require("@modern-js/utils/lodash");
|
|
69
|
-
var import_builder = require("../builder");
|
|
70
69
|
var import_printInstructions = require("../utils/printInstructions");
|
|
71
70
|
var import_routes = require("../utils/routes");
|
|
72
71
|
var import_config = require("../utils/config");
|
|
73
72
|
var import_getSelectedEntries = require("../utils/getSelectedEntries");
|
|
74
73
|
var import_config2 = require("../config");
|
|
74
|
+
var import_builder = require("../builder");
|
|
75
75
|
var import_utils2 = require("./utils");
|
|
76
76
|
var import_constants = require("./constants");
|
|
77
77
|
const debug = (0, import_utils.createDebugger)("plugin-analyze");
|
|
78
|
-
var analyze_default = (
|
|
78
|
+
var analyze_default = ({
|
|
79
|
+
bundler
|
|
80
|
+
}) => ({
|
|
79
81
|
name: "@modern-js/plugin-analyze",
|
|
80
82
|
setup: (api) => {
|
|
81
83
|
let pagesDir = [];
|
|
@@ -167,56 +169,51 @@ var analyze_default = () => ({
|
|
|
167
169
|
if (buildCommands.includes(command)) {
|
|
168
170
|
let _b;
|
|
169
171
|
const normalizedConfig = api.useResolvedConfigContext();
|
|
170
|
-
const
|
|
172
|
+
const createBuilderForModern = yield (0, import_builder.createBuilderGenerator)(bundler);
|
|
173
|
+
const builder = yield createBuilderForModern({
|
|
171
174
|
normalizedConfig,
|
|
172
175
|
appContext,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
(0, import_printInstructions.printInstructions)(
|
|
198
|
-
hookRunners2,
|
|
199
|
-
appContext,
|
|
200
|
-
normalizedConfig
|
|
201
|
-
);
|
|
202
|
-
}
|
|
176
|
+
onBeforeBuild(_0) {
|
|
177
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
|
178
|
+
const hookRunners2 = api.useHookRunners();
|
|
179
|
+
yield (0, import_routes.generateRoutes)(appContext);
|
|
180
|
+
yield hookRunners2.beforeBuild({ bundlerConfigs });
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
onAfterBuild(_0) {
|
|
184
|
+
return __async(this, arguments, function* ({ stats }) {
|
|
185
|
+
const hookRunners2 = api.useHookRunners();
|
|
186
|
+
yield hookRunners2.afterBuild({ stats });
|
|
187
|
+
yield (0, import_config.emitResolvedConfig)(
|
|
188
|
+
appContext.appDirectory,
|
|
189
|
+
normalizedConfig
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
onDevCompileDone(_0) {
|
|
194
|
+
return __async(this, arguments, function* ({ isFirstCompile }) {
|
|
195
|
+
const hookRunners2 = api.useHookRunners();
|
|
196
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
197
|
+
hookRunners2.afterDev();
|
|
198
|
+
if (isFirstCompile) {
|
|
199
|
+
(0, import_printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
|
203
200
|
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
onBeforeCreateCompiler(_0) {
|
|
205
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
|
206
|
+
const hookRunners2 = api.useHookRunners();
|
|
207
|
+
yield hookRunners2.beforeCreateCompiler({
|
|
208
|
+
bundlerConfigs
|
|
204
209
|
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
});
|
|
213
|
-
},
|
|
214
|
-
onAfterCreateCompiler(_0) {
|
|
215
|
-
return __async(this, arguments, function* ({ compiler }) {
|
|
216
|
-
const hookRunners2 = api.useHookRunners();
|
|
217
|
-
yield hookRunners2.afterCreateCompiler({ compiler });
|
|
218
|
-
});
|
|
219
|
-
}
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
onAfterCreateCompiler(_0) {
|
|
213
|
+
return __async(this, arguments, function* ({ compiler }) {
|
|
214
|
+
const hookRunners2 = api.useHookRunners();
|
|
215
|
+
yield hookRunners2.afterCreateCompiler({ compiler });
|
|
216
|
+
});
|
|
220
217
|
}
|
|
221
218
|
});
|
|
222
219
|
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
@@ -259,7 +256,7 @@ var analyze_default = () => ({
|
|
|
259
256
|
},
|
|
260
257
|
resolvedConfig({ resolved }) {
|
|
261
258
|
const appContext = api.useAppContext();
|
|
262
|
-
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext);
|
|
259
|
+
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext, bundler);
|
|
263
260
|
return {
|
|
264
261
|
resolved: config
|
|
265
262
|
};
|
|
@@ -183,7 +183,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
183
183
|
route.error = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
const finalRoute = createRoute(
|
|
187
187
|
route,
|
|
188
188
|
rootDir,
|
|
189
189
|
path.join(dirname, `${import_constants.NESTED_ROUTE.LAYOUT_FILE}.ts`),
|
|
@@ -196,15 +196,6 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
196
196
|
if (route.children && route.children.length === 0 && !route.index) {
|
|
197
197
|
return null;
|
|
198
198
|
}
|
|
199
|
-
if (finalRoute.children && finalRoute.children.length === 1 && !finalRoute._component) {
|
|
200
|
-
const childRoute = finalRoute.children[0];
|
|
201
|
-
if (childRoute.path === "*") {
|
|
202
|
-
const path2 = `${finalRoute.path || ""}/${childRoute.path || ""}`;
|
|
203
|
-
finalRoute = __spreadProps(__spreadValues({}, childRoute), {
|
|
204
|
-
path: path2
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
199
|
return finalRoute;
|
|
209
200
|
});
|
|
210
201
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var builder_rspack_exports = {};
|
|
19
|
+
__export(builder_rspack_exports, {
|
|
20
|
+
createRspackBuilderForModern: () => createRspackBuilderForModern
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(builder_rspack_exports);
|
|
23
|
+
var import_builder_rspack_provider = require("@modern-js/builder-rspack-provider");
|
|
24
|
+
var import_generator = require("../generator");
|
|
25
|
+
function createRspackBuilderForModern(options) {
|
|
26
|
+
return (0, import_generator.generateBuilder)(options, import_builder_rspack_provider.builderRspackProvider);
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
createRspackBuilderForModern
|
|
31
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var compatModern_exports = {};
|
|
19
|
+
__export(compatModern_exports, {
|
|
20
|
+
PluginCompatModern: () => PluginCompatModern
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(compatModern_exports);
|
|
23
|
+
var import_path = require("path");
|
|
24
|
+
var import_shared = require("../../shared");
|
|
25
|
+
var import_webpackPlugins = require("../webpackPlugins");
|
|
26
|
+
const PluginCompatModern = (options) => ({
|
|
27
|
+
name: "builder-plugin-compat-modern",
|
|
28
|
+
setup(api) {
|
|
29
|
+
const { normalizedConfig: modernConfig, appContext } = options;
|
|
30
|
+
api.modifyWebpackChain((chain, { CHAIN_ID }) => {
|
|
31
|
+
var _a;
|
|
32
|
+
chain.resolve.modules.add("node_modules").add((0, import_path.join)(api.context.rootPath, "node_modules"));
|
|
33
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
34
|
+
const defaultCopyPattern = (0, import_shared.createCopyPattern)(
|
|
35
|
+
appContext,
|
|
36
|
+
modernConfig,
|
|
37
|
+
"public",
|
|
38
|
+
chain
|
|
39
|
+
);
|
|
40
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
|
41
|
+
var _a2;
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const { entrypoints } = appContext;
|
|
50
|
+
const existNestedRoutes = entrypoints.some(
|
|
51
|
+
(entrypoint) => entrypoint.nestedRoutesEntry
|
|
52
|
+
);
|
|
53
|
+
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
|
54
|
+
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
|
55
|
+
if (existNestedRoutes || routerManifest) {
|
|
56
|
+
chain.plugin("route-plugin").use(import_webpackPlugins.RouterPlugin);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
PluginCompatModern
|
|
64
|
+
});
|