@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,175 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _asyncToGenerator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
31
|
+
var f, y, t, g, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
};
|
|
40
|
+
return g = {
|
|
41
|
+
next: verb(0),
|
|
42
|
+
"throw": verb(1),
|
|
43
|
+
"return": verb(2)
|
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
+
return this;
|
|
46
|
+
}), g;
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([
|
|
50
|
+
n,
|
|
51
|
+
v
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while(_)try {
|
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
+
if (y = 0, t) op = [
|
|
60
|
+
op[0] & 2,
|
|
61
|
+
t.value
|
|
62
|
+
];
|
|
63
|
+
switch(op[0]){
|
|
64
|
+
case 0:
|
|
65
|
+
case 1:
|
|
66
|
+
t = op;
|
|
67
|
+
break;
|
|
68
|
+
case 4:
|
|
69
|
+
_.label++;
|
|
70
|
+
return {
|
|
71
|
+
value: op[1],
|
|
72
|
+
done: false
|
|
73
|
+
};
|
|
74
|
+
case 5:
|
|
75
|
+
_.label++;
|
|
76
|
+
y = op[1];
|
|
77
|
+
op = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
continue;
|
|
81
|
+
case 7:
|
|
82
|
+
op = _.ops.pop();
|
|
83
|
+
_.trys.pop();
|
|
84
|
+
continue;
|
|
85
|
+
default:
|
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
+
_ = 0;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
+
_.label = op[1];
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
+
_.label = t[1];
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t && _.label < t[2]) {
|
|
100
|
+
_.label = t[2];
|
|
101
|
+
_.ops.push(op);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t[2]) _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
op = body.call(thisArg, _);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
op = [
|
|
111
|
+
6,
|
|
112
|
+
e
|
|
113
|
+
];
|
|
114
|
+
y = 0;
|
|
115
|
+
} finally{
|
|
116
|
+
f = t = 0;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] & 5) throw op[1];
|
|
119
|
+
return {
|
|
120
|
+
value: op[0] ? op[1] : void 0,
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function createBuilderGenerator(bundler) {
|
|
126
|
+
return _createBuilderGenerator.apply(this, arguments);
|
|
127
|
+
}
|
|
128
|
+
function _createBuilderGenerator() {
|
|
129
|
+
_createBuilderGenerator = _asyncToGenerator(function(bundler) {
|
|
130
|
+
var createRspackBuilderForModern, _, createWebpackBuilderForModern;
|
|
131
|
+
return __generator(this, function(_state) {
|
|
132
|
+
switch(_state.label){
|
|
133
|
+
case 0:
|
|
134
|
+
if (!(bundler === "rspack")) return [
|
|
135
|
+
3,
|
|
136
|
+
4
|
|
137
|
+
];
|
|
138
|
+
_state.label = 1;
|
|
139
|
+
case 1:
|
|
140
|
+
_state.trys.push([
|
|
141
|
+
1,
|
|
142
|
+
3,
|
|
143
|
+
,
|
|
144
|
+
4
|
|
145
|
+
]);
|
|
146
|
+
return [
|
|
147
|
+
4,
|
|
148
|
+
import("./builder-rspack")
|
|
149
|
+
];
|
|
150
|
+
case 2:
|
|
151
|
+
createRspackBuilderForModern = _state.sent().createRspackBuilderForModern;
|
|
152
|
+
return [
|
|
153
|
+
2,
|
|
154
|
+
createRspackBuilderForModern
|
|
155
|
+
];
|
|
156
|
+
case 3:
|
|
157
|
+
_ = _state.sent();
|
|
158
|
+
throw new Error("Failed to use rspack, please check if you have `@modern-js/builder-rspack-provider` installed");
|
|
159
|
+
case 4:
|
|
160
|
+
return [
|
|
161
|
+
4,
|
|
162
|
+
import("./builder-webpack")
|
|
163
|
+
];
|
|
164
|
+
case 5:
|
|
165
|
+
createWebpackBuilderForModern = _state.sent().createWebpackBuilderForModern;
|
|
166
|
+
return [
|
|
167
|
+
2,
|
|
168
|
+
createWebpackBuilderForModern
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
return _createBuilderGenerator.apply(this, arguments);
|
|
174
|
+
}
|
|
175
|
+
export { createBuilderGenerator };
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _arrayWithoutHoles(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
8
|
-
}
|
|
9
1
|
function _defineProperty(obj, key, value) {
|
|
10
2
|
if (key in obj) {
|
|
11
3
|
Object.defineProperty(obj, key, {
|
|
@@ -19,12 +11,6 @@ function _defineProperty(obj, key, value) {
|
|
|
19
11
|
}
|
|
20
12
|
return obj;
|
|
21
13
|
}
|
|
22
|
-
function _iterableToArray(iter) {
|
|
23
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
24
|
-
}
|
|
25
|
-
function _nonIterableSpread() {
|
|
26
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
27
|
-
}
|
|
28
14
|
function _objectSpread(target) {
|
|
29
15
|
for(var i = 1; i < arguments.length; i++){
|
|
30
16
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -64,32 +50,57 @@ function _objectSpreadProps(target, source) {
|
|
|
64
50
|
}
|
|
65
51
|
return target;
|
|
66
52
|
}
|
|
67
|
-
function _toConsumableArray(arr) {
|
|
68
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
69
|
-
}
|
|
70
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
71
|
-
if (!o) return;
|
|
72
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
73
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
74
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
75
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
76
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
77
|
-
}
|
|
78
|
-
import { join } from "path";
|
|
79
53
|
import { mergeBuilderConfig } from "@modern-js/builder-shared";
|
|
80
|
-
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
81
|
-
import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
|
|
82
54
|
import { getEntryOptions } from "@modern-js/utils";
|
|
83
|
-
import
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import
|
|
87
|
-
var
|
|
55
|
+
import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
|
|
56
|
+
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
57
|
+
import { HtmlAsyncChunkPlugin } from "../bundlerPlugins/HtmlAsyncChunkPlugin";
|
|
58
|
+
import { BottomTemplatePlugin } from "../bundlerPlugins/HtmlBottomTemplate";
|
|
59
|
+
var isStreamingSSR = function(userConfig) {
|
|
60
|
+
var isStreaming = function(ssr) {
|
|
61
|
+
return ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
62
|
+
};
|
|
63
|
+
var server = userConfig.server;
|
|
64
|
+
if (isStreaming(server.ssr)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
68
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
69
|
+
try {
|
|
70
|
+
for(var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
71
|
+
var name = _step.value;
|
|
72
|
+
if (isStreaming(server.ssrByEntries[name])) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
_didIteratorError = true;
|
|
78
|
+
_iteratorError = err;
|
|
79
|
+
} finally{
|
|
80
|
+
try {
|
|
81
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
82
|
+
_iterator.return();
|
|
83
|
+
}
|
|
84
|
+
} finally{
|
|
85
|
+
if (_didIteratorError) {
|
|
86
|
+
throw _iteratorError;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
var builderPluginAdapterModern = function(options) {
|
|
88
94
|
return {
|
|
89
|
-
name: "builder-plugin-
|
|
95
|
+
name: "builder-plugin-adapter-modern",
|
|
90
96
|
setup: function setup(api) {
|
|
97
|
+
var isHtmlEnabled = function isHtmlEnabled(config, target) {
|
|
98
|
+
var _config_tools;
|
|
99
|
+
return ((_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : _config_tools.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
100
|
+
};
|
|
101
|
+
var normalizedConfig = options.normalizedConfig, appContext = options.appContext;
|
|
91
102
|
api.modifyBuilderConfig(function(config) {
|
|
92
|
-
if (isStreamingSSR(
|
|
103
|
+
if (isStreamingSSR(normalizedConfig)) {
|
|
93
104
|
return mergeBuilderConfig(config, {
|
|
94
105
|
html: {
|
|
95
106
|
inject: "body"
|
|
@@ -98,70 +109,44 @@ var PluginCompatModern = function(appContext, modernConfig, options) {
|
|
|
98
109
|
}
|
|
99
110
|
return config;
|
|
100
111
|
});
|
|
101
|
-
api.
|
|
112
|
+
api.modifyBundlerChain(function(chain, param) {
|
|
102
113
|
var target = param.target, CHAIN_ID = param.CHAIN_ID, isProd = param.isProd;
|
|
103
|
-
var
|
|
104
|
-
var ref;
|
|
105
|
-
return ((ref = config.tools) === null || ref === void 0 ? void 0 : ref.htmlPlugin) !== false && target2 !== "node" && target2 !== "web-worker";
|
|
106
|
-
};
|
|
107
|
-
var ref;
|
|
108
|
-
var builderNormalizedConfig = api.getNormalizedConfig();
|
|
114
|
+
var builderConfig = api.getNormalizedConfig();
|
|
109
115
|
if (target === "node") {
|
|
110
116
|
chain.name("server");
|
|
117
|
+
} else if (target === "service-worker") {
|
|
118
|
+
chain.name("service-worker");
|
|
119
|
+
} else if (target === "web-worker") {
|
|
120
|
+
chain.name("worker");
|
|
111
121
|
} else if (target === "modern-web") {
|
|
112
122
|
chain.name("modern");
|
|
113
123
|
} else {
|
|
114
124
|
chain.name("client");
|
|
115
125
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
applyNodeCompat(chain, modernConfig, isProd);
|
|
126
|
+
if (target === "node" || target === "service-worker") {
|
|
127
|
+
applyNodeCompat(target, chain, normalizedConfig, isProd);
|
|
119
128
|
}
|
|
120
|
-
if (isHtmlEnabled(
|
|
121
|
-
|
|
129
|
+
if (isHtmlEnabled(builderConfig, target)) {
|
|
130
|
+
applyBottomHtmlPlugin({
|
|
122
131
|
api: api,
|
|
123
132
|
chain: chain,
|
|
124
|
-
|
|
133
|
+
modernConfig: normalizedConfig,
|
|
125
134
|
appContext: appContext,
|
|
126
|
-
|
|
135
|
+
CHAIN_ID: CHAIN_ID
|
|
127
136
|
});
|
|
128
137
|
applyAsyncChunkHtmlPlugin({
|
|
129
138
|
chain: chain,
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
modernConfig: normalizedConfig,
|
|
140
|
+
CHAIN_ID: CHAIN_ID
|
|
132
141
|
});
|
|
133
142
|
}
|
|
134
|
-
if (
|
|
135
|
-
var defaultCopyPattern = createCopyPattern(appContext, modernConfig, "public", chain);
|
|
136
|
-
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(function(args) {
|
|
137
|
-
var ref;
|
|
138
|
-
return [
|
|
139
|
-
{
|
|
140
|
-
patterns: _toConsumableArray(((ref = args[0]) === null || ref === void 0 ? void 0 : ref.patterns) || []).concat([
|
|
141
|
-
defaultCopyPattern
|
|
142
|
-
])
|
|
143
|
-
}
|
|
144
|
-
];
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
var entrypoints = appContext.entrypoints;
|
|
148
|
-
var existNestedRoutes = entrypoints.some(function(entrypoint) {
|
|
149
|
-
return entrypoint.nestedRoutesEntry;
|
|
150
|
-
});
|
|
151
|
-
var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.runtime) === null || ref === void 0 ? void 0 : ref.router;
|
|
152
|
-
var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
|
|
153
|
-
if (existNestedRoutes || routerManifest) {
|
|
154
|
-
chain.plugin("route-plugin").use(RouterPlugin);
|
|
155
|
-
}
|
|
156
|
-
if (target !== "node") {
|
|
143
|
+
if (target !== "node" && target !== "web-worker" && target !== "service-worker") {
|
|
157
144
|
var bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
158
145
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
159
146
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
160
147
|
}
|
|
161
148
|
});
|
|
162
|
-
|
|
163
|
-
applyCallbacks(api, options);
|
|
164
|
-
}
|
|
149
|
+
applyCallbacks(api, options);
|
|
165
150
|
}
|
|
166
151
|
};
|
|
167
152
|
};
|
|
@@ -175,11 +160,58 @@ function applyCallbacks(api, options) {
|
|
|
175
160
|
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
176
161
|
options.onExit && api.onExit(options.onExit);
|
|
177
162
|
}
|
|
178
|
-
function
|
|
163
|
+
function applyBottomHtmlPlugin(param) {
|
|
164
|
+
var api = param.api, chain = param.chain, modernConfig = param.modernConfig, appContext = param.appContext, CHAIN_ID = param.CHAIN_ID;
|
|
165
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
166
|
+
try {
|
|
167
|
+
var _loop = function() {
|
|
168
|
+
var entryName = _step.value;
|
|
169
|
+
var baseTemplateParams = _objectSpread({
|
|
170
|
+
entryName: entryName,
|
|
171
|
+
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
172
|
+
mountId: modernConfig.html.mountId
|
|
173
|
+
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
174
|
+
chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function(args) {
|
|
175
|
+
return [
|
|
176
|
+
_objectSpreadProps(_objectSpread({}, args[0] || {}), {
|
|
177
|
+
__internal__: true,
|
|
178
|
+
bottomTemplate: appContext.htmlTemplates["__".concat(entryName, "-bottom__")] && lodashTemplate(appContext.htmlTemplates["__".concat(entryName, "-bottom__")])(baseTemplateParams)
|
|
179
|
+
})
|
|
180
|
+
];
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
for(var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
184
|
+
} catch (err) {
|
|
185
|
+
_didIteratorError = true;
|
|
186
|
+
_iteratorError = err;
|
|
187
|
+
} finally{
|
|
188
|
+
try {
|
|
189
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
190
|
+
_iterator.return();
|
|
191
|
+
}
|
|
192
|
+
} finally{
|
|
193
|
+
if (_didIteratorError) {
|
|
194
|
+
throw _iteratorError;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [
|
|
199
|
+
HtmlWebpackPlugin
|
|
200
|
+
]);
|
|
201
|
+
}
|
|
202
|
+
function applyAsyncChunkHtmlPlugin(param) {
|
|
203
|
+
var chain = param.chain, modernConfig = param.modernConfig, CHAIN_ID = param.CHAIN_ID;
|
|
204
|
+
if (isStreamingSSR(modernConfig)) {
|
|
205
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
|
|
206
|
+
HtmlWebpackPlugin
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
179
211
|
var filterEntriesBySSRConfig = function filterEntriesBySSRConfig(isProd2, chain2, serverConfig, outputConfig) {
|
|
180
|
-
var
|
|
212
|
+
var _outputConfig_ssg;
|
|
181
213
|
var entries = chain2.entryPoints.entries();
|
|
182
|
-
if (isProd2 && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (
|
|
214
|
+
if (isProd2 && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (_outputConfig_ssg = outputConfig.ssg) === null || _outputConfig_ssg === void 0 ? void 0 : _outputConfig_ssg[0]) === "function")) {
|
|
183
215
|
return;
|
|
184
216
|
}
|
|
185
217
|
if (typeof entries === "undefined") {
|
|
@@ -198,14 +230,14 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
198
230
|
}
|
|
199
231
|
});
|
|
200
232
|
}
|
|
201
|
-
var
|
|
233
|
+
var _ref = serverConfig || {}, ssr = _ref.ssr, ssrByEntries = _ref.ssrByEntries;
|
|
202
234
|
entryNames.forEach(function(name) {
|
|
203
235
|
if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
|
|
204
236
|
chain2.entryPoints.delete(name);
|
|
205
237
|
}
|
|
206
238
|
});
|
|
207
239
|
};
|
|
208
|
-
|
|
240
|
+
var nodeExts = [
|
|
209
241
|
".node.js",
|
|
210
242
|
".node.jsx",
|
|
211
243
|
".node.ts",
|
|
@@ -214,33 +246,19 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
214
246
|
".server.ts",
|
|
215
247
|
".server.ts",
|
|
216
248
|
".server.tsx"
|
|
217
|
-
];
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
var api = param.api, chain = param.chain, modernConfig = param.modernConfig, appContext = param.appContext, CHAIN_ID = param.CHAIN_ID;
|
|
249
|
+
];
|
|
250
|
+
var webWorkerExts = [
|
|
251
|
+
".worker.js",
|
|
252
|
+
".worker.jsx",
|
|
253
|
+
".worker.ts",
|
|
254
|
+
".worker.tsx"
|
|
255
|
+
];
|
|
225
256
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
226
257
|
try {
|
|
227
|
-
var
|
|
228
|
-
var
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
232
|
-
mountId: modernConfig.html.mountId
|
|
233
|
-
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
234
|
-
chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function(args) {
|
|
235
|
-
return [
|
|
236
|
-
_objectSpreadProps(_objectSpread({}, args[0] || {}), {
|
|
237
|
-
__internal__: true,
|
|
238
|
-
bottomTemplate: appContext.htmlTemplates["__".concat(entryName, "-bottom__")] && lodashTemplate(appContext.htmlTemplates["__".concat(entryName, "-bottom__")])(baseTemplateParams)
|
|
239
|
-
})
|
|
240
|
-
];
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
for(var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
258
|
+
for(var _iterator = nodeExts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
259
|
+
var ext = _step.value;
|
|
260
|
+
chain.resolve.extensions.prepend(ext);
|
|
261
|
+
}
|
|
244
262
|
} catch (err) {
|
|
245
263
|
_didIteratorError = true;
|
|
246
264
|
_iteratorError = err;
|
|
@@ -255,50 +273,28 @@ function applyBottomHtmlWebpackPlugin(param) {
|
|
|
255
273
|
}
|
|
256
274
|
}
|
|
257
275
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
]);
|
|
261
|
-
}
|
|
262
|
-
var isStreamingSSR = function(userConfig) {
|
|
263
|
-
var isStreaming = function(ssr) {
|
|
264
|
-
return ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
265
|
-
};
|
|
266
|
-
var server = userConfig.server;
|
|
267
|
-
if (isStreaming(server.ssr)) {
|
|
268
|
-
return true;
|
|
269
|
-
}
|
|
270
|
-
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
271
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
276
|
+
if (target === "service-worker") {
|
|
277
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
272
278
|
try {
|
|
273
|
-
for(var
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
279
|
+
for(var _iterator1 = webWorkerExts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
280
|
+
var ext1 = _step1.value;
|
|
281
|
+
chain.resolve.extensions.prepend(ext1);
|
|
278
282
|
}
|
|
279
283
|
} catch (err) {
|
|
280
|
-
|
|
281
|
-
|
|
284
|
+
_didIteratorError1 = true;
|
|
285
|
+
_iteratorError1 = err;
|
|
282
286
|
} finally{
|
|
283
287
|
try {
|
|
284
|
-
if (!
|
|
285
|
-
|
|
288
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
289
|
+
_iterator1.return();
|
|
286
290
|
}
|
|
287
291
|
} finally{
|
|
288
|
-
if (
|
|
289
|
-
throw
|
|
292
|
+
if (_didIteratorError1) {
|
|
293
|
+
throw _iteratorError1;
|
|
290
294
|
}
|
|
291
295
|
}
|
|
292
296
|
}
|
|
293
297
|
}
|
|
294
|
-
|
|
295
|
-
};
|
|
296
|
-
function applyAsyncChunkHtmlPlugin(param) {
|
|
297
|
-
var chain = param.chain, modernConfig = param.modernConfig, CHAIN_ID = param.CHAIN_ID;
|
|
298
|
-
if (isStreamingSSR(modernConfig)) {
|
|
299
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
|
|
300
|
-
HtmlWebpackPlugin
|
|
301
|
-
]);
|
|
302
|
-
}
|
|
298
|
+
filterEntriesBySSRConfig(isProd, chain, modernConfig.server, modernConfig.output);
|
|
303
299
|
}
|
|
304
|
-
export {
|
|
300
|
+
export { applyCallbacks, builderPluginAdapterModern };
|
|
File without changes
|
|
@@ -48,8 +48,8 @@ var BottomTemplatePlugin = /*#__PURE__*/ function() {
|
|
|
48
48
|
var _this = this;
|
|
49
49
|
compiler.hooks.compilation.tap(this.name, function(compilation) {
|
|
50
50
|
_this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(_this.name, function(data) {
|
|
51
|
-
var
|
|
52
|
-
if (!((
|
|
51
|
+
var _data_plugin_options;
|
|
52
|
+
if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
|
|
53
53
|
return data;
|
|
54
54
|
}
|
|
55
55
|
if (_this.bottomTemplateReg.test(data.html)) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -182,7 +182,7 @@ import { buildServerConfig } from "../utils/config";
|
|
|
182
182
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
183
183
|
var dev = function() {
|
|
184
184
|
var _ref = _asyncToGenerator(function(api, options) {
|
|
185
|
-
var
|
|
185
|
+
var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, app, server;
|
|
186
186
|
return __generator(this, function(_state) {
|
|
187
187
|
switch(_state.label){
|
|
188
188
|
case 0:
|
|
@@ -237,7 +237,7 @@ var dev = function() {
|
|
|
237
237
|
dev: _objectSpread({
|
|
238
238
|
port: port,
|
|
239
239
|
https: normalizedConfig.dev.https
|
|
240
|
-
}, (
|
|
240
|
+
}, (_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer),
|
|
241
241
|
pwd: appDirectory,
|
|
242
242
|
config: normalizedConfig,
|
|
243
243
|
serverConfigFile: serverConfigFile,
|
|
File without changes
|
|
File without changes
|
|
@@ -129,7 +129,7 @@ import { injectDataLoaderPlugin } from "../utils/createServer";
|
|
|
129
129
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
130
130
|
var start = function() {
|
|
131
131
|
var _ref = _asyncToGenerator(function(api) {
|
|
132
|
-
var
|
|
132
|
+
var _userConfig_source, appContext, userConfig, hookRunners, appDirectory, port, serverConfigFile, apiOnly, serverInternalPlugins, app;
|
|
133
133
|
return __generator(this, function(_state) {
|
|
134
134
|
switch(_state.label){
|
|
135
135
|
case 0:
|
|
@@ -140,7 +140,7 @@ var start = function() {
|
|
|
140
140
|
logger.log(chalk.cyan("Starting the modern server..."));
|
|
141
141
|
return [
|
|
142
142
|
4,
|
|
143
|
-
isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (
|
|
143
|
+
isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir)
|
|
144
144
|
];
|
|
145
145
|
case 1:
|
|
146
146
|
apiOnly = _state.sent();
|
|
@@ -51,12 +51,11 @@ function _objectSpreadProps(target, source) {
|
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
53
|
import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
|
|
54
|
-
function createDefaultConfig(appContext) {
|
|
54
|
+
function createDefaultConfig(appContext, bundler) {
|
|
55
55
|
var defaultBuilderConfig = createDefaultBuilderConfig();
|
|
56
56
|
var dev = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.dev), {
|
|
57
57
|
port: void 0
|
|
58
58
|
});
|
|
59
|
-
var tools = _objectSpread({}, defaultBuilderConfig.tools);
|
|
60
59
|
var output = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.output), {
|
|
61
60
|
disableNodePolyfill: true
|
|
62
61
|
});
|
|
@@ -95,6 +94,7 @@ function createDefaultConfig(appContext) {
|
|
|
95
94
|
baseUrl: "/",
|
|
96
95
|
port: 8080
|
|
97
96
|
};
|
|
97
|
+
var tools = bundler === "webpack" ? _objectSpread({}, defaultBuilderConfig.tools) : void 0;
|
|
98
98
|
return {
|
|
99
99
|
source: source,
|
|
100
100
|
output: output,
|