@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,38 @@
|
|
|
1
|
+
import { chalk, inquirer } from "@modern-js/utils";
|
|
2
|
+
import { i18n, localeKeys } from "../locale";
|
|
3
|
+
const getSelectedEntries = async (entry, entrypoints) => {
|
|
4
|
+
const entryNames = entrypoints.map((e) => e.entryName);
|
|
5
|
+
if (!entry) {
|
|
6
|
+
return entryNames;
|
|
7
|
+
}
|
|
8
|
+
if (typeof entry === "boolean") {
|
|
9
|
+
const { selected } = await inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "checkbox",
|
|
12
|
+
name: "selected",
|
|
13
|
+
choices: entryNames,
|
|
14
|
+
message: i18n.t(localeKeys.command.dev.selectEntry),
|
|
15
|
+
validate(answer) {
|
|
16
|
+
if (answer.length < 1) {
|
|
17
|
+
return i18n.t(localeKeys.command.dev.requireEntry);
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]);
|
|
23
|
+
return selected;
|
|
24
|
+
}
|
|
25
|
+
entry.forEach((name) => {
|
|
26
|
+
if (!entryNames.includes(name)) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Can not found entry ${chalk.yellow(
|
|
29
|
+
name
|
|
30
|
+
)}, the entry should be one of ${chalk.yellow(entryNames.join(", "))}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return entry;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
getSelectedEntries
|
|
38
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
async function getServerInternalPlugins(api) {
|
|
2
|
+
const hookRunners = api.useHookRunners();
|
|
3
|
+
const { plugins: serverPlugins } = await hookRunners.collectServerPlugins({
|
|
4
|
+
plugins: []
|
|
5
|
+
});
|
|
6
|
+
const serverInternalPlugins = serverPlugins.reduce(
|
|
7
|
+
(result, plugin) => Object.assign(result, plugin),
|
|
8
|
+
{}
|
|
9
|
+
);
|
|
10
|
+
api.setAppContext({
|
|
11
|
+
...api.useAppContext(),
|
|
12
|
+
serverInternalPlugins
|
|
13
|
+
});
|
|
14
|
+
return serverInternalPlugins;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
getServerInternalPlugins
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { prettyInstructions, logger } from "@modern-js/utils";
|
|
2
|
+
const printInstructions = async (hookRunners, appContext, config) => {
|
|
3
|
+
const message = prettyInstructions(appContext, config);
|
|
4
|
+
const { instructions } = await hookRunners.beforePrintInstructions({
|
|
5
|
+
instructions: message
|
|
6
|
+
});
|
|
7
|
+
logger.info(instructions);
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
printInstructions
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cli } from "@modern-js/core";
|
|
2
|
+
import { chalk, clearConsole, logger, program } from "@modern-js/utils";
|
|
3
|
+
async function restart(hooksRunner, filename) {
|
|
4
|
+
clearConsole();
|
|
5
|
+
logger.info(`Restart because ${chalk.yellow(filename)} is changed...
|
|
6
|
+
`);
|
|
7
|
+
let hasGetError = false;
|
|
8
|
+
await hooksRunner.beforeRestart();
|
|
9
|
+
try {
|
|
10
|
+
await cli.init(cli.getPrevInitOptions());
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error(err);
|
|
13
|
+
hasGetError = true;
|
|
14
|
+
} finally {
|
|
15
|
+
if (!hasGetError) {
|
|
16
|
+
program.parse(process.argv);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
restart
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fs, ROUTE_SPEC_FILE } from "@modern-js/utils";
|
|
3
|
+
const generateRoutes = async (appContext) => {
|
|
4
|
+
const { serverRoutes, distDirectory } = appContext;
|
|
5
|
+
const output = JSON.stringify({ routes: serverRoutes }, null, 2);
|
|
6
|
+
await fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
generateRoutes
|
|
10
|
+
};
|
|
File without changes
|
|
@@ -49,12 +49,12 @@ import {
|
|
|
49
49
|
isDevCommand
|
|
50
50
|
} from "@modern-js/utils";
|
|
51
51
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
52
|
-
import { createBuilderForModern } from "../builder";
|
|
53
52
|
import { printInstructions } from "../utils/printInstructions";
|
|
54
53
|
import { generateRoutes } from "../utils/routes";
|
|
55
54
|
import { emitResolvedConfig } from "../utils/config";
|
|
56
55
|
import { getSelectedEntries } from "../utils/getSelectedEntries";
|
|
57
56
|
import { initialNormalizedConfig } from "../config";
|
|
57
|
+
import { createBuilderGenerator } from "../builder";
|
|
58
58
|
import {
|
|
59
59
|
getServerLoadersFile,
|
|
60
60
|
isPageComponentFile,
|
|
@@ -67,7 +67,9 @@ import {
|
|
|
67
67
|
APP_INIT_IMPORTED
|
|
68
68
|
} from "./constants";
|
|
69
69
|
const debug = createDebugger("plugin-analyze");
|
|
70
|
-
var analyze_default = (
|
|
70
|
+
var analyze_default = ({
|
|
71
|
+
bundler
|
|
72
|
+
}) => ({
|
|
71
73
|
name: "@modern-js/plugin-analyze",
|
|
72
74
|
setup: (api) => {
|
|
73
75
|
let pagesDir = [];
|
|
@@ -159,56 +161,51 @@ var analyze_default = () => ({
|
|
|
159
161
|
if (buildCommands.includes(command)) {
|
|
160
162
|
let _b;
|
|
161
163
|
const normalizedConfig = api.useResolvedConfigContext();
|
|
164
|
+
const createBuilderForModern = yield createBuilderGenerator(bundler);
|
|
162
165
|
const builder = yield createBuilderForModern({
|
|
163
166
|
normalizedConfig,
|
|
164
167
|
appContext,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
printInstructions(
|
|
190
|
-
hookRunners2,
|
|
191
|
-
appContext,
|
|
192
|
-
normalizedConfig
|
|
193
|
-
);
|
|
194
|
-
}
|
|
168
|
+
onBeforeBuild(_0) {
|
|
169
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
|
170
|
+
const hookRunners2 = api.useHookRunners();
|
|
171
|
+
yield generateRoutes(appContext);
|
|
172
|
+
yield hookRunners2.beforeBuild({ bundlerConfigs });
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
onAfterBuild(_0) {
|
|
176
|
+
return __async(this, arguments, function* ({ stats }) {
|
|
177
|
+
const hookRunners2 = api.useHookRunners();
|
|
178
|
+
yield hookRunners2.afterBuild({ stats });
|
|
179
|
+
yield emitResolvedConfig(
|
|
180
|
+
appContext.appDirectory,
|
|
181
|
+
normalizedConfig
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
onDevCompileDone(_0) {
|
|
186
|
+
return __async(this, arguments, function* ({ isFirstCompile }) {
|
|
187
|
+
const hookRunners2 = api.useHookRunners();
|
|
188
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
189
|
+
hookRunners2.afterDev();
|
|
190
|
+
if (isFirstCompile) {
|
|
191
|
+
printInstructions(hookRunners2, appContext, normalizedConfig);
|
|
195
192
|
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
onBeforeCreateCompiler(_0) {
|
|
197
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
|
198
|
+
const hookRunners2 = api.useHookRunners();
|
|
199
|
+
yield hookRunners2.beforeCreateCompiler({
|
|
200
|
+
bundlerConfigs
|
|
196
201
|
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
onAfterCreateCompiler(_0) {
|
|
207
|
-
return __async(this, arguments, function* ({ compiler }) {
|
|
208
|
-
const hookRunners2 = api.useHookRunners();
|
|
209
|
-
yield hookRunners2.afterCreateCompiler({ compiler });
|
|
210
|
-
});
|
|
211
|
-
}
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
onAfterCreateCompiler(_0) {
|
|
205
|
+
return __async(this, arguments, function* ({ compiler }) {
|
|
206
|
+
const hookRunners2 = api.useHookRunners();
|
|
207
|
+
yield hookRunners2.afterCreateCompiler({ compiler });
|
|
208
|
+
});
|
|
212
209
|
}
|
|
213
210
|
});
|
|
214
211
|
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
@@ -251,7 +248,7 @@ var analyze_default = () => ({
|
|
|
251
248
|
},
|
|
252
249
|
resolvedConfig({ resolved }) {
|
|
253
250
|
const appContext = api.useAppContext();
|
|
254
|
-
const config = initialNormalizedConfig(resolved, appContext);
|
|
251
|
+
const config = initialNormalizedConfig(resolved, appContext, bundler);
|
|
255
252
|
return {
|
|
256
253
|
resolved: config
|
|
257
254
|
};
|
|
@@ -157,7 +157,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
157
157
|
route.error = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
const finalRoute = createRoute(
|
|
161
161
|
route,
|
|
162
162
|
rootDir,
|
|
163
163
|
path.join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`),
|
|
@@ -170,15 +170,6 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
170
170
|
if (route.children && route.children.length === 0 && !route.index) {
|
|
171
171
|
return null;
|
|
172
172
|
}
|
|
173
|
-
if (finalRoute.children && finalRoute.children.length === 1 && !finalRoute._component) {
|
|
174
|
-
const childRoute = finalRoute.children[0];
|
|
175
|
-
if (childRoute.path === "*") {
|
|
176
|
-
const path2 = `${finalRoute.path || ""}/${childRoute.path || ""}`;
|
|
177
|
-
finalRoute = __spreadProps(__spreadValues({}, childRoute), {
|
|
178
|
-
path: path2
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
173
|
return finalRoute;
|
|
183
174
|
});
|
|
184
175
|
export {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
|
|
2
|
+
import { generateBuilder } from "../generator";
|
|
3
|
+
function createRspackBuilderForModern(options) {
|
|
4
|
+
return generateBuilder(options, builderRspackProvider);
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
createRspackBuilderForModern
|
|
8
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { createCopyPattern } from "../../shared";
|
|
3
|
+
import { RouterPlugin } from "../webpackPlugins";
|
|
4
|
+
const PluginCompatModern = (options) => ({
|
|
5
|
+
name: "builder-plugin-compat-modern",
|
|
6
|
+
setup(api) {
|
|
7
|
+
const { normalizedConfig: modernConfig, appContext } = options;
|
|
8
|
+
api.modifyWebpackChain((chain, { CHAIN_ID }) => {
|
|
9
|
+
var _a;
|
|
10
|
+
chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
|
|
11
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
12
|
+
const defaultCopyPattern = createCopyPattern(
|
|
13
|
+
appContext,
|
|
14
|
+
modernConfig,
|
|
15
|
+
"public",
|
|
16
|
+
chain
|
|
17
|
+
);
|
|
18
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
|
19
|
+
var _a2;
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const { entrypoints } = appContext;
|
|
28
|
+
const existNestedRoutes = entrypoints.some(
|
|
29
|
+
(entrypoint) => entrypoint.nestedRoutesEntry
|
|
30
|
+
);
|
|
31
|
+
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
|
32
|
+
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
|
33
|
+
if (existNestedRoutes || routerManifest) {
|
|
34
|
+
chain.plugin("route-plugin").use(RouterPlugin);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
PluginCompatModern
|
|
41
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import {
|
|
41
|
+
builderWebpackProvider
|
|
42
|
+
} from "@modern-js/builder-webpack-provider";
|
|
43
|
+
import { applyOptionsChain } from "@modern-js/utils";
|
|
44
|
+
import { createCopyPattern } from "../shared";
|
|
45
|
+
import { generateBuilder } from "../generator";
|
|
46
|
+
import { PluginCompatModern } from "./builderPlugins/compatModern";
|
|
47
|
+
function createWebpackBuilderForModern(options) {
|
|
48
|
+
return generateBuilder(options, builderWebpackProvider, {
|
|
49
|
+
modifyBuilderConfig(config) {
|
|
50
|
+
modifyOutputConfig(config, options.appContext);
|
|
51
|
+
},
|
|
52
|
+
modifyBuilderInstance(builder) {
|
|
53
|
+
return __async(this, null, function* () {
|
|
54
|
+
yield applyBuilderPlugins(builder, options);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function modifyOutputConfig(config, appContext) {
|
|
60
|
+
config.output = createOutputConfig(config, appContext);
|
|
61
|
+
function createOutputConfig(config2, appContext2) {
|
|
62
|
+
const defaultCopyPattern = createCopyPattern(appContext2, config2, "upload");
|
|
63
|
+
const { copy } = config2.output;
|
|
64
|
+
const copyOptions = Array.isArray(copy) ? copy : copy == null ? void 0 : copy.patterns;
|
|
65
|
+
const builderCopy = [...copyOptions || [], defaultCopyPattern];
|
|
66
|
+
return __spreadProps(__spreadValues({}, config2.output), {
|
|
67
|
+
copy: builderCopy
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function applyBuilderPlugins(builder, options) {
|
|
72
|
+
return __async(this, null, function* () {
|
|
73
|
+
const { normalizedConfig } = options;
|
|
74
|
+
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
75
|
+
const { PluginNodePolyfill } = yield import("@modern-js/builder-plugin-node-polyfill");
|
|
76
|
+
builder.addPlugins([PluginNodePolyfill()]);
|
|
77
|
+
}
|
|
78
|
+
if (normalizedConfig.tools.esbuild) {
|
|
79
|
+
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
|
80
|
+
const { PluginEsbuild } = yield import("@modern-js/builder-plugin-esbuild");
|
|
81
|
+
builder.addPlugins([
|
|
82
|
+
PluginEsbuild({
|
|
83
|
+
loader: false,
|
|
84
|
+
minimize: applyOptionsChain({}, esbuildOptions)
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
builder.addPlugins([PluginCompatModern(options)]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
createWebpackBuilderForModern
|
|
93
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RouterPlugin";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function createBuilderOptions(target, appContext) {
|
|
2
|
+
const entries = {};
|
|
3
|
+
const { entrypoints = [], checkedEntries } = appContext;
|
|
4
|
+
for (const { entryName, entry } of entrypoints) {
|
|
5
|
+
if (checkedEntries && !checkedEntries.includes(entryName)) {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
if (entryName in entries) {
|
|
9
|
+
entries[entryName].push(entry);
|
|
10
|
+
} else {
|
|
11
|
+
entries[entryName] = [entry];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
cwd: appContext.appDirectory,
|
|
16
|
+
target,
|
|
17
|
+
configPath: appContext.configFile || void 0,
|
|
18
|
+
entry: entries,
|
|
19
|
+
framework: appContext.metaName
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
createBuilderOptions
|
|
24
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderConfig) {
|
|
21
|
+
const htmlConfig = __spreadValues({}, resolveConfig.html);
|
|
22
|
+
if (!htmlConfig.template) {
|
|
23
|
+
htmlConfig.templateByEntries = __spreadValues(__spreadValues({}, htmlConfig.templateByEntries), appContext.htmlTemplates);
|
|
24
|
+
}
|
|
25
|
+
const config = __spreadProps(__spreadValues({}, resolveConfig), {
|
|
26
|
+
dev: __spreadProps(__spreadValues({}, resolveConfig.dev), {
|
|
27
|
+
port: appContext.port
|
|
28
|
+
}),
|
|
29
|
+
html: htmlConfig,
|
|
30
|
+
output: __spreadProps(__spreadValues({}, resolveConfig.output), {
|
|
31
|
+
cleanDistPath: false
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
modifyBuilderConfig == null ? void 0 : modifyBuilderConfig(config);
|
|
35
|
+
return config;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
createBuilderProviderConfig
|
|
39
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isProd, isSSR, isUseSSRBundle } from "@modern-js/utils";
|
|
2
|
+
function getBuilderTargets(normalizedConfig) {
|
|
3
|
+
const targets = ["web"];
|
|
4
|
+
const useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
|
|
5
|
+
if (useNodeTarget) {
|
|
6
|
+
targets.push("node");
|
|
7
|
+
}
|
|
8
|
+
return targets;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
getBuilderTargets
|
|
12
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { createBuilder } from "@modern-js/builder";
|
|
22
|
+
import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
|
|
23
|
+
import { getBuilderTargets } from "./getBuilderTargets";
|
|
24
|
+
import { createBuilderOptions } from "./createBuilderOptions";
|
|
25
|
+
function generateBuilder(options, generateProvider, utils) {
|
|
26
|
+
return __async(this, null, function* () {
|
|
27
|
+
const { normalizedConfig, appContext } = options;
|
|
28
|
+
const { modifyBuilderConfig, modifyBuilderInstance } = utils || {};
|
|
29
|
+
const builderConfig = createBuilderProviderConfig(
|
|
30
|
+
normalizedConfig,
|
|
31
|
+
appContext,
|
|
32
|
+
modifyBuilderConfig
|
|
33
|
+
);
|
|
34
|
+
const provider = generateProvider({
|
|
35
|
+
builderConfig
|
|
36
|
+
});
|
|
37
|
+
const target = getBuilderTargets(normalizedConfig);
|
|
38
|
+
const builderOptions = createBuilderOptions(target, appContext);
|
|
39
|
+
const builder = yield createBuilder(provider, builderOptions);
|
|
40
|
+
yield applyBuilderPlugins(builder, options);
|
|
41
|
+
yield modifyBuilderInstance == null ? void 0 : modifyBuilderInstance(builder);
|
|
42
|
+
return builder;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function applyBuilderPlugins(builder, options) {
|
|
46
|
+
return __async(this, null, function* () {
|
|
47
|
+
const { builderPluginAdapterModern } = yield import("../shared/builderPlugins/adapterModern");
|
|
48
|
+
builder.addPlugins([builderPluginAdapterModern(options)]);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
generateBuilder
|
|
53
|
+
};
|