@modern-js/app-tools 2.3.1-alpha.2 → 2.5.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/{js/node → cjs}/analyze/constants.js +0 -0
- package/dist/cjs/analyze/generateCode.js +249 -0
- package/dist/{js/node → cjs}/analyze/getBundleEntry.js +6 -0
- package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutes.js +1 -18
- package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutesLegacy.js +1 -18
- package/dist/{js/node → cjs}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/node → cjs}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/node → cjs}/analyze/getFileSystemEntry.js +0 -0
- package/dist/{js/node → cjs}/analyze/getHtmlTemplate.js +4 -24
- package/dist/{js/node → cjs}/analyze/getServerRoutes.js +22 -42
- package/dist/cjs/analyze/index.js +290 -0
- package/dist/{js/node → cjs}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/node → cjs}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/node → cjs}/analyze/nestedRoutes.js +16 -50
- package/dist/{js/node → cjs}/analyze/templates.js +16 -49
- package/dist/{js/node → cjs}/analyze/utils.js +9 -29
- 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/{js/node/builder/webpackPlugins/routerPlugin.js → cjs/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +14 -29
- package/dist/cjs/builder/builder-webpack/webpackPlugins/index.js +17 -0
- package/dist/cjs/builder/generator/createBuilderOptions.js +47 -0
- package/dist/{js/node/config/initial/index.js → cjs/builder/generator/createBuilderProviderConfig.js} +26 -18
- 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/{js/node/builder/builderPlugins/compatModern.js → cjs/builder/shared/builderPlugins/adapterModern.js} +109 -137
- 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/{js/node/utils → cjs/builder/shared}/types.js +0 -0
- package/dist/{js/node → cjs}/commands/build.js +9 -46
- package/dist/cjs/commands/deploy.js +31 -0
- package/dist/{js/node → cjs}/commands/dev.js +17 -52
- package/dist/{js/node → cjs}/commands/index.js +0 -0
- package/dist/{js/node → cjs}/commands/inspect.js +2 -22
- package/dist/{js/node → cjs}/commands/serve.js +8 -28
- package/dist/{js/node → cjs}/config/default.js +16 -27
- package/dist/cjs/config/index.js +19 -0
- package/dist/cjs/config/initialize/index.js +35 -0
- package/dist/{js/node/config/initial → cjs/config/initialize}/inits.js +8 -22
- 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/{js/node → cjs}/exports/server.js +0 -0
- package/dist/{js/node → cjs}/hooks.js +0 -0
- package/dist/cjs/index.js +198 -0
- package/dist/cjs/initialize/index.js +102 -0
- package/dist/{js/node → cjs}/locale/en.js +0 -0
- package/dist/{js/node → cjs}/locale/index.js +0 -0
- package/dist/{js/node → cjs}/locale/zh.js +1 -1
- package/dist/{js/node → cjs}/schema/Schema.js +0 -0
- package/dist/{js/node → cjs}/schema/index.js +0 -0
- package/dist/{js/node → cjs}/schema/legacy.js +0 -0
- package/dist/{js/node → cjs}/types/config/deploy.js +0 -0
- package/dist/{js/node → cjs}/types/config/dev.js +0 -0
- package/dist/{js/node → cjs}/types/config/experiments.js +0 -0
- package/dist/{js/node → cjs}/types/config/html.js +0 -0
- package/dist/{js/node → cjs}/types/config/index.js +0 -0
- package/dist/{js/node → cjs}/types/config/output.js +0 -0
- package/dist/{js/node → cjs}/types/config/performance.js +0 -0
- package/dist/{js/node → cjs}/types/config/security.js +0 -0
- package/dist/{js/node → cjs}/types/config/source.js +0 -0
- package/dist/{js/node → cjs}/types/config/tools.js +0 -0
- package/dist/{js/node → cjs}/types/hooks.js +0 -0
- package/dist/{js/node → cjs}/types/index.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/index.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/output.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/source.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/tools.js +0 -0
- package/dist/cjs/types/utils.js +15 -0
- package/dist/{js/node → cjs}/utils/config.js +19 -57
- package/dist/{js/node → cjs}/utils/createServer.js +10 -46
- package/dist/{js/node → cjs}/utils/env.js +0 -0
- package/dist/{js/node → cjs}/utils/generateWatchFiles.js +16 -38
- package/dist/{js/node → cjs}/utils/getSelectedEntries.js +3 -23
- package/dist/{js/node/config/index.js → cjs/utils/getServerInternalPlugins.js} +20 -13
- package/dist/{js/node → cjs}/utils/language.js +0 -0
- package/dist/{js/node → cjs}/utils/printInstructions.js +3 -23
- package/dist/cjs/utils/restart.js +45 -0
- package/dist/{js/node → cjs}/utils/routes.js +3 -23
- package/dist/cjs/utils/types.js +15 -0
- package/dist/{js/treeshaking → esm}/analyze/constants.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/generateCode.js +14 -14
- package/dist/{js/treeshaking → esm}/analyze/getBundleEntry.js +4 -2
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getFileSystemEntry.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getHtmlTemplate.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getServerRoutes.js +8 -6
- package/dist/{js/treeshaking → esm}/analyze/index.js +142 -137
- package/dist/{js/treeshaking → esm}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/nestedRoutes.js +5 -5
- package/dist/{js/treeshaking → esm}/analyze/templates.js +8 -7
- package/dist/{js/treeshaking → esm}/analyze/utils.js +3 -3
- package/dist/esm/builder/builder-rspack/index.js +6 -0
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/{js/treeshaking/builder → esm/builder/builder-webpack}/index.js +44 -117
- package/dist/{js/treeshaking/builder/webpackPlugins/routerPlugin.js → esm/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +6 -3
- 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/{js/treeshaking/builder/builderPlugins/compatModern.js → esm/builder/shared/builderPlugins/adapterModern.js} +138 -142
- package/dist/{js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js → esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
- package/dist/{js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js → esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js} +2 -2
- 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/{js/treeshaking/utils → esm/builder/shared}/types.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/build.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/dev.js +2 -2
- package/dist/{js/treeshaking → esm}/commands/index.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/inspect.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/serve.js +2 -2
- package/dist/{js/treeshaking → esm}/config/default.js +2 -2
- package/dist/esm/config/index.js +3 -0
- package/dist/esm/config/initialize/index.js +10 -0
- package/dist/{js/treeshaking/config/initial → esm/config/initialize}/inits.js +6 -4
- package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
- package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createOutputConfig.js +1 -1
- package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createSourceConfig.js +1 -1
- package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createToolsConfig.js +1 -1
- package/dist/{js/treeshaking/config/initial/transformNormalizedConfig.js → esm/config/legacy/index.js} +4 -1
- package/dist/{js/treeshaking → esm}/defineConfig.js +0 -0
- package/dist/{js/treeshaking → esm}/exports/server.js +0 -0
- package/dist/{js/treeshaking → esm}/hooks.js +0 -0
- package/dist/{js/treeshaking → esm}/index.js +19 -12
- package/dist/{js/treeshaking → esm}/initialize/index.js +36 -28
- package/dist/{js/treeshaking → esm}/locale/en.js +0 -0
- package/dist/{js/treeshaking → esm}/locale/index.js +0 -0
- package/dist/{js/treeshaking → esm}/locale/zh.js +1 -1
- package/dist/{js/treeshaking → esm}/schema/Schema.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/index.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/legacy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/dev.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/experiments.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/html.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/output.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/performance.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/security.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/source.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/tools.js +0 -0
- package/dist/{js/treeshaking → esm}/types/hooks.js +0 -0
- package/dist/{js/treeshaking → esm}/types/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/output.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/source.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/tools.js +0 -0
- package/dist/esm/types/utils.js +1 -0
- package/dist/{js/treeshaking → esm}/utils/config.js +2 -2
- package/dist/{js/treeshaking → esm}/utils/createServer.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/env.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/generateWatchFiles.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/getSelectedEntries.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/getServerInternalPlugins.js +2 -2
- package/dist/{js/treeshaking → esm}/utils/language.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/printInstructions.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/restart.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/routes.js +0 -0
- package/dist/esm/utils/types.js +1 -0
- package/dist/{js/modern → esm-node}/analyze/constants.js +0 -0
- package/dist/esm-node/analyze/generateCode.js +225 -0
- package/dist/{js/modern → esm-node}/analyze/getBundleEntry.js +6 -0
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutes.js +1 -20
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutesLegacy.js +1 -20
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getFileSystemEntry.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getHtmlTemplate.js +4 -24
- package/dist/{js/modern → esm-node}/analyze/getServerRoutes.js +24 -45
- package/dist/esm-node/analyze/index.js +281 -0
- package/dist/{js/modern → esm-node}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/nestedRoutes.js +16 -52
- package/dist/{js/modern → esm-node}/analyze/templates.js +16 -51
- package/dist/{js/modern → esm-node}/analyze/utils.js +9 -29
- 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/{js/modern/builder/webpackPlugins/routerPlugin.js → esm-node/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +8 -25
- 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/{js/modern/builder/builderPlugins/compatModern.js → esm-node/builder/shared/builderPlugins/adapterModern.js} +104 -135
- 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/{js/modern/utils → 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/{js/modern → esm-node}/commands/index.js +0 -0
- package/dist/esm-node/commands/inspect.js +18 -0
- package/dist/{js/modern → esm-node}/commands/serve.js +8 -28
- package/dist/{js/modern → esm-node}/config/default.js +16 -29
- package/dist/esm-node/config/index.js +3 -0
- package/dist/esm-node/config/initialize/index.js +12 -0
- package/dist/{js/modern/config/initial → esm-node/config/initialize}/inits.js +8 -24
- 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/{js/modern → esm-node}/exports/server.js +0 -0
- package/dist/{js/modern → esm-node}/hooks.js +0 -0
- package/dist/esm-node/index.js +172 -0
- package/dist/esm-node/initialize/index.js +91 -0
- package/dist/{js/modern → esm-node}/locale/en.js +0 -0
- package/dist/{js/modern → esm-node}/locale/index.js +0 -0
- package/dist/{js/modern → esm-node}/locale/zh.js +1 -1
- package/dist/{js/modern → esm-node}/schema/Schema.js +0 -0
- package/dist/{js/modern → esm-node}/schema/index.js +0 -0
- package/dist/{js/modern → esm-node}/schema/legacy.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/deploy.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/dev.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/experiments.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/html.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/output.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/performance.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/security.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/source.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/tools.js +0 -0
- package/dist/{js/modern → esm-node}/types/hooks.js +0 -0
- package/dist/{js/modern → esm-node}/types/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/output.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/source.js +0 -0
- package/dist/{js/modern → 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/{js/modern → esm-node}/utils/env.js +0 -0
- package/dist/esm-node/utils/generateWatchFiles.js +33 -0
- package/dist/{js/modern → esm-node}/utils/getSelectedEntries.js +3 -23
- package/dist/esm-node/utils/getServerInternalPlugins.js +18 -0
- package/dist/{js/modern → esm-node}/utils/language.js +0 -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/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/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/analyze/generateCode.js +0 -247
- package/dist/js/modern/analyze/index.js +0 -332
- package/dist/js/modern/builder/index.js +0 -159
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
- package/dist/js/modern/commands/build.js +0 -91
- package/dist/js/modern/commands/deploy.js +0 -28
- package/dist/js/modern/commands/dev.js +0 -109
- package/dist/js/modern/commands/inspect.js +0 -38
- package/dist/js/modern/config/index.js +0 -8
- package/dist/js/modern/config/initial/index.js +0 -16
- package/dist/js/modern/defineConfig.js +0 -27
- package/dist/js/modern/index.js +0 -211
- package/dist/js/modern/initialize/index.js +0 -124
- package/dist/js/modern/utils/config.js +0 -128
- package/dist/js/modern/utils/createServer.js +0 -75
- package/dist/js/modern/utils/generateWatchFiles.js +0 -55
- package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
- package/dist/js/modern/utils/printInstructions.js +0 -31
- package/dist/js/modern/utils/restart.js +0 -44
- package/dist/js/modern/utils/routes.js +0 -30
- package/dist/js/node/analyze/generateCode.js +0 -271
- package/dist/js/node/analyze/index.js +0 -339
- package/dist/js/node/builder/index.js +0 -177
- package/dist/js/node/commands/deploy.js +0 -51
- package/dist/js/node/defineConfig.js +0 -49
- package/dist/js/node/index.js +0 -235
- package/dist/js/node/initialize/index.js +0 -134
- package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
- package/dist/js/node/utils/restart.js +0 -67
- package/dist/js/treeshaking/config/index.js +0 -3
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +0 -19
- 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,72 @@
|
|
|
1
|
+
import { ResolvedConfigContext } from "@modern-js/core";
|
|
2
|
+
import { printInstructions } from "../utils/printInstructions";
|
|
3
|
+
import {
|
|
4
|
+
setServer,
|
|
5
|
+
createServer,
|
|
6
|
+
injectDataLoaderPlugin
|
|
7
|
+
} from "../utils/createServer";
|
|
8
|
+
import { generateRoutes } from "../utils/routes";
|
|
9
|
+
import { buildServerConfig } from "../utils/config";
|
|
10
|
+
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
11
|
+
const dev = async (api, options) => {
|
|
12
|
+
var _a;
|
|
13
|
+
if (options.analyze) {
|
|
14
|
+
process.env.BUNDLE_ANALYZE = "true";
|
|
15
|
+
}
|
|
16
|
+
let normalizedConfig = api.useResolvedConfigContext();
|
|
17
|
+
const appContext = api.useAppContext();
|
|
18
|
+
const hookRunners = api.useHookRunners();
|
|
19
|
+
normalizedConfig = { ...normalizedConfig, cliOptions: options };
|
|
20
|
+
ResolvedConfigContext.set(normalizedConfig);
|
|
21
|
+
const { appDirectory, distDirectory, port, apiOnly, serverConfigFile } = appContext;
|
|
22
|
+
await buildServerConfig({
|
|
23
|
+
appDirectory,
|
|
24
|
+
distDirectory,
|
|
25
|
+
configFile: serverConfigFile,
|
|
26
|
+
options: {
|
|
27
|
+
esbuildOptions: {
|
|
28
|
+
watch: true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
await hookRunners.beforeDev();
|
|
33
|
+
if (!appContext.builder && !apiOnly) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
await generateRoutes(appContext);
|
|
39
|
+
const serverInternalPlugins = await getServerInternalPlugins(api);
|
|
40
|
+
const serverOptions = {
|
|
41
|
+
dev: {
|
|
42
|
+
port,
|
|
43
|
+
https: normalizedConfig.dev.https,
|
|
44
|
+
...(_a = normalizedConfig.tools) == null ? void 0 : _a.devServer
|
|
45
|
+
},
|
|
46
|
+
pwd: appDirectory,
|
|
47
|
+
config: normalizedConfig,
|
|
48
|
+
serverConfigFile,
|
|
49
|
+
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins)
|
|
50
|
+
};
|
|
51
|
+
if (apiOnly) {
|
|
52
|
+
const app = await createServer({
|
|
53
|
+
...serverOptions,
|
|
54
|
+
compiler: null
|
|
55
|
+
});
|
|
56
|
+
app.listen(port, async (err) => {
|
|
57
|
+
if (err) {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
const { server } = await appContext.builder.startDevServer({
|
|
64
|
+
printURLs: false,
|
|
65
|
+
serverOptions
|
|
66
|
+
});
|
|
67
|
+
setServer(server);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
dev
|
|
72
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
const inspect = async (api, options) => {
|
|
3
|
+
const appContext = api.useAppContext();
|
|
4
|
+
if (!appContext.builder) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return appContext.builder.inspectConfig({
|
|
10
|
+
env: options.env,
|
|
11
|
+
verbose: options.verbose,
|
|
12
|
+
outputPath: join(appContext == null ? void 0 : appContext.builder.context.distPath, options.output),
|
|
13
|
+
writeToDisk: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
inspect
|
|
18
|
+
};
|
|
@@ -1,54 +1,34 @@
|
|
|
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
1
|
import { logger, chalk, isApiOnly } from "@modern-js/utils";
|
|
22
2
|
import server from "@modern-js/prod-server";
|
|
23
3
|
import { printInstructions } from "../utils/printInstructions";
|
|
24
4
|
import { injectDataLoaderPlugin } from "../utils/createServer";
|
|
25
5
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
26
|
-
const start = (api) =>
|
|
6
|
+
const start = async (api) => {
|
|
27
7
|
var _a;
|
|
28
8
|
const appContext = api.useAppContext();
|
|
29
9
|
const userConfig = api.useResolvedConfigContext();
|
|
30
10
|
const hookRunners = api.useHookRunners();
|
|
31
11
|
const { appDirectory, port, serverConfigFile } = appContext;
|
|
32
12
|
logger.log(chalk.cyan(`Starting the modern server...`));
|
|
33
|
-
const apiOnly =
|
|
13
|
+
const apiOnly = await isApiOnly(
|
|
34
14
|
appContext.appDirectory,
|
|
35
15
|
(_a = userConfig == null ? void 0 : userConfig.source) == null ? void 0 : _a.entriesDir
|
|
36
16
|
);
|
|
37
|
-
const serverInternalPlugins =
|
|
38
|
-
const app =
|
|
17
|
+
const serverInternalPlugins = await getServerInternalPlugins(api);
|
|
18
|
+
const app = await server({
|
|
39
19
|
pwd: appDirectory,
|
|
40
20
|
config: userConfig,
|
|
41
21
|
serverConfigFile,
|
|
42
22
|
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins),
|
|
43
23
|
apiOnly
|
|
44
24
|
});
|
|
45
|
-
app.listen(port, (err) =>
|
|
25
|
+
app.listen(port, async (err) => {
|
|
46
26
|
if (err) {
|
|
47
27
|
throw err;
|
|
48
28
|
}
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
}
|
|
29
|
+
await printInstructions(hookRunners, appContext, userConfig);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
52
32
|
export {
|
|
53
33
|
start
|
|
54
34
|
};
|
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
|
|
21
|
-
function createDefaultConfig(appContext) {
|
|
2
|
+
function createDefaultConfig(appContext, bundler) {
|
|
22
3
|
const defaultBuilderConfig = createDefaultBuilderConfig();
|
|
23
|
-
const dev =
|
|
4
|
+
const dev = {
|
|
5
|
+
...defaultBuilderConfig.dev,
|
|
24
6
|
port: void 0
|
|
25
|
-
}
|
|
26
|
-
const
|
|
27
|
-
|
|
7
|
+
};
|
|
8
|
+
const output = {
|
|
9
|
+
...defaultBuilderConfig.output,
|
|
28
10
|
disableNodePolyfill: true
|
|
29
|
-
}
|
|
30
|
-
const source =
|
|
11
|
+
};
|
|
12
|
+
const source = {
|
|
13
|
+
...defaultBuilderConfig.source,
|
|
31
14
|
entries: void 0,
|
|
32
15
|
enableAsyncEntry: false,
|
|
33
16
|
disableDefaultEntries: false,
|
|
@@ -39,8 +22,9 @@ function createDefaultConfig(appContext) {
|
|
|
39
22
|
"@": appContext.srcDirectory,
|
|
40
23
|
"@shared": appContext.sharedDirectory
|
|
41
24
|
}
|
|
42
|
-
}
|
|
43
|
-
const html =
|
|
25
|
+
};
|
|
26
|
+
const html = {
|
|
27
|
+
...defaultBuilderConfig.html,
|
|
44
28
|
title: "",
|
|
45
29
|
meta: {
|
|
46
30
|
charset: { charset: "utf-8" },
|
|
@@ -52,7 +36,7 @@ function createDefaultConfig(appContext) {
|
|
|
52
36
|
"wap-font-scale": "no",
|
|
53
37
|
"format-detection": "telephone=no"
|
|
54
38
|
}
|
|
55
|
-
}
|
|
39
|
+
};
|
|
56
40
|
const server = {
|
|
57
41
|
routes: void 0,
|
|
58
42
|
publicRoutes: void 0,
|
|
@@ -61,6 +45,9 @@ function createDefaultConfig(appContext) {
|
|
|
61
45
|
baseUrl: "/",
|
|
62
46
|
port: 8080
|
|
63
47
|
};
|
|
48
|
+
const tools = bundler === "webpack" ? {
|
|
49
|
+
...defaultBuilderConfig.tools
|
|
50
|
+
} : void 0;
|
|
64
51
|
return {
|
|
65
52
|
source,
|
|
66
53
|
output,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { initHtmlConfig, initSourceConfig, initToolsConfig } from "./inits";
|
|
2
|
+
function initialNormalizedConfig(config, appContext, bundler) {
|
|
3
|
+
initHtmlConfig(config, appContext);
|
|
4
|
+
initSourceConfig(config, appContext, bundler);
|
|
5
|
+
if (bundler === "webpack") {
|
|
6
|
+
initToolsConfig(config);
|
|
7
|
+
}
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
initialNormalizedConfig
|
|
12
|
+
};
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import path, { dirname, isAbsolute, posix, sep } from "path";
|
|
21
2
|
import {
|
|
22
3
|
applyOptionsChain,
|
|
@@ -59,14 +40,16 @@ function initHtmlConfig(config, appContext) {
|
|
|
59
40
|
return favicon || defaultFavicon || void 0;
|
|
60
41
|
}
|
|
61
42
|
}
|
|
62
|
-
function initSourceConfig(config, appContext) {
|
|
43
|
+
function initSourceConfig(config, appContext, bundler) {
|
|
63
44
|
config.source.include = createBuilderInclude(config, appContext);
|
|
64
|
-
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
65
45
|
config.source.globalVars = createBuilderGlobalVars(config, appContext);
|
|
46
|
+
if (bundler === "webpack") {
|
|
47
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
48
|
+
}
|
|
66
49
|
function createBuilderGlobalVars(config2, appContext2) {
|
|
67
50
|
const { globalVars = {} } = config2.source;
|
|
68
51
|
const publicEnv = getAutoInjectEnv(appContext2);
|
|
69
|
-
return
|
|
52
|
+
return { ...globalVars, ...publicEnv };
|
|
70
53
|
}
|
|
71
54
|
function createBuilderInclude(config2, appContext2) {
|
|
72
55
|
const { include } = config2.source;
|
|
@@ -136,10 +119,11 @@ function initToolsConfig(config) {
|
|
|
136
119
|
config.tools.tsChecker = applyOptionsChain(defaultTsChecker, tsChecker);
|
|
137
120
|
tsLoader && (config.tools.tsLoader = (tsLoaderConfig, utils) => {
|
|
138
121
|
applyOptionsChain(
|
|
139
|
-
|
|
122
|
+
{
|
|
123
|
+
...tsLoaderConfig,
|
|
140
124
|
transpileOnly: false,
|
|
141
125
|
allowTsInNodeModules: true
|
|
142
|
-
}
|
|
126
|
+
},
|
|
143
127
|
tsLoader || {},
|
|
144
128
|
utils
|
|
145
129
|
);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import lintPlugin from "@modern-js/plugin-lint";
|
|
3
|
+
import {
|
|
4
|
+
cleanRequireCache,
|
|
5
|
+
emptyDir,
|
|
6
|
+
Import,
|
|
7
|
+
getCommand
|
|
8
|
+
} from "@modern-js/utils";
|
|
9
|
+
import { castArray } from "@modern-js/utils/lodash";
|
|
10
|
+
import analyzePlugin from "./analyze";
|
|
11
|
+
import initializePlugin from "./initialize";
|
|
12
|
+
import { hooks } from "./hooks";
|
|
13
|
+
import { i18n, localeKeys } from "./locale";
|
|
14
|
+
import { getLocaleLanguage } from "./utils/language";
|
|
15
|
+
import { restart } from "./utils/restart";
|
|
16
|
+
import { generateWatchFiles } from "./utils/generateWatchFiles";
|
|
17
|
+
export * from "./defineConfig";
|
|
18
|
+
export * from "./types";
|
|
19
|
+
const upgradeModel = Import.lazy(
|
|
20
|
+
"@modern-js/upgrade",
|
|
21
|
+
require
|
|
22
|
+
);
|
|
23
|
+
const devCommand = async (program, api) => {
|
|
24
|
+
const runner = api.useHookRunners();
|
|
25
|
+
const devToolMetas = await runner.registerDev();
|
|
26
|
+
const devProgram = program.command("dev").alias("start").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).action(async (options) => {
|
|
27
|
+
const { dev } = await import("./commands/dev");
|
|
28
|
+
await dev(api, options);
|
|
29
|
+
});
|
|
30
|
+
for (const meta of devToolMetas) {
|
|
31
|
+
if (!meta.subCommands) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
for (const subCmd of meta.subCommands) {
|
|
35
|
+
devProgram.command(subCmd).action(async (options = {}) => {
|
|
36
|
+
const { appDirectory } = api.useAppContext();
|
|
37
|
+
const { isTypescript } = await import("@modern-js/utils");
|
|
38
|
+
await runner.beforeDevTask(meta);
|
|
39
|
+
await meta.action(options, {
|
|
40
|
+
isTsProject: isTypescript(appDirectory)
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const buildCommand = async (program, api) => {
|
|
47
|
+
const runner = api.useHookRunners();
|
|
48
|
+
const platformBuilders = await runner.registerBuildPlatform();
|
|
49
|
+
const buildProgram = program.command("build").usage("[options]").description(i18n.t(localeKeys.command.build.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).action(async (options) => {
|
|
50
|
+
const { build } = await import("./commands/build");
|
|
51
|
+
await build(api, options);
|
|
52
|
+
});
|
|
53
|
+
for (const platformBuilder of platformBuilders) {
|
|
54
|
+
const platforms = castArray(platformBuilder.platform);
|
|
55
|
+
for (const platform of platforms) {
|
|
56
|
+
buildProgram.command(platform).action(async () => {
|
|
57
|
+
const { appDirectory } = api.useAppContext();
|
|
58
|
+
const { isTypescript } = await import("@modern-js/utils");
|
|
59
|
+
await runner.beforeBuildPlatform(platformBuilders);
|
|
60
|
+
await platformBuilder.build(platform, {
|
|
61
|
+
isTsProject: isTypescript(appDirectory)
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var src_default = (options = {
|
|
68
|
+
bundler: "webpack"
|
|
69
|
+
}) => ({
|
|
70
|
+
name: "@modern-js/app-tools",
|
|
71
|
+
post: [
|
|
72
|
+
"@modern-js/plugin-initialize",
|
|
73
|
+
"@modern-js/plugin-analyze",
|
|
74
|
+
"@modern-js/plugin-ssr",
|
|
75
|
+
"@modern-js/plugin-document",
|
|
76
|
+
"@modern-js/plugin-state",
|
|
77
|
+
"@modern-js/plugin-router",
|
|
78
|
+
"@modern-js/plugin-router-v5",
|
|
79
|
+
"@modern-js/plugin-polyfill"
|
|
80
|
+
],
|
|
81
|
+
registerHook: hooks,
|
|
82
|
+
usePlugins: [
|
|
83
|
+
initializePlugin({
|
|
84
|
+
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
85
|
+
}),
|
|
86
|
+
analyzePlugin({
|
|
87
|
+
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
88
|
+
}),
|
|
89
|
+
lintPlugin()
|
|
90
|
+
],
|
|
91
|
+
setup: (api) => {
|
|
92
|
+
const locale = getLocaleLanguage();
|
|
93
|
+
i18n.changeLanguage({ locale });
|
|
94
|
+
return {
|
|
95
|
+
async commands({ program }) {
|
|
96
|
+
await devCommand(program, api);
|
|
97
|
+
await buildCommand(program, api);
|
|
98
|
+
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option(
|
|
99
|
+
"-c --config <config>",
|
|
100
|
+
i18n.t(localeKeys.command.shared.config)
|
|
101
|
+
).action(async () => {
|
|
102
|
+
const { start } = await import("./commands/serve");
|
|
103
|
+
await start(api);
|
|
104
|
+
});
|
|
105
|
+
program.command("deploy").usage("[options]").option(
|
|
106
|
+
"-c --config <config>",
|
|
107
|
+
i18n.t(localeKeys.command.shared.config)
|
|
108
|
+
).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options2) => {
|
|
109
|
+
const { build } = await import("./commands/build");
|
|
110
|
+
await build(api);
|
|
111
|
+
const { deploy } = await import("./commands/deploy");
|
|
112
|
+
await deploy(api, options2);
|
|
113
|
+
process.exit(0);
|
|
114
|
+
});
|
|
115
|
+
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option(
|
|
116
|
+
"-c, --config <config>",
|
|
117
|
+
i18n.t(localeKeys.command.new.config)
|
|
118
|
+
).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(async (options2) => {
|
|
119
|
+
const { MWANewAction } = await import("@modern-js/new-action");
|
|
120
|
+
await MWANewAction({ ...options2, locale: options2.lang || locale });
|
|
121
|
+
});
|
|
122
|
+
program.command("inspect").description("inspect internal webpack config").option(
|
|
123
|
+
`--env <env>`,
|
|
124
|
+
i18n.t(localeKeys.command.inspect.env),
|
|
125
|
+
"development"
|
|
126
|
+
).option(
|
|
127
|
+
"--output <output>",
|
|
128
|
+
i18n.t(localeKeys.command.inspect.output),
|
|
129
|
+
"/"
|
|
130
|
+
).option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option(
|
|
131
|
+
"-c --config <config>",
|
|
132
|
+
i18n.t(localeKeys.command.shared.config)
|
|
133
|
+
).action(async (options2) => {
|
|
134
|
+
const { inspect } = await import("./commands/inspect");
|
|
135
|
+
inspect(api, options2);
|
|
136
|
+
});
|
|
137
|
+
upgradeModel.defineCommand(program.command("upgrade"));
|
|
138
|
+
},
|
|
139
|
+
async prepare() {
|
|
140
|
+
const command = getCommand();
|
|
141
|
+
if (command === "dev" || command === "start" || command === "build") {
|
|
142
|
+
const appContext = api.useAppContext();
|
|
143
|
+
await emptyDir(appContext.distDirectory);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
async watchFiles() {
|
|
147
|
+
const appContext = api.useAppContext();
|
|
148
|
+
const config = api.useResolvedConfigContext();
|
|
149
|
+
return generateWatchFiles(appContext, config.source.configDir);
|
|
150
|
+
},
|
|
151
|
+
async fileChange(e) {
|
|
152
|
+
const { filename, eventType } = e;
|
|
153
|
+
const appContext = api.useAppContext();
|
|
154
|
+
const { appDirectory, srcDirectory } = appContext;
|
|
155
|
+
const absolutePath = path.resolve(appDirectory, filename);
|
|
156
|
+
if (!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")) {
|
|
157
|
+
const { closeServer } = await import("./utils/createServer");
|
|
158
|
+
await closeServer();
|
|
159
|
+
await restart(api.useHookRunners(), filename);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
async beforeRestart() {
|
|
163
|
+
cleanRequireCache([require.resolve("./analyze")]);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
export {
|
|
169
|
+
buildCommand,
|
|
170
|
+
src_default as default,
|
|
171
|
+
devCommand
|
|
172
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureAbsolutePath,
|
|
3
|
+
getPort,
|
|
4
|
+
isDev,
|
|
5
|
+
isDevCommand
|
|
6
|
+
} from "@modern-js/utils";
|
|
7
|
+
import { legacySchema, schema } from "../schema";
|
|
8
|
+
import {
|
|
9
|
+
checkIsLegacyConfig,
|
|
10
|
+
createDefaultConfig,
|
|
11
|
+
createLegacyDefaultConfig,
|
|
12
|
+
transformNormalizedConfig
|
|
13
|
+
} from "../config";
|
|
14
|
+
var initialize_default = ({
|
|
15
|
+
bundler
|
|
16
|
+
}) => ({
|
|
17
|
+
name: "@modern-js/plugin-initialize",
|
|
18
|
+
setup(api) {
|
|
19
|
+
const config = () => {
|
|
20
|
+
const appContext = api.useAppContext();
|
|
21
|
+
const userConfig = api.useConfigContext();
|
|
22
|
+
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
|
|
23
|
+
};
|
|
24
|
+
const validateSchema = () => {
|
|
25
|
+
const userConfig = api.useConfigContext();
|
|
26
|
+
const schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
|
|
27
|
+
return schemas.generate();
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
config,
|
|
31
|
+
validateSchema,
|
|
32
|
+
async resolvedConfig({ resolved }) {
|
|
33
|
+
var _a;
|
|
34
|
+
let appContext = api.useAppContext();
|
|
35
|
+
const userConfig = api.useConfigContext();
|
|
36
|
+
const port = await getServerPort(resolved);
|
|
37
|
+
appContext = {
|
|
38
|
+
...appContext,
|
|
39
|
+
port,
|
|
40
|
+
distDirectory: ensureAbsolutePath(
|
|
41
|
+
appContext.distDirectory,
|
|
42
|
+
((_a = resolved.output.distPath) == null ? void 0 : _a.root) || "dist"
|
|
43
|
+
)
|
|
44
|
+
};
|
|
45
|
+
api.setAppContext(appContext);
|
|
46
|
+
const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
|
47
|
+
resolved._raw = userConfig;
|
|
48
|
+
resolved.server = {
|
|
49
|
+
...normalizedConfig.server || {},
|
|
50
|
+
port
|
|
51
|
+
};
|
|
52
|
+
resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
|
|
53
|
+
stabilizeConfig(resolved, normalizedConfig, [
|
|
54
|
+
"source",
|
|
55
|
+
"bff",
|
|
56
|
+
"dev",
|
|
57
|
+
"html",
|
|
58
|
+
"output",
|
|
59
|
+
"tools",
|
|
60
|
+
"testing",
|
|
61
|
+
"plugins",
|
|
62
|
+
"builderPlugins",
|
|
63
|
+
"runtime",
|
|
64
|
+
"runtimeByEntries",
|
|
65
|
+
"deploy",
|
|
66
|
+
"performance"
|
|
67
|
+
]);
|
|
68
|
+
if (bundler === "webpack") {
|
|
69
|
+
resolved.security = normalizedConfig.security || {};
|
|
70
|
+
resolved.experiments = normalizedConfig.experiments;
|
|
71
|
+
}
|
|
72
|
+
return { resolved };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
function stabilizeConfig(resolve, config, keys) {
|
|
78
|
+
keys.forEach((key) => {
|
|
79
|
+
resolve[key] = config[key] || {};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async function getServerPort(config) {
|
|
83
|
+
const prodPort = config.server.port || 8080;
|
|
84
|
+
if (isDev() && isDevCommand()) {
|
|
85
|
+
return getPort(config.dev.port || prodPort);
|
|
86
|
+
}
|
|
87
|
+
return prodPort;
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
initialize_default as default
|
|
91
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -17,7 +17,7 @@ const ZH_LOCALE = {
|
|
|
17
17
|
serve: { describe: "应用启动命令" },
|
|
18
18
|
deploy: { describe: "部署应用命令" },
|
|
19
19
|
new: {
|
|
20
|
-
describe: "
|
|
20
|
+
describe: "Web App 项目中执行生成器",
|
|
21
21
|
debug: "开启 Debug 模式,打印调试日志信息",
|
|
22
22
|
config: "生成器运行默认配置(JSON 字符串)",
|
|
23
23
|
distTag: "生成器使用特殊的 npm Tag 版本",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|