@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,230 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var adapterModern_exports = {};
|
|
25
|
+
__export(adapterModern_exports, {
|
|
26
|
+
applyCallbacks: () => applyCallbacks,
|
|
27
|
+
builderPluginAdapterModern: () => builderPluginAdapterModern
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(adapterModern_exports);
|
|
30
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
31
|
+
var import_utils = require("@modern-js/utils");
|
|
32
|
+
var import_html_webpack_plugin = __toESM(require("@modern-js/builder-webpack-provider/html-webpack-plugin"));
|
|
33
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
|
34
|
+
var import_HtmlAsyncChunkPlugin = require("../bundlerPlugins/HtmlAsyncChunkPlugin");
|
|
35
|
+
var import_HtmlBottomTemplate = require("../bundlerPlugins/HtmlBottomTemplate");
|
|
36
|
+
const isStreamingSSR = (userConfig) => {
|
|
37
|
+
const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
38
|
+
const { server } = userConfig;
|
|
39
|
+
if (isStreaming(server.ssr)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
43
|
+
for (const name of Object.keys(server.ssrByEntries)) {
|
|
44
|
+
if (isStreaming(server.ssrByEntries[name])) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
const builderPluginAdapterModern = (options) => ({
|
|
52
|
+
name: "builder-plugin-adapter-modern",
|
|
53
|
+
setup(api) {
|
|
54
|
+
const { normalizedConfig, appContext } = options;
|
|
55
|
+
api.modifyBuilderConfig((config) => {
|
|
56
|
+
if (isStreamingSSR(normalizedConfig)) {
|
|
57
|
+
return (0, import_builder_shared.mergeBuilderConfig)(config, {
|
|
58
|
+
html: {
|
|
59
|
+
inject: "body"
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return config;
|
|
64
|
+
});
|
|
65
|
+
api.modifyBundlerChain((chain, { target, CHAIN_ID, isProd }) => {
|
|
66
|
+
const builderConfig = api.getNormalizedConfig();
|
|
67
|
+
if (target === "node") {
|
|
68
|
+
chain.name("server");
|
|
69
|
+
} else if (target === "service-worker") {
|
|
70
|
+
chain.name("service-worker");
|
|
71
|
+
} else if (target === "web-worker") {
|
|
72
|
+
chain.name("worker");
|
|
73
|
+
} else if (target === "modern-web") {
|
|
74
|
+
chain.name("modern");
|
|
75
|
+
} else {
|
|
76
|
+
chain.name("client");
|
|
77
|
+
}
|
|
78
|
+
if (target === "node" || target === "service-worker") {
|
|
79
|
+
applyNodeCompat(target, chain, normalizedConfig, isProd);
|
|
80
|
+
}
|
|
81
|
+
if (isHtmlEnabled(builderConfig, target)) {
|
|
82
|
+
applyBottomHtmlPlugin({
|
|
83
|
+
api,
|
|
84
|
+
chain,
|
|
85
|
+
modernConfig: normalizedConfig,
|
|
86
|
+
appContext,
|
|
87
|
+
CHAIN_ID
|
|
88
|
+
});
|
|
89
|
+
applyAsyncChunkHtmlPlugin({
|
|
90
|
+
chain,
|
|
91
|
+
modernConfig: normalizedConfig,
|
|
92
|
+
CHAIN_ID
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (target !== "node" && target !== "web-worker" && target !== "service-worker") {
|
|
96
|
+
const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
97
|
+
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
98
|
+
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
applyCallbacks(api, options);
|
|
102
|
+
function isHtmlEnabled(config, target) {
|
|
103
|
+
var _a;
|
|
104
|
+
return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
function applyCallbacks(api, options) {
|
|
109
|
+
options.onAfterBuild && api.onAfterBuild(options.onAfterBuild);
|
|
110
|
+
options.onAfterCreateCompiler && api.onAfterCreateCompiler(options.onAfterCreateCompiler);
|
|
111
|
+
options.onAfterStartDevServer && api.onAfterStartDevServer(options.onAfterStartDevServer);
|
|
112
|
+
options.onBeforeBuild && api.onBeforeBuild(options.onBeforeBuild);
|
|
113
|
+
options.onBeforeCreateCompiler && api.onBeforeCreateCompiler(options.onBeforeCreateCompiler);
|
|
114
|
+
options.onBeforeStartDevServer && api.onBeforeStartDevServer(options.onBeforeStartDevServer);
|
|
115
|
+
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
116
|
+
options.onExit && api.onExit(options.onExit);
|
|
117
|
+
}
|
|
118
|
+
function applyBottomHtmlPlugin({
|
|
119
|
+
api,
|
|
120
|
+
chain,
|
|
121
|
+
modernConfig,
|
|
122
|
+
appContext,
|
|
123
|
+
CHAIN_ID
|
|
124
|
+
}) {
|
|
125
|
+
for (const entryName of Object.keys(api.context.entry)) {
|
|
126
|
+
const baseTemplateParams = {
|
|
127
|
+
entryName,
|
|
128
|
+
title: (0, import_utils.getEntryOptions)(
|
|
129
|
+
entryName,
|
|
130
|
+
modernConfig.html.title,
|
|
131
|
+
modernConfig.html.titleByEntries,
|
|
132
|
+
appContext.packageName
|
|
133
|
+
),
|
|
134
|
+
mountId: modernConfig.html.mountId,
|
|
135
|
+
...(0, import_utils.getEntryOptions)(
|
|
136
|
+
entryName,
|
|
137
|
+
modernConfig.html.templateParameters,
|
|
138
|
+
modernConfig.html.templateParametersByEntries,
|
|
139
|
+
appContext.packageName
|
|
140
|
+
)
|
|
141
|
+
};
|
|
142
|
+
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
|
|
143
|
+
{
|
|
144
|
+
...args[0] || {},
|
|
145
|
+
__internal__: true,
|
|
146
|
+
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && (0, import_lodash.template)(appContext.htmlTemplates[`__${entryName}-bottom__`])(
|
|
147
|
+
baseTemplateParams
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(import_HtmlBottomTemplate.BottomTemplatePlugin, [import_html_webpack_plugin.default]);
|
|
153
|
+
}
|
|
154
|
+
function applyAsyncChunkHtmlPlugin({
|
|
155
|
+
chain,
|
|
156
|
+
modernConfig,
|
|
157
|
+
CHAIN_ID
|
|
158
|
+
}) {
|
|
159
|
+
if (isStreamingSSR(modernConfig)) {
|
|
160
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_HtmlAsyncChunkPlugin.HtmlAsyncChunkPlugin, [import_html_webpack_plugin.default]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
164
|
+
const nodeExts = [
|
|
165
|
+
".node.js",
|
|
166
|
+
".node.jsx",
|
|
167
|
+
".node.ts",
|
|
168
|
+
".node.tsx",
|
|
169
|
+
".server.js",
|
|
170
|
+
".server.ts",
|
|
171
|
+
".server.ts",
|
|
172
|
+
".server.tsx"
|
|
173
|
+
];
|
|
174
|
+
const webWorkerExts = [
|
|
175
|
+
".worker.js",
|
|
176
|
+
".worker.jsx",
|
|
177
|
+
".worker.ts",
|
|
178
|
+
".worker.tsx"
|
|
179
|
+
];
|
|
180
|
+
for (const ext of nodeExts) {
|
|
181
|
+
chain.resolve.extensions.prepend(ext);
|
|
182
|
+
}
|
|
183
|
+
if (target === "service-worker") {
|
|
184
|
+
for (const ext of webWorkerExts) {
|
|
185
|
+
chain.resolve.extensions.prepend(ext);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
filterEntriesBySSRConfig(
|
|
189
|
+
isProd,
|
|
190
|
+
chain,
|
|
191
|
+
modernConfig.server,
|
|
192
|
+
modernConfig.output
|
|
193
|
+
);
|
|
194
|
+
function filterEntriesBySSRConfig(isProd2, chain2, serverConfig, outputConfig) {
|
|
195
|
+
var _a;
|
|
196
|
+
const entries = chain2.entryPoints.entries();
|
|
197
|
+
if (isProd2 && ((outputConfig == null ? void 0 : outputConfig.ssg) === true || typeof ((_a = outputConfig == null ? void 0 : outputConfig.ssg) == null ? void 0 : _a[0]) === "function")) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (typeof entries === "undefined") {
|
|
201
|
+
throw new Error(
|
|
202
|
+
"No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required"
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const entryNames = Object.keys(entries);
|
|
206
|
+
if (isProd2 && entryNames.length === 1 && (outputConfig == null ? void 0 : outputConfig.ssg)) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const ssgEntries = [];
|
|
210
|
+
if (isProd2 && (outputConfig == null ? void 0 : outputConfig.ssg)) {
|
|
211
|
+
const { ssg } = outputConfig;
|
|
212
|
+
entryNames.forEach((name) => {
|
|
213
|
+
if (ssg[name]) {
|
|
214
|
+
ssgEntries.push(name);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
const { ssr, ssrByEntries } = serverConfig || {};
|
|
219
|
+
entryNames.forEach((name) => {
|
|
220
|
+
if (!ssgEntries.includes(name) && (ssr && (ssrByEntries == null ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries == null ? void 0 : ssrByEntries[name]))) {
|
|
221
|
+
chain2.entryPoints.delete(name);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
227
|
+
0 && (module.exports = {
|
|
228
|
+
applyCallbacks,
|
|
229
|
+
builderPluginAdapterModern
|
|
230
|
+
});
|
|
@@ -15,36 +15,33 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var HtmlAsyncChunkPlugin_exports = {};
|
|
19
|
+
__export(HtmlAsyncChunkPlugin_exports, {
|
|
20
20
|
HtmlAsyncChunkPlugin: () => HtmlAsyncChunkPlugin
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(HtmlAsyncChunkPlugin_exports);
|
|
23
23
|
class HtmlAsyncChunkPlugin {
|
|
24
24
|
constructor(htmlWebpackPlugin) {
|
|
25
25
|
this.name = "HtmlAsyncChunkPlugin";
|
|
26
26
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
|
27
27
|
}
|
|
28
28
|
apply(compiler) {
|
|
29
|
-
compiler.hooks.compilation.tap(
|
|
30
|
-
this.
|
|
31
|
-
(
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
attributes.async = true;
|
|
40
|
-
delete attributes.defer;
|
|
41
|
-
}
|
|
29
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
30
|
+
const hooks = this.htmlWebpackPlugin.getHooks(compilation);
|
|
31
|
+
hooks.alterAssetTagGroups.tap(this.name, (assets) => {
|
|
32
|
+
const tags = [...assets.headTags, ...assets.bodyTags];
|
|
33
|
+
for (const tag of tags) {
|
|
34
|
+
if (tag.tagName === "script") {
|
|
35
|
+
const { attributes } = tag;
|
|
36
|
+
if (attributes && attributes.defer === true) {
|
|
37
|
+
attributes.async = true;
|
|
38
|
+
delete attributes.defer;
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
);
|
|
41
|
+
}
|
|
42
|
+
return assets;
|
|
43
|
+
});
|
|
44
|
+
});
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var HtmlBottomTemplate_exports = {};
|
|
19
|
+
__export(HtmlBottomTemplate_exports, {
|
|
20
20
|
BottomTemplatePlugin: () => BottomTemplatePlugin
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(HtmlBottomTemplate_exports);
|
|
23
23
|
class BottomTemplatePlugin {
|
|
24
24
|
constructor(htmlWebpackPlugin) {
|
|
25
25
|
this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
|
|
@@ -28,30 +28,27 @@ class BottomTemplatePlugin {
|
|
|
28
28
|
this.name = "bottom-template";
|
|
29
29
|
}
|
|
30
30
|
apply(compiler) {
|
|
31
|
-
compiler.hooks.compilation.tap(
|
|
32
|
-
this.name,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.bodyRegExp,
|
|
45
|
-
(match) => `
|
|
31
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
32
|
+
this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(this.name, (data) => {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!((_a = data.plugin.options) == null ? void 0 : _a.__internal__)) {
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
if (this.bottomTemplateReg.test(data.html)) {
|
|
38
|
+
data.html = data.html.replace(this.bottomTemplateReg, "");
|
|
39
|
+
const { bottomTemplate } = data.plugin.options;
|
|
40
|
+
if (bottomTemplate) {
|
|
41
|
+
data.html = data.html.replace(
|
|
42
|
+
this.bodyRegExp,
|
|
43
|
+
(match) => `
|
|
46
44
|
${bottomTemplate}
|
|
47
45
|
${match}`
|
|
48
|
-
|
|
49
|
-
}
|
|
46
|
+
);
|
|
50
47
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
);
|
|
48
|
+
}
|
|
49
|
+
return data;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -21,11 +21,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
mod
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var
|
|
25
|
-
__export(
|
|
24
|
+
var createCopyPattern_exports = {};
|
|
25
|
+
__export(createCopyPattern_exports, {
|
|
26
26
|
createCopyPattern: () => createCopyPattern
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(createCopyPattern_exports);
|
|
29
29
|
var import_path = __toESM(require("path"));
|
|
30
30
|
var import_utils = require("@modern-js/utils");
|
|
31
31
|
function createCopyPattern(appContext, config, patternsType, chain) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var shared_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(shared_exports);
|
|
17
|
+
__reExport(shared_exports, require("./createCopyPattern"), module.exports);
|
|
18
|
+
__reExport(shared_exports, require("./types"), module.exports);
|
|
19
|
+
__reExport(shared_exports, require("./builderPlugins/adapterModern"), module.exports);
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,75 @@
|
|
|
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 build_exports = {};
|
|
19
|
+
__export(build_exports, {
|
|
20
|
+
build: () => build
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(build_exports);
|
|
23
|
+
var import_core = require("@modern-js/core");
|
|
24
|
+
var import_utils = require("@modern-js/utils");
|
|
25
|
+
var import_routes = require("../utils/routes");
|
|
26
|
+
var import_config = require("../utils/config");
|
|
27
|
+
const build = async (api, options) => {
|
|
28
|
+
if (options == null ? void 0 : options.analyze) {
|
|
29
|
+
process.env.BUNDLE_ANALYZE = "true";
|
|
30
|
+
}
|
|
31
|
+
let resolvedConfig = api.useResolvedConfigContext();
|
|
32
|
+
const appContext = api.useAppContext();
|
|
33
|
+
const hookRunners = api.useHookRunners();
|
|
34
|
+
const { apiOnly } = appContext;
|
|
35
|
+
if (apiOnly) {
|
|
36
|
+
const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
|
|
37
|
+
await hookRunners.beforeBuild({
|
|
38
|
+
bundlerConfigs: void 0
|
|
39
|
+
});
|
|
40
|
+
await (0, import_config.buildServerConfig)({
|
|
41
|
+
appDirectory: appDirectory2,
|
|
42
|
+
distDirectory: distDirectory2,
|
|
43
|
+
configFile: serverConfigFile2
|
|
44
|
+
});
|
|
45
|
+
await (0, import_routes.generateRoutes)(appContext);
|
|
46
|
+
await hookRunners.afterBuild({
|
|
47
|
+
stats: void 0
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
resolvedConfig = { ...resolvedConfig, cliOptions: options };
|
|
52
|
+
import_core.ResolvedConfigContext.set(resolvedConfig);
|
|
53
|
+
const { distDirectory, appDirectory, serverConfigFile } = appContext;
|
|
54
|
+
await (0, import_config.buildServerConfig)({
|
|
55
|
+
appDirectory,
|
|
56
|
+
distDirectory,
|
|
57
|
+
configFile: serverConfigFile
|
|
58
|
+
});
|
|
59
|
+
try {
|
|
60
|
+
import_utils.logger.info("Create a production build...\n");
|
|
61
|
+
if (!appContext.builder) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
await appContext.builder.build();
|
|
67
|
+
} catch (error) {
|
|
68
|
+
(0, import_utils.printBuildError)(error);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
build
|
|
75
|
+
});
|
|
@@ -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 deploy_exports = {};
|
|
19
|
+
__export(deploy_exports, {
|
|
20
|
+
deploy: () => deploy
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(deploy_exports);
|
|
23
|
+
const deploy = async (api, options) => {
|
|
24
|
+
const hookRunners = api.useHookRunners();
|
|
25
|
+
await hookRunners.beforeDeploy(options);
|
|
26
|
+
await hookRunners.afterDeploy(options);
|
|
27
|
+
};
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
deploy
|
|
31
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
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 dev_exports = {};
|
|
19
|
+
__export(dev_exports, {
|
|
20
|
+
dev: () => dev
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(dev_exports);
|
|
23
|
+
var import_core = require("@modern-js/core");
|
|
24
|
+
var import_printInstructions = require("../utils/printInstructions");
|
|
25
|
+
var import_createServer = require("../utils/createServer");
|
|
26
|
+
var import_routes = require("../utils/routes");
|
|
27
|
+
var import_config = require("../utils/config");
|
|
28
|
+
var import_getServerInternalPlugins = require("../utils/getServerInternalPlugins");
|
|
29
|
+
const dev = async (api, options) => {
|
|
30
|
+
var _a;
|
|
31
|
+
if (options.analyze) {
|
|
32
|
+
process.env.BUNDLE_ANALYZE = "true";
|
|
33
|
+
}
|
|
34
|
+
let normalizedConfig = api.useResolvedConfigContext();
|
|
35
|
+
const appContext = api.useAppContext();
|
|
36
|
+
const hookRunners = api.useHookRunners();
|
|
37
|
+
normalizedConfig = { ...normalizedConfig, cliOptions: options };
|
|
38
|
+
import_core.ResolvedConfigContext.set(normalizedConfig);
|
|
39
|
+
const { appDirectory, distDirectory, port, apiOnly, serverConfigFile } = appContext;
|
|
40
|
+
await (0, import_config.buildServerConfig)({
|
|
41
|
+
appDirectory,
|
|
42
|
+
distDirectory,
|
|
43
|
+
configFile: serverConfigFile,
|
|
44
|
+
options: {
|
|
45
|
+
esbuildOptions: {
|
|
46
|
+
watch: true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
await hookRunners.beforeDev();
|
|
51
|
+
if (!appContext.builder && !apiOnly) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
await (0, import_routes.generateRoutes)(appContext);
|
|
57
|
+
const serverInternalPlugins = await (0, import_getServerInternalPlugins.getServerInternalPlugins)(api);
|
|
58
|
+
const serverOptions = {
|
|
59
|
+
dev: {
|
|
60
|
+
port,
|
|
61
|
+
https: normalizedConfig.dev.https,
|
|
62
|
+
...(_a = normalizedConfig.tools) == null ? void 0 : _a.devServer
|
|
63
|
+
},
|
|
64
|
+
pwd: appDirectory,
|
|
65
|
+
config: normalizedConfig,
|
|
66
|
+
serverConfigFile,
|
|
67
|
+
internalPlugins: (0, import_createServer.injectDataLoaderPlugin)(serverInternalPlugins)
|
|
68
|
+
};
|
|
69
|
+
if (apiOnly) {
|
|
70
|
+
const app = await (0, import_createServer.createServer)({
|
|
71
|
+
...serverOptions,
|
|
72
|
+
compiler: null
|
|
73
|
+
});
|
|
74
|
+
app.listen(port, async (err) => {
|
|
75
|
+
if (err) {
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
(0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
const { server } = await appContext.builder.startDevServer({
|
|
82
|
+
printURLs: false,
|
|
83
|
+
serverOptions
|
|
84
|
+
});
|
|
85
|
+
(0, import_createServer.setServer)(server);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
dev
|
|
91
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var commands_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(commands_exports);
|
|
17
|
+
__reExport(commands_exports, require("./dev"), module.exports);
|
|
18
|
+
__reExport(commands_exports, require("./build"), module.exports);
|
|
19
|
+
__reExport(commands_exports, require("./serve"), module.exports);
|
|
@@ -0,0 +1,41 @@
|
|
|
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 inspect_exports = {};
|
|
19
|
+
__export(inspect_exports, {
|
|
20
|
+
inspect: () => inspect
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(inspect_exports);
|
|
23
|
+
var import_path = require("path");
|
|
24
|
+
const inspect = async (api, options) => {
|
|
25
|
+
const appContext = api.useAppContext();
|
|
26
|
+
if (!appContext.builder) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return appContext.builder.inspectConfig({
|
|
32
|
+
env: options.env,
|
|
33
|
+
verbose: options.verbose,
|
|
34
|
+
outputPath: (0, import_path.join)(appContext == null ? void 0 : appContext.builder.context.distPath, options.output),
|
|
35
|
+
writeToDisk: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
inspect
|
|
41
|
+
});
|