@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,281 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import {
|
|
3
|
+
createDebugger,
|
|
4
|
+
findExists,
|
|
5
|
+
fs,
|
|
6
|
+
getEntryOptions,
|
|
7
|
+
isApiOnly,
|
|
8
|
+
minimist,
|
|
9
|
+
getCommand,
|
|
10
|
+
isDevCommand
|
|
11
|
+
} from "@modern-js/utils";
|
|
12
|
+
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
13
|
+
import { printInstructions } from "../utils/printInstructions";
|
|
14
|
+
import { generateRoutes } from "../utils/routes";
|
|
15
|
+
import { emitResolvedConfig } from "../utils/config";
|
|
16
|
+
import { getSelectedEntries } from "../utils/getSelectedEntries";
|
|
17
|
+
import { initialNormalizedConfig } from "../config";
|
|
18
|
+
import { createBuilderGenerator } from "../builder";
|
|
19
|
+
import {
|
|
20
|
+
getServerLoadersFile,
|
|
21
|
+
isPageComponentFile,
|
|
22
|
+
parseModule,
|
|
23
|
+
replaceWithAlias
|
|
24
|
+
} from "./utils";
|
|
25
|
+
import {
|
|
26
|
+
APP_CONFIG_NAME,
|
|
27
|
+
APP_INIT_EXPORTED,
|
|
28
|
+
APP_INIT_IMPORTED
|
|
29
|
+
} from "./constants";
|
|
30
|
+
const debug = createDebugger("plugin-analyze");
|
|
31
|
+
var analyze_default = ({
|
|
32
|
+
bundler
|
|
33
|
+
}) => ({
|
|
34
|
+
name: "@modern-js/plugin-analyze",
|
|
35
|
+
setup: (api) => {
|
|
36
|
+
let pagesDir = [];
|
|
37
|
+
let nestedRouteEntries = [];
|
|
38
|
+
let originEntrypoints = [];
|
|
39
|
+
return {
|
|
40
|
+
async prepare() {
|
|
41
|
+
var _a;
|
|
42
|
+
let appContext = api.useAppContext();
|
|
43
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
44
|
+
const hookRunners = api.useHookRunners();
|
|
45
|
+
try {
|
|
46
|
+
fs.emptydirSync(appContext.internalDirectory);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
const apiOnly = await isApiOnly(
|
|
50
|
+
appContext.appDirectory,
|
|
51
|
+
(_a = resolvedConfig.source) == null ? void 0 : _a.entriesDir
|
|
52
|
+
);
|
|
53
|
+
await hookRunners.addRuntimeExports();
|
|
54
|
+
if (apiOnly) {
|
|
55
|
+
const { routes: routes2 } = await hookRunners.modifyServerRoutes({
|
|
56
|
+
routes: []
|
|
57
|
+
});
|
|
58
|
+
debug(`server routes: %o`, routes2);
|
|
59
|
+
appContext = {
|
|
60
|
+
...appContext,
|
|
61
|
+
apiOnly,
|
|
62
|
+
serverRoutes: routes2
|
|
63
|
+
};
|
|
64
|
+
api.setAppContext(appContext);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const [
|
|
68
|
+
{ getBundleEntry },
|
|
69
|
+
{ getServerRoutes },
|
|
70
|
+
{ generateCode },
|
|
71
|
+
{ getHtmlTemplate }
|
|
72
|
+
] = await Promise.all([
|
|
73
|
+
import("./getBundleEntry"),
|
|
74
|
+
import("./getServerRoutes"),
|
|
75
|
+
import("./generateCode"),
|
|
76
|
+
import("./getHtmlTemplate")
|
|
77
|
+
]);
|
|
78
|
+
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
79
|
+
debug(`entrypoints: %o`, entrypoints);
|
|
80
|
+
const initialRoutes = getServerRoutes(entrypoints, {
|
|
81
|
+
appContext,
|
|
82
|
+
config: resolvedConfig
|
|
83
|
+
});
|
|
84
|
+
const { routes } = await hookRunners.modifyServerRoutes({
|
|
85
|
+
routes: initialRoutes
|
|
86
|
+
});
|
|
87
|
+
debug(`server routes: %o`, routes);
|
|
88
|
+
appContext = {
|
|
89
|
+
...appContext,
|
|
90
|
+
entrypoints,
|
|
91
|
+
serverRoutes: routes
|
|
92
|
+
};
|
|
93
|
+
api.setAppContext(appContext);
|
|
94
|
+
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
|
95
|
+
pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
|
|
96
|
+
originEntrypoints = cloneDeep(entrypoints);
|
|
97
|
+
await generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
98
|
+
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
|
99
|
+
appContext,
|
|
100
|
+
config: resolvedConfig
|
|
101
|
+
});
|
|
102
|
+
debug(`html templates: %o`, htmlTemplates);
|
|
103
|
+
await hookRunners.addDefineTypes();
|
|
104
|
+
debug(`add Define Types`);
|
|
105
|
+
let checkedEntries = entrypoints.map((point) => point.entryName);
|
|
106
|
+
if (isDevCommand()) {
|
|
107
|
+
const { entry } = minimist(process.argv.slice(2));
|
|
108
|
+
checkedEntries = await getSelectedEntries(
|
|
109
|
+
typeof entry === "string" ? entry.split(",") : entry,
|
|
110
|
+
entrypoints
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
appContext = {
|
|
114
|
+
...appContext,
|
|
115
|
+
entrypoints,
|
|
116
|
+
checkedEntries,
|
|
117
|
+
apiOnly,
|
|
118
|
+
serverRoutes: routes,
|
|
119
|
+
htmlTemplates
|
|
120
|
+
};
|
|
121
|
+
api.setAppContext(appContext);
|
|
122
|
+
const command = getCommand();
|
|
123
|
+
const buildCommands = ["dev", "start", "build", "inspect", "deploy"];
|
|
124
|
+
if (buildCommands.includes(command)) {
|
|
125
|
+
const normalizedConfig = api.useResolvedConfigContext();
|
|
126
|
+
const createBuilderForModern = await createBuilderGenerator(bundler);
|
|
127
|
+
const builder = await createBuilderForModern({
|
|
128
|
+
normalizedConfig,
|
|
129
|
+
appContext,
|
|
130
|
+
async onBeforeBuild({ bundlerConfigs }) {
|
|
131
|
+
const hookRunners2 = api.useHookRunners();
|
|
132
|
+
await generateRoutes(appContext);
|
|
133
|
+
await hookRunners2.beforeBuild({
|
|
134
|
+
bundlerConfigs
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
async onAfterBuild({ stats }) {
|
|
138
|
+
const hookRunners2 = api.useHookRunners();
|
|
139
|
+
await hookRunners2.afterBuild({ stats });
|
|
140
|
+
await emitResolvedConfig(
|
|
141
|
+
appContext.appDirectory,
|
|
142
|
+
normalizedConfig
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
async onDevCompileDone({ isFirstCompile }) {
|
|
146
|
+
const hookRunners2 = api.useHookRunners();
|
|
147
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
148
|
+
hookRunners2.afterDev();
|
|
149
|
+
if (isFirstCompile) {
|
|
150
|
+
printInstructions(hookRunners2, appContext, normalizedConfig);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
async onBeforeCreateCompiler({ bundlerConfigs }) {
|
|
155
|
+
const hookRunners2 = api.useHookRunners();
|
|
156
|
+
await hookRunners2.beforeCreateCompiler({
|
|
157
|
+
bundlerConfigs
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
async onAfterCreateCompiler({ compiler }) {
|
|
161
|
+
const hookRunners2 = api.useHookRunners();
|
|
162
|
+
await hookRunners2.afterCreateCompiler({
|
|
163
|
+
compiler
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
168
|
+
appContext = {
|
|
169
|
+
...appContext,
|
|
170
|
+
builder
|
|
171
|
+
};
|
|
172
|
+
api.setAppContext(appContext);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
watchFiles() {
|
|
176
|
+
return pagesDir;
|
|
177
|
+
},
|
|
178
|
+
config() {
|
|
179
|
+
return {
|
|
180
|
+
tools: {
|
|
181
|
+
webpackChain: (chain, { name }) => {
|
|
182
|
+
const appContext = api.useAppContext();
|
|
183
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
184
|
+
const { entrypoints, internalDirectory, packageName } = appContext;
|
|
185
|
+
entrypoints.forEach((entrypoint) => {
|
|
186
|
+
const { entryName } = entrypoint;
|
|
187
|
+
const ssr = getEntryOptions(
|
|
188
|
+
entryName,
|
|
189
|
+
resolvedConfig.server.ssr,
|
|
190
|
+
resolvedConfig.server.ssrByEntries,
|
|
191
|
+
packageName
|
|
192
|
+
);
|
|
193
|
+
if (entrypoint.nestedRoutesEntry && ssr && name === "server") {
|
|
194
|
+
const serverLoadersFile = getServerLoadersFile(
|
|
195
|
+
internalDirectory,
|
|
196
|
+
entryName
|
|
197
|
+
);
|
|
198
|
+
chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
resolvedConfig({ resolved }) {
|
|
206
|
+
const appContext = api.useAppContext();
|
|
207
|
+
const config = initialNormalizedConfig(resolved, appContext, bundler);
|
|
208
|
+
return {
|
|
209
|
+
resolved: config
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
async modifyEntryImports({ entrypoint, imports }) {
|
|
213
|
+
const appContext = api.useAppContext();
|
|
214
|
+
const { srcDirectory, internalSrcAlias } = appContext;
|
|
215
|
+
const { fileSystemRoutes, nestedRoutesEntry } = entrypoint;
|
|
216
|
+
if (fileSystemRoutes && nestedRoutesEntry) {
|
|
217
|
+
const rootLayoutPath = path.join(nestedRoutesEntry, "layout");
|
|
218
|
+
const rootLayoutFile = findExists(
|
|
219
|
+
[".js", ".ts", ".jsx", ".tsx"].map(
|
|
220
|
+
(ext) => `${rootLayoutPath}${ext}`
|
|
221
|
+
)
|
|
222
|
+
);
|
|
223
|
+
if (rootLayoutFile) {
|
|
224
|
+
const rootLayoutBuffer = await fs.readFile(rootLayoutFile);
|
|
225
|
+
const rootLayout = rootLayoutBuffer.toString();
|
|
226
|
+
const [, moduleExports] = await parseModule({
|
|
227
|
+
source: rootLayout.toString(),
|
|
228
|
+
filename: rootLayoutFile
|
|
229
|
+
});
|
|
230
|
+
const hasAppConfig = moduleExports.some(
|
|
231
|
+
(e) => e.n === APP_CONFIG_NAME
|
|
232
|
+
);
|
|
233
|
+
const generateLayoutPath = replaceWithAlias(
|
|
234
|
+
srcDirectory,
|
|
235
|
+
rootLayoutFile,
|
|
236
|
+
internalSrcAlias
|
|
237
|
+
);
|
|
238
|
+
if (hasAppConfig) {
|
|
239
|
+
imports.push({
|
|
240
|
+
value: generateLayoutPath,
|
|
241
|
+
specifiers: [{ imported: APP_CONFIG_NAME }]
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
const hasAppInit = moduleExports.some(
|
|
245
|
+
(e) => e.n === APP_INIT_EXPORTED
|
|
246
|
+
);
|
|
247
|
+
if (hasAppInit) {
|
|
248
|
+
imports.push({
|
|
249
|
+
value: generateLayoutPath,
|
|
250
|
+
specifiers: [
|
|
251
|
+
{ imported: APP_INIT_EXPORTED, local: APP_INIT_IMPORTED }
|
|
252
|
+
]
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
entrypoint,
|
|
259
|
+
imports
|
|
260
|
+
};
|
|
261
|
+
},
|
|
262
|
+
async fileChange(e) {
|
|
263
|
+
const appContext = api.useAppContext();
|
|
264
|
+
const { appDirectory } = appContext;
|
|
265
|
+
const { filename, eventType } = e;
|
|
266
|
+
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
|
267
|
+
const absoluteFilePath = path.resolve(appDirectory, filename);
|
|
268
|
+
const isRouteComponent = isPageFile(absoluteFilePath) && isPageComponentFile(absoluteFilePath);
|
|
269
|
+
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
|
270
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
271
|
+
const { generateCode } = await import("./generateCode");
|
|
272
|
+
const entrypoints = cloneDeep(originEntrypoints);
|
|
273
|
+
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
export {
|
|
280
|
+
analyze_default as default
|
|
281
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,42 +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
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
1
|
import * as path from "path";
|
|
41
2
|
import { fs, getRouteId } from "@modern-js/utils";
|
|
42
3
|
import { JS_EXTENSIONS, NESTED_ROUTE } from "./constants";
|
|
@@ -47,10 +8,11 @@ const replaceDynamicPath = (routePath) => {
|
|
|
47
8
|
};
|
|
48
9
|
const createIndexRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
49
10
|
return createRoute(
|
|
50
|
-
|
|
11
|
+
{
|
|
12
|
+
...routeInfo,
|
|
51
13
|
index: true,
|
|
52
14
|
children: void 0
|
|
53
|
-
}
|
|
15
|
+
},
|
|
54
16
|
rootDir,
|
|
55
17
|
filename,
|
|
56
18
|
entryName
|
|
@@ -58,17 +20,18 @@ const createIndexRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
|
58
20
|
};
|
|
59
21
|
const createRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
60
22
|
const id = getRouteId(filename, rootDir, entryName);
|
|
61
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
...routeInfo,
|
|
62
25
|
id,
|
|
63
26
|
type: "nested"
|
|
64
|
-
}
|
|
27
|
+
};
|
|
65
28
|
};
|
|
66
|
-
const walk = (dirname, rootDir, alias, entryName) =>
|
|
29
|
+
const walk = async (dirname, rootDir, alias, entryName) => {
|
|
67
30
|
var _a, _b, _c, _d;
|
|
68
|
-
if (!
|
|
31
|
+
if (!await fs.pathExists(dirname)) {
|
|
69
32
|
return null;
|
|
70
33
|
}
|
|
71
|
-
const isDirectory = (
|
|
34
|
+
const isDirectory = (await fs.stat(dirname)).isDirectory();
|
|
72
35
|
if (!isDirectory) {
|
|
73
36
|
return null;
|
|
74
37
|
}
|
|
@@ -92,14 +55,14 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
92
55
|
let pageRoute = null;
|
|
93
56
|
let splatLoaderFile = "";
|
|
94
57
|
let splatRoute = null;
|
|
95
|
-
const items =
|
|
58
|
+
const items = await fs.readdir(dirname);
|
|
96
59
|
for (const item of items) {
|
|
97
60
|
const itemPath = path.join(dirname, item);
|
|
98
61
|
const extname = path.extname(item);
|
|
99
62
|
const itemWithoutExt = item.slice(0, -extname.length);
|
|
100
|
-
const isDirectory2 = (
|
|
63
|
+
const isDirectory2 = (await fs.stat(itemPath)).isDirectory();
|
|
101
64
|
if (isDirectory2) {
|
|
102
|
-
const childRoute =
|
|
65
|
+
const childRoute = await walk(itemPath, rootDir, alias, entryName);
|
|
103
66
|
if (childRoute) {
|
|
104
67
|
(_a = route.children) == null ? void 0 : _a.push(childRoute);
|
|
105
68
|
}
|
|
@@ -174,13 +137,14 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
174
137
|
const childRoute = finalRoute.children[0];
|
|
175
138
|
if (childRoute.path === "*") {
|
|
176
139
|
const path2 = `${finalRoute.path || ""}/${childRoute.path || ""}`;
|
|
177
|
-
finalRoute =
|
|
140
|
+
finalRoute = {
|
|
141
|
+
...childRoute,
|
|
178
142
|
path: path2
|
|
179
|
-
}
|
|
143
|
+
};
|
|
180
144
|
}
|
|
181
145
|
}
|
|
182
146
|
return finalRoute;
|
|
183
|
-
}
|
|
147
|
+
};
|
|
184
148
|
export {
|
|
185
149
|
walk
|
|
186
150
|
};
|
|
@@ -1,42 +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
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
1
|
import path from "path";
|
|
41
2
|
import { fs, slash } from "@modern-js/utils";
|
|
42
3
|
import { APP_CONFIG_NAME, TEMP_LOADERS_DIR } from "./constants";
|
|
@@ -69,6 +30,7 @@ const renderFunction = ({
|
|
|
69
30
|
customBootstrap,
|
|
70
31
|
fileSystemRoutes: fileSystemRoutes2
|
|
71
32
|
}) => {
|
|
33
|
+
const bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
|
|
72
34
|
return `
|
|
73
35
|
const finalAppConfig = {
|
|
74
36
|
...App.config,
|
|
@@ -90,7 +52,7 @@ const renderFunction = ({
|
|
|
90
52
|
|
|
91
53
|
|
|
92
54
|
if (IS_BROWSER) {
|
|
93
|
-
${customBootstrap ? `customBootstrap(AppWrapper);` :
|
|
55
|
+
${customBootstrap ? `customBootstrap(AppWrapper, () => ${bootstrap});` : `${bootstrap};`}
|
|
94
56
|
}
|
|
95
57
|
|
|
96
58
|
return AppWrapper
|
|
@@ -143,10 +105,11 @@ const routesForServer = ({
|
|
|
143
105
|
loader = `loader_${loaders.length - 1}`;
|
|
144
106
|
}
|
|
145
107
|
}
|
|
146
|
-
const finalRoute =
|
|
108
|
+
const finalRoute = {
|
|
109
|
+
...route,
|
|
147
110
|
loader,
|
|
148
111
|
children
|
|
149
|
-
}
|
|
112
|
+
};
|
|
150
113
|
return finalRoute;
|
|
151
114
|
};
|
|
152
115
|
let routesCode = `
|
|
@@ -176,13 +139,13 @@ const routesForServer = ({
|
|
|
176
139
|
${routesCode}
|
|
177
140
|
`;
|
|
178
141
|
};
|
|
179
|
-
const fileSystemRoutes =
|
|
142
|
+
const fileSystemRoutes = async ({
|
|
180
143
|
routes,
|
|
181
144
|
ssrMode,
|
|
182
145
|
nestedRoutesEntry,
|
|
183
146
|
entryName,
|
|
184
147
|
internalDirectory
|
|
185
|
-
}) {
|
|
148
|
+
}) => {
|
|
186
149
|
const loadings = [];
|
|
187
150
|
const errors = [];
|
|
188
151
|
const loaders = [];
|
|
@@ -256,13 +219,14 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
256
219
|
lazyImport = `() => import('${route._component}')`;
|
|
257
220
|
component = `loadable(${lazyImport})`;
|
|
258
221
|
}
|
|
259
|
-
const finalRoute =
|
|
222
|
+
const finalRoute = {
|
|
223
|
+
...route,
|
|
260
224
|
lazyImport,
|
|
261
225
|
loading,
|
|
262
226
|
loader,
|
|
263
227
|
error,
|
|
264
228
|
children
|
|
265
|
-
}
|
|
229
|
+
};
|
|
266
230
|
if (route._component) {
|
|
267
231
|
finalRoute.component = component;
|
|
268
232
|
}
|
|
@@ -277,9 +241,10 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
277
241
|
routeComponentsCode += `${JSON.stringify(newRoute, null, 2).replace(/"(loadable.*\))"/g, "$1").replace(/"(loadableLazy.*\))"/g, "$1").replace(/"(\(\)[^,]+)",/g, "$1,").replace(/"(lazy\(.*\))"/g, "$1").replace(/"(loading_[^"])"/g, "$1").replace(/"(loader_[^"])"/g, "$1").replace(/"(RootLayout)"/g, "$1").replace(/"(error_[^"])"/g, "$1").replace(/\\"/g, '"')},`;
|
|
278
242
|
} else {
|
|
279
243
|
const component = `loadable(() => import('${route._component}'))`;
|
|
280
|
-
const finalRoute =
|
|
244
|
+
const finalRoute = {
|
|
245
|
+
...route,
|
|
281
246
|
component
|
|
282
|
-
}
|
|
247
|
+
};
|
|
283
248
|
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, "$1").replace(/"(lazy[^"]*)"/g, "$1")},`;
|
|
284
249
|
}
|
|
285
250
|
}
|
|
@@ -307,8 +272,8 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
307
272
|
`;
|
|
308
273
|
}
|
|
309
274
|
}
|
|
310
|
-
|
|
311
|
-
|
|
275
|
+
await fs.ensureFile(loadersMapFile);
|
|
276
|
+
await fs.writeJSON(loadersMapFile, loadersMap);
|
|
312
277
|
return `
|
|
313
278
|
${importLazyCode}
|
|
314
279
|
${rootLayoutCode}
|
|
@@ -317,7 +282,7 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
317
282
|
${importLoadersCode}
|
|
318
283
|
${routeComponentsCode}
|
|
319
284
|
`;
|
|
320
|
-
}
|
|
285
|
+
};
|
|
321
286
|
export {
|
|
322
287
|
fileSystemRoutes,
|
|
323
288
|
html,
|
|
@@ -1,23 +1,3 @@
|
|
|
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 fs from "fs";
|
|
22
2
|
import path from "path";
|
|
23
3
|
import { isReact18, normalizeToPosixPath, fs as fse } from "@modern-js/utils";
|
|
@@ -105,28 +85,28 @@ const isPageComponentFile = (filePath) => {
|
|
|
105
85
|
return false;
|
|
106
86
|
};
|
|
107
87
|
const replaceWithAlias = (base, filePath, alias) => normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
|
108
|
-
const parseModule =
|
|
88
|
+
const parseModule = async ({
|
|
109
89
|
source,
|
|
110
90
|
filename
|
|
111
|
-
}) {
|
|
91
|
+
}) => {
|
|
112
92
|
let content = source;
|
|
113
93
|
if (JS_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
|
|
114
|
-
const result =
|
|
94
|
+
const result = await transform(content, {
|
|
115
95
|
loader: path.extname(filename).slice(1),
|
|
116
96
|
format: "esm"
|
|
117
97
|
});
|
|
118
98
|
content = result.code;
|
|
119
99
|
}
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
const hasLoader = (filename) =>
|
|
123
|
-
const source =
|
|
124
|
-
const [, moduleExports] =
|
|
100
|
+
return await parse(content);
|
|
101
|
+
};
|
|
102
|
+
const hasLoader = async (filename) => {
|
|
103
|
+
const source = await fse.readFile(filename);
|
|
104
|
+
const [, moduleExports] = await parseModule({
|
|
125
105
|
source: source.toString(),
|
|
126
106
|
filename
|
|
127
107
|
});
|
|
128
108
|
return moduleExports.some((e) => e.n === LOADER_EXPORT_NAME);
|
|
129
|
-
}
|
|
109
|
+
};
|
|
130
110
|
const getServerLoadersFile = (internalDirectory, entryName) => {
|
|
131
111
|
return path.join(internalDirectory, entryName, "route-server-loaders.js");
|
|
132
112
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
|
|
2
|
+
import { generateBuilder } from "../generator";
|
|
3
|
+
function createRspackBuilderForModern(options) {
|
|
4
|
+
return generateBuilder(options, builderRspackProvider);
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
createRspackBuilderForModern
|
|
8
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { createCopyPattern } from "../../shared";
|
|
3
|
+
import { RouterPlugin } from "../webpackPlugins";
|
|
4
|
+
const PluginCompatModern = (options) => ({
|
|
5
|
+
name: "builder-plugin-compat-modern",
|
|
6
|
+
setup(api) {
|
|
7
|
+
const { normalizedConfig: modernConfig, appContext } = options;
|
|
8
|
+
api.modifyWebpackChain((chain, { CHAIN_ID }) => {
|
|
9
|
+
var _a;
|
|
10
|
+
chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
|
|
11
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
12
|
+
const defaultCopyPattern = createCopyPattern(
|
|
13
|
+
appContext,
|
|
14
|
+
modernConfig,
|
|
15
|
+
"public",
|
|
16
|
+
chain
|
|
17
|
+
);
|
|
18
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
|
19
|
+
var _a2;
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const { entrypoints } = appContext;
|
|
28
|
+
const existNestedRoutes = entrypoints.some(
|
|
29
|
+
(entrypoint) => entrypoint.nestedRoutesEntry
|
|
30
|
+
);
|
|
31
|
+
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
|
32
|
+
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
|
33
|
+
if (existNestedRoutes || routerManifest) {
|
|
34
|
+
chain.plugin("route-plugin").use(RouterPlugin);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
PluginCompatModern
|
|
41
|
+
};
|