@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
|
@@ -1,38 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __objRest = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
36
7
|
var __export = (target, all) => {
|
|
37
8
|
for (var name in all)
|
|
38
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -69,9 +40,10 @@ const applyBaseUrl = (baseUrl, routes) => {
|
|
|
69
40
|
} else {
|
|
70
41
|
return routes.map((route) => {
|
|
71
42
|
const urlPath = (0, import_utils.urlJoin)(baseUrl, route.urlPath);
|
|
72
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
...route,
|
|
73
45
|
urlPath: urlPath === "/" ? urlPath : (0, import_utils.removeTailSlash)(urlPath)
|
|
74
|
-
}
|
|
46
|
+
};
|
|
75
47
|
});
|
|
76
48
|
}
|
|
77
49
|
}
|
|
@@ -86,28 +58,34 @@ const applyRouteOptions = (original, routeOptions) => {
|
|
|
86
58
|
if (Array.isArray(route)) {
|
|
87
59
|
routes = route.map((url) => {
|
|
88
60
|
if ((0, import_utils.isPlainObject)(url)) {
|
|
89
|
-
const
|
|
90
|
-
return
|
|
61
|
+
const { path: urlPath, ...other } = url;
|
|
62
|
+
return {
|
|
63
|
+
...original,
|
|
64
|
+
...other,
|
|
91
65
|
urlPath
|
|
92
|
-
}
|
|
66
|
+
};
|
|
93
67
|
} else {
|
|
94
|
-
return
|
|
68
|
+
return {
|
|
69
|
+
...original,
|
|
95
70
|
urlPath: url
|
|
96
|
-
}
|
|
71
|
+
};
|
|
97
72
|
}
|
|
98
73
|
});
|
|
99
74
|
} else if ((0, import_utils.isPlainObject)(route)) {
|
|
100
|
-
const
|
|
75
|
+
const { path: urlPath, ...other } = route;
|
|
101
76
|
routes = [
|
|
102
|
-
|
|
77
|
+
{
|
|
78
|
+
...original,
|
|
79
|
+
...other,
|
|
103
80
|
urlPath
|
|
104
|
-
}
|
|
81
|
+
}
|
|
105
82
|
];
|
|
106
83
|
} else {
|
|
107
84
|
routes = [
|
|
108
|
-
|
|
85
|
+
{
|
|
86
|
+
...original,
|
|
109
87
|
urlPath: route
|
|
110
|
-
}
|
|
88
|
+
}
|
|
111
89
|
];
|
|
112
90
|
}
|
|
113
91
|
} else {
|
|
@@ -119,7 +97,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
|
119
97
|
const {
|
|
120
98
|
html: { disableHtmlFolder },
|
|
121
99
|
output: { distPath: { html: htmlPath } = {} },
|
|
122
|
-
server: { baseUrl, routes, ssr, ssrByEntries }
|
|
100
|
+
server: { baseUrl, routes, ssr, ssrByEntries, worker }
|
|
123
101
|
} = config;
|
|
124
102
|
const { packageName } = appContext;
|
|
125
103
|
let htmlRoutes = entrypoints.reduce(
|
|
@@ -131,6 +109,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
|
131
109
|
packageName
|
|
132
110
|
);
|
|
133
111
|
const isSSR = Boolean(entryOptions);
|
|
112
|
+
const isWorker = Boolean(worker);
|
|
134
113
|
const { resHeaders } = (routes == null ? void 0 : routes[entryName]) || {};
|
|
135
114
|
let route = {
|
|
136
115
|
urlPath: `/${entryName === import_utils.MAIN_ENTRY_NAME ? "" : entryName}`,
|
|
@@ -143,6 +122,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
|
143
122
|
isSPA: true,
|
|
144
123
|
isSSR,
|
|
145
124
|
responseHeaders: resHeaders,
|
|
125
|
+
worker: isWorker ? `${import_utils.SERVER_WORKER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0,
|
|
146
126
|
bundle: isSSR ? `${import_utils.SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0
|
|
147
127
|
};
|
|
148
128
|
if (routes == null ? void 0 : routes.hasOwnProperty(entryName)) {
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var analyze_exports = {};
|
|
25
|
+
__export(analyze_exports, {
|
|
26
|
+
default: () => analyze_default
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(analyze_exports);
|
|
29
|
+
var path = __toESM(require("path"));
|
|
30
|
+
var import_utils = require("@modern-js/utils");
|
|
31
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
|
32
|
+
var import_printInstructions = require("../utils/printInstructions");
|
|
33
|
+
var import_routes = require("../utils/routes");
|
|
34
|
+
var import_config = require("../utils/config");
|
|
35
|
+
var import_getSelectedEntries = require("../utils/getSelectedEntries");
|
|
36
|
+
var import_config2 = require("../config");
|
|
37
|
+
var import_builder = require("../builder");
|
|
38
|
+
var import_utils2 = require("./utils");
|
|
39
|
+
var import_constants = require("./constants");
|
|
40
|
+
const debug = (0, import_utils.createDebugger)("plugin-analyze");
|
|
41
|
+
var analyze_default = ({
|
|
42
|
+
bundler
|
|
43
|
+
}) => ({
|
|
44
|
+
name: "@modern-js/plugin-analyze",
|
|
45
|
+
setup: (api) => {
|
|
46
|
+
let pagesDir = [];
|
|
47
|
+
let nestedRouteEntries = [];
|
|
48
|
+
let originEntrypoints = [];
|
|
49
|
+
return {
|
|
50
|
+
async prepare() {
|
|
51
|
+
var _a;
|
|
52
|
+
let appContext = api.useAppContext();
|
|
53
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
54
|
+
const hookRunners = api.useHookRunners();
|
|
55
|
+
try {
|
|
56
|
+
import_utils.fs.emptydirSync(appContext.internalDirectory);
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
const apiOnly = await (0, import_utils.isApiOnly)(
|
|
60
|
+
appContext.appDirectory,
|
|
61
|
+
(_a = resolvedConfig.source) == null ? void 0 : _a.entriesDir
|
|
62
|
+
);
|
|
63
|
+
await hookRunners.addRuntimeExports();
|
|
64
|
+
if (apiOnly) {
|
|
65
|
+
const { routes: routes2 } = await hookRunners.modifyServerRoutes({
|
|
66
|
+
routes: []
|
|
67
|
+
});
|
|
68
|
+
debug(`server routes: %o`, routes2);
|
|
69
|
+
appContext = {
|
|
70
|
+
...appContext,
|
|
71
|
+
apiOnly,
|
|
72
|
+
serverRoutes: routes2
|
|
73
|
+
};
|
|
74
|
+
api.setAppContext(appContext);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const [
|
|
78
|
+
{ getBundleEntry },
|
|
79
|
+
{ getServerRoutes },
|
|
80
|
+
{ generateCode },
|
|
81
|
+
{ getHtmlTemplate }
|
|
82
|
+
] = await Promise.all([
|
|
83
|
+
Promise.resolve().then(() => __toESM(require("./getBundleEntry"))),
|
|
84
|
+
Promise.resolve().then(() => __toESM(require("./getServerRoutes"))),
|
|
85
|
+
Promise.resolve().then(() => __toESM(require("./generateCode"))),
|
|
86
|
+
Promise.resolve().then(() => __toESM(require("./getHtmlTemplate")))
|
|
87
|
+
]);
|
|
88
|
+
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
89
|
+
debug(`entrypoints: %o`, entrypoints);
|
|
90
|
+
const initialRoutes = getServerRoutes(entrypoints, {
|
|
91
|
+
appContext,
|
|
92
|
+
config: resolvedConfig
|
|
93
|
+
});
|
|
94
|
+
const { routes } = await hookRunners.modifyServerRoutes({
|
|
95
|
+
routes: initialRoutes
|
|
96
|
+
});
|
|
97
|
+
debug(`server routes: %o`, routes);
|
|
98
|
+
appContext = {
|
|
99
|
+
...appContext,
|
|
100
|
+
entrypoints,
|
|
101
|
+
serverRoutes: routes
|
|
102
|
+
};
|
|
103
|
+
api.setAppContext(appContext);
|
|
104
|
+
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
|
105
|
+
pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
|
|
106
|
+
originEntrypoints = (0, import_lodash.cloneDeep)(entrypoints);
|
|
107
|
+
await generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
108
|
+
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
|
109
|
+
appContext,
|
|
110
|
+
config: resolvedConfig
|
|
111
|
+
});
|
|
112
|
+
debug(`html templates: %o`, htmlTemplates);
|
|
113
|
+
await hookRunners.addDefineTypes();
|
|
114
|
+
debug(`add Define Types`);
|
|
115
|
+
let checkedEntries = entrypoints.map((point) => point.entryName);
|
|
116
|
+
if ((0, import_utils.isDevCommand)()) {
|
|
117
|
+
const { entry } = (0, import_utils.minimist)(process.argv.slice(2));
|
|
118
|
+
checkedEntries = await (0, import_getSelectedEntries.getSelectedEntries)(
|
|
119
|
+
typeof entry === "string" ? entry.split(",") : entry,
|
|
120
|
+
entrypoints
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
appContext = {
|
|
124
|
+
...appContext,
|
|
125
|
+
entrypoints,
|
|
126
|
+
checkedEntries,
|
|
127
|
+
apiOnly,
|
|
128
|
+
serverRoutes: routes,
|
|
129
|
+
htmlTemplates
|
|
130
|
+
};
|
|
131
|
+
api.setAppContext(appContext);
|
|
132
|
+
const command = (0, import_utils.getCommand)();
|
|
133
|
+
const buildCommands = ["dev", "start", "build", "inspect", "deploy"];
|
|
134
|
+
if (buildCommands.includes(command)) {
|
|
135
|
+
const normalizedConfig = api.useResolvedConfigContext();
|
|
136
|
+
const createBuilderForModern = await (0, import_builder.createBuilderGenerator)(bundler);
|
|
137
|
+
const builder = await createBuilderForModern({
|
|
138
|
+
normalizedConfig,
|
|
139
|
+
appContext,
|
|
140
|
+
async onBeforeBuild({ bundlerConfigs }) {
|
|
141
|
+
const hookRunners2 = api.useHookRunners();
|
|
142
|
+
await (0, import_routes.generateRoutes)(appContext);
|
|
143
|
+
await hookRunners2.beforeBuild({
|
|
144
|
+
bundlerConfigs
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
async onAfterBuild({ stats }) {
|
|
148
|
+
const hookRunners2 = api.useHookRunners();
|
|
149
|
+
await hookRunners2.afterBuild({ stats });
|
|
150
|
+
await (0, import_config.emitResolvedConfig)(
|
|
151
|
+
appContext.appDirectory,
|
|
152
|
+
normalizedConfig
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
async onDevCompileDone({ isFirstCompile }) {
|
|
156
|
+
const hookRunners2 = api.useHookRunners();
|
|
157
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
158
|
+
hookRunners2.afterDev();
|
|
159
|
+
if (isFirstCompile) {
|
|
160
|
+
(0, import_printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
async onBeforeCreateCompiler({ bundlerConfigs }) {
|
|
165
|
+
const hookRunners2 = api.useHookRunners();
|
|
166
|
+
await hookRunners2.beforeCreateCompiler({
|
|
167
|
+
bundlerConfigs
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
async onAfterCreateCompiler({ compiler }) {
|
|
171
|
+
const hookRunners2 = api.useHookRunners();
|
|
172
|
+
await hookRunners2.afterCreateCompiler({
|
|
173
|
+
compiler
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
178
|
+
appContext = {
|
|
179
|
+
...appContext,
|
|
180
|
+
builder
|
|
181
|
+
};
|
|
182
|
+
api.setAppContext(appContext);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
watchFiles() {
|
|
186
|
+
return pagesDir;
|
|
187
|
+
},
|
|
188
|
+
config() {
|
|
189
|
+
return {
|
|
190
|
+
tools: {
|
|
191
|
+
webpackChain: (chain, { name }) => {
|
|
192
|
+
const appContext = api.useAppContext();
|
|
193
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
194
|
+
const { entrypoints, internalDirectory, packageName } = appContext;
|
|
195
|
+
entrypoints.forEach((entrypoint) => {
|
|
196
|
+
const { entryName } = entrypoint;
|
|
197
|
+
const ssr = (0, import_utils.getEntryOptions)(
|
|
198
|
+
entryName,
|
|
199
|
+
resolvedConfig.server.ssr,
|
|
200
|
+
resolvedConfig.server.ssrByEntries,
|
|
201
|
+
packageName
|
|
202
|
+
);
|
|
203
|
+
if (entrypoint.nestedRoutesEntry && ssr && name === "server") {
|
|
204
|
+
const serverLoadersFile = (0, import_utils2.getServerLoadersFile)(
|
|
205
|
+
internalDirectory,
|
|
206
|
+
entryName
|
|
207
|
+
);
|
|
208
|
+
chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
resolvedConfig({ resolved }) {
|
|
216
|
+
const appContext = api.useAppContext();
|
|
217
|
+
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext, bundler);
|
|
218
|
+
return {
|
|
219
|
+
resolved: config
|
|
220
|
+
};
|
|
221
|
+
},
|
|
222
|
+
async modifyEntryImports({ entrypoint, imports }) {
|
|
223
|
+
const appContext = api.useAppContext();
|
|
224
|
+
const { srcDirectory, internalSrcAlias } = appContext;
|
|
225
|
+
const { fileSystemRoutes, nestedRoutesEntry } = entrypoint;
|
|
226
|
+
if (fileSystemRoutes && nestedRoutesEntry) {
|
|
227
|
+
const rootLayoutPath = path.join(nestedRoutesEntry, "layout");
|
|
228
|
+
const rootLayoutFile = (0, import_utils.findExists)(
|
|
229
|
+
[".js", ".ts", ".jsx", ".tsx"].map(
|
|
230
|
+
(ext) => `${rootLayoutPath}${ext}`
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
if (rootLayoutFile) {
|
|
234
|
+
const rootLayoutBuffer = await import_utils.fs.readFile(rootLayoutFile);
|
|
235
|
+
const rootLayout = rootLayoutBuffer.toString();
|
|
236
|
+
const [, moduleExports] = await (0, import_utils2.parseModule)({
|
|
237
|
+
source: rootLayout.toString(),
|
|
238
|
+
filename: rootLayoutFile
|
|
239
|
+
});
|
|
240
|
+
const hasAppConfig = moduleExports.some(
|
|
241
|
+
(e) => e.n === import_constants.APP_CONFIG_NAME
|
|
242
|
+
);
|
|
243
|
+
const generateLayoutPath = (0, import_utils2.replaceWithAlias)(
|
|
244
|
+
srcDirectory,
|
|
245
|
+
rootLayoutFile,
|
|
246
|
+
internalSrcAlias
|
|
247
|
+
);
|
|
248
|
+
if (hasAppConfig) {
|
|
249
|
+
imports.push({
|
|
250
|
+
value: generateLayoutPath,
|
|
251
|
+
specifiers: [{ imported: import_constants.APP_CONFIG_NAME }]
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const hasAppInit = moduleExports.some(
|
|
255
|
+
(e) => e.n === import_constants.APP_INIT_EXPORTED
|
|
256
|
+
);
|
|
257
|
+
if (hasAppInit) {
|
|
258
|
+
imports.push({
|
|
259
|
+
value: generateLayoutPath,
|
|
260
|
+
specifiers: [
|
|
261
|
+
{ imported: import_constants.APP_INIT_EXPORTED, local: import_constants.APP_INIT_IMPORTED }
|
|
262
|
+
]
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
entrypoint,
|
|
269
|
+
imports
|
|
270
|
+
};
|
|
271
|
+
},
|
|
272
|
+
async fileChange(e) {
|
|
273
|
+
const appContext = api.useAppContext();
|
|
274
|
+
const { appDirectory } = appContext;
|
|
275
|
+
const { filename, eventType } = e;
|
|
276
|
+
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
|
277
|
+
const absoluteFilePath = path.resolve(appDirectory, filename);
|
|
278
|
+
const isRouteComponent = isPageFile(absoluteFilePath) && (0, import_utils2.isPageComponentFile)(absoluteFilePath);
|
|
279
|
+
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
|
280
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
281
|
+
const { generateCode } = await Promise.resolve().then(() => __toESM(require("./generateCode")));
|
|
282
|
+
const entrypoints = (0, import_lodash.cloneDeep)(originEntrypoints);
|
|
283
|
+
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
290
|
+
0 && (module.exports = {});
|
|
File without changes
|
|
File without changes
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -38,26 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
21
|
mod
|
|
39
22
|
));
|
|
40
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
-
var __async = (__this, __arguments, generator) => {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
var fulfilled = (value) => {
|
|
44
|
-
try {
|
|
45
|
-
step(generator.next(value));
|
|
46
|
-
} catch (e) {
|
|
47
|
-
reject(e);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var rejected = (value) => {
|
|
51
|
-
try {
|
|
52
|
-
step(generator.throw(value));
|
|
53
|
-
} catch (e) {
|
|
54
|
-
reject(e);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
24
|
var nestedRoutes_exports = {};
|
|
62
25
|
__export(nestedRoutes_exports, {
|
|
63
26
|
walk: () => walk
|
|
@@ -73,10 +36,11 @@ const replaceDynamicPath = (routePath) => {
|
|
|
73
36
|
};
|
|
74
37
|
const createIndexRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
75
38
|
return createRoute(
|
|
76
|
-
|
|
39
|
+
{
|
|
40
|
+
...routeInfo,
|
|
77
41
|
index: true,
|
|
78
42
|
children: void 0
|
|
79
|
-
}
|
|
43
|
+
},
|
|
80
44
|
rootDir,
|
|
81
45
|
filename,
|
|
82
46
|
entryName
|
|
@@ -84,17 +48,18 @@ const createIndexRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
|
84
48
|
};
|
|
85
49
|
const createRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
86
50
|
const id = (0, import_utils.getRouteId)(filename, rootDir, entryName);
|
|
87
|
-
return
|
|
51
|
+
return {
|
|
52
|
+
...routeInfo,
|
|
88
53
|
id,
|
|
89
54
|
type: "nested"
|
|
90
|
-
}
|
|
55
|
+
};
|
|
91
56
|
};
|
|
92
|
-
const walk = (dirname, rootDir, alias, entryName) =>
|
|
57
|
+
const walk = async (dirname, rootDir, alias, entryName) => {
|
|
93
58
|
var _a, _b, _c, _d;
|
|
94
|
-
if (!
|
|
59
|
+
if (!await import_utils.fs.pathExists(dirname)) {
|
|
95
60
|
return null;
|
|
96
61
|
}
|
|
97
|
-
const isDirectory = (
|
|
62
|
+
const isDirectory = (await import_utils.fs.stat(dirname)).isDirectory();
|
|
98
63
|
if (!isDirectory) {
|
|
99
64
|
return null;
|
|
100
65
|
}
|
|
@@ -118,14 +83,14 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
118
83
|
let pageRoute = null;
|
|
119
84
|
let splatLoaderFile = "";
|
|
120
85
|
let splatRoute = null;
|
|
121
|
-
const items =
|
|
86
|
+
const items = await import_utils.fs.readdir(dirname);
|
|
122
87
|
for (const item of items) {
|
|
123
88
|
const itemPath = path.join(dirname, item);
|
|
124
89
|
const extname = path.extname(item);
|
|
125
90
|
const itemWithoutExt = item.slice(0, -extname.length);
|
|
126
|
-
const isDirectory2 = (
|
|
91
|
+
const isDirectory2 = (await import_utils.fs.stat(itemPath)).isDirectory();
|
|
127
92
|
if (isDirectory2) {
|
|
128
|
-
const childRoute =
|
|
93
|
+
const childRoute = await walk(itemPath, rootDir, alias, entryName);
|
|
129
94
|
if (childRoute) {
|
|
130
95
|
(_a = route.children) == null ? void 0 : _a.push(childRoute);
|
|
131
96
|
}
|
|
@@ -200,13 +165,14 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
200
165
|
const childRoute = finalRoute.children[0];
|
|
201
166
|
if (childRoute.path === "*") {
|
|
202
167
|
const path2 = `${finalRoute.path || ""}/${childRoute.path || ""}`;
|
|
203
|
-
finalRoute =
|
|
168
|
+
finalRoute = {
|
|
169
|
+
...childRoute,
|
|
204
170
|
path: path2
|
|
205
|
-
}
|
|
171
|
+
};
|
|
206
172
|
}
|
|
207
173
|
}
|
|
208
174
|
return finalRoute;
|
|
209
|
-
}
|
|
175
|
+
};
|
|
210
176
|
// Annotate the CommonJS export names for ESM import in node:
|
|
211
177
|
0 && (module.exports = {
|
|
212
178
|
walk
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -38,26 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
21
|
mod
|
|
39
22
|
));
|
|
40
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
-
var __async = (__this, __arguments, generator) => {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
var fulfilled = (value) => {
|
|
44
|
-
try {
|
|
45
|
-
step(generator.next(value));
|
|
46
|
-
} catch (e) {
|
|
47
|
-
reject(e);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var rejected = (value) => {
|
|
51
|
-
try {
|
|
52
|
-
step(generator.throw(value));
|
|
53
|
-
} catch (e) {
|
|
54
|
-
reject(e);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
24
|
var templates_exports = {};
|
|
62
25
|
__export(templates_exports, {
|
|
63
26
|
fileSystemRoutes: () => fileSystemRoutes,
|
|
@@ -99,6 +62,7 @@ const renderFunction = ({
|
|
|
99
62
|
customBootstrap,
|
|
100
63
|
fileSystemRoutes: fileSystemRoutes2
|
|
101
64
|
}) => {
|
|
65
|
+
const bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
|
|
102
66
|
return `
|
|
103
67
|
const finalAppConfig = {
|
|
104
68
|
...App.config,
|
|
@@ -120,7 +84,7 @@ const renderFunction = ({
|
|
|
120
84
|
|
|
121
85
|
|
|
122
86
|
if (IS_BROWSER) {
|
|
123
|
-
${customBootstrap ? `customBootstrap(AppWrapper);` :
|
|
87
|
+
${customBootstrap ? `customBootstrap(AppWrapper, () => ${bootstrap});` : `${bootstrap};`}
|
|
124
88
|
}
|
|
125
89
|
|
|
126
90
|
return AppWrapper
|
|
@@ -173,10 +137,11 @@ const routesForServer = ({
|
|
|
173
137
|
loader = `loader_${loaders.length - 1}`;
|
|
174
138
|
}
|
|
175
139
|
}
|
|
176
|
-
const finalRoute =
|
|
140
|
+
const finalRoute = {
|
|
141
|
+
...route,
|
|
177
142
|
loader,
|
|
178
143
|
children
|
|
179
|
-
}
|
|
144
|
+
};
|
|
180
145
|
return finalRoute;
|
|
181
146
|
};
|
|
182
147
|
let routesCode = `
|
|
@@ -206,13 +171,13 @@ const routesForServer = ({
|
|
|
206
171
|
${routesCode}
|
|
207
172
|
`;
|
|
208
173
|
};
|
|
209
|
-
const fileSystemRoutes =
|
|
174
|
+
const fileSystemRoutes = async ({
|
|
210
175
|
routes,
|
|
211
176
|
ssrMode,
|
|
212
177
|
nestedRoutesEntry,
|
|
213
178
|
entryName,
|
|
214
179
|
internalDirectory
|
|
215
|
-
}) {
|
|
180
|
+
}) => {
|
|
216
181
|
const loadings = [];
|
|
217
182
|
const errors = [];
|
|
218
183
|
const loaders = [];
|
|
@@ -286,13 +251,14 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
286
251
|
lazyImport = `() => import('${route._component}')`;
|
|
287
252
|
component = `loadable(${lazyImport})`;
|
|
288
253
|
}
|
|
289
|
-
const finalRoute =
|
|
254
|
+
const finalRoute = {
|
|
255
|
+
...route,
|
|
290
256
|
lazyImport,
|
|
291
257
|
loading,
|
|
292
258
|
loader,
|
|
293
259
|
error,
|
|
294
260
|
children
|
|
295
|
-
}
|
|
261
|
+
};
|
|
296
262
|
if (route._component) {
|
|
297
263
|
finalRoute.component = component;
|
|
298
264
|
}
|
|
@@ -307,9 +273,10 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
307
273
|
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, '"')},`;
|
|
308
274
|
} else {
|
|
309
275
|
const component = `loadable(() => import('${route._component}'))`;
|
|
310
|
-
const finalRoute =
|
|
276
|
+
const finalRoute = {
|
|
277
|
+
...route,
|
|
311
278
|
component
|
|
312
|
-
}
|
|
279
|
+
};
|
|
313
280
|
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, "$1").replace(/"(lazy[^"]*)"/g, "$1")},`;
|
|
314
281
|
}
|
|
315
282
|
}
|
|
@@ -337,8 +304,8 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
337
304
|
`;
|
|
338
305
|
}
|
|
339
306
|
}
|
|
340
|
-
|
|
341
|
-
|
|
307
|
+
await import_utils.fs.ensureFile(loadersMapFile);
|
|
308
|
+
await import_utils.fs.writeJSON(loadersMapFile, loadersMap);
|
|
342
309
|
return `
|
|
343
310
|
${importLazyCode}
|
|
344
311
|
${rootLayoutCode}
|
|
@@ -347,7 +314,7 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
347
314
|
${importLoadersCode}
|
|
348
315
|
${routeComponentsCode}
|
|
349
316
|
`;
|
|
350
|
-
}
|
|
317
|
+
};
|
|
351
318
|
// Annotate the CommonJS export names for ESM import in node:
|
|
352
319
|
0 && (module.exports = {
|
|
353
320
|
fileSystemRoutes,
|