@modern-js/app-tools 2.35.1 → 2.35.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analyze/constants.js +68 -75
- package/dist/cjs/analyze/generateCode.js +74 -57
- package/dist/cjs/analyze/getBundleEntry.js +53 -27
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +63 -37
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +63 -37
- package/dist/cjs/analyze/getClientRoutes/index.js +27 -17
- package/dist/cjs/analyze/getClientRoutes/utils.js +47 -30
- package/dist/cjs/analyze/getFileSystemEntry.js +58 -32
- package/dist/cjs/analyze/getHtmlTemplate.js +45 -20
- package/dist/cjs/analyze/getServerRoutes.js +55 -29
- package/dist/cjs/analyze/index.js +77 -55
- package/dist/cjs/analyze/isDefaultExportFunction.js +42 -17
- package/dist/cjs/analyze/makeLegalIdentifier.js +24 -7
- package/dist/cjs/analyze/nestedRoutes.js +108 -65
- package/dist/cjs/analyze/templates.js +135 -53
- package/dist/cjs/analyze/utils.js +101 -67
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +46 -20
- package/dist/cjs/builder/builder-rspack/index.js +29 -12
- package/dist/cjs/builder/builder-webpack/adapterModern.js +28 -11
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +30 -20
- package/dist/cjs/builder/builder-webpack/index.js +40 -14
- package/dist/cjs/builder/generator/createBuilderOptions.js +24 -7
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +26 -9
- package/dist/cjs/builder/generator/getBuilderTargets.js +27 -10
- package/dist/cjs/builder/generator/index.js +44 -18
- package/dist/cjs/builder/index.js +39 -13
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +34 -7
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +36 -19
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +47 -21
- package/dist/cjs/builder/shared/builderPlugins/index.js +24 -6
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -10
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +29 -12
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +42 -25
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +24 -6
- package/dist/cjs/builder/shared/createCopyInfo.js +38 -12
- package/dist/cjs/builder/shared/index.js +24 -6
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +21 -8
- package/dist/cjs/builder/shared/types.js +15 -3
- package/dist/cjs/commands/build.js +33 -16
- package/dist/cjs/commands/deploy.js +24 -7
- package/dist/cjs/commands/dev.js +40 -23
- package/dist/cjs/commands/index.js +24 -6
- package/dist/cjs/commands/inspect.js +26 -9
- package/dist/cjs/commands/serve.js +48 -22
- package/dist/cjs/config/default.js +33 -23
- package/dist/cjs/config/index.js +24 -6
- package/dist/cjs/config/initialize/index.js +27 -10
- package/dist/cjs/config/initialize/inits.js +44 -25
- package/dist/cjs/config/legacy/createHtmlConfig.js +24 -7
- package/dist/cjs/config/legacy/createOutputConfig.js +24 -7
- package/dist/cjs/config/legacy/createSourceConfig.js +24 -7
- package/dist/cjs/config/legacy/createToolsConfig.js +24 -7
- package/dist/cjs/config/legacy/index.js +34 -23
- package/dist/cjs/defineConfig.js +25 -15
- package/dist/cjs/exports/server.js +25 -8
- package/dist/cjs/hooks.js +50 -33
- package/dist/cjs/index.js +95 -80
- package/dist/cjs/initialize/index.js +30 -17
- package/dist/cjs/locale/en.js +24 -7
- package/dist/cjs/locale/index.js +31 -21
- package/dist/cjs/locale/zh.js +24 -7
- package/dist/cjs/schema/Schema.js +28 -11
- package/dist/cjs/schema/index.js +40 -21
- package/dist/cjs/schema/legacy.js +30 -17
- package/dist/cjs/types/config/deploy.js +15 -3
- package/dist/cjs/types/config/dev.js +15 -3
- package/dist/cjs/types/config/experiments.js +15 -3
- package/dist/cjs/types/config/html.js +15 -3
- package/dist/cjs/types/config/index.js +20 -4
- package/dist/cjs/types/config/output.js +15 -3
- package/dist/cjs/types/config/performance.js +15 -3
- package/dist/cjs/types/config/security.js +15 -3
- package/dist/cjs/types/config/source.js +15 -3
- package/dist/cjs/types/config/testing.js +15 -3
- package/dist/cjs/types/config/tools.js +15 -3
- package/dist/cjs/types/hooks.js +15 -3
- package/dist/cjs/types/index.js +24 -6
- package/dist/cjs/types/legacyConfig/deploy.js +15 -3
- package/dist/cjs/types/legacyConfig/dev.js +15 -3
- package/dist/cjs/types/legacyConfig/index.js +15 -3
- package/dist/cjs/types/legacyConfig/output.js +15 -3
- package/dist/cjs/types/legacyConfig/source.js +15 -3
- package/dist/cjs/types/legacyConfig/testing.js +15 -3
- package/dist/cjs/types/legacyConfig/tools.js +15 -3
- package/dist/cjs/types/utils.js +15 -3
- package/dist/cjs/utils/config.js +50 -33
- package/dist/cjs/utils/createServer.js +43 -26
- package/dist/cjs/utils/env.js +26 -9
- package/dist/cjs/utils/generateWatchFiles.js +41 -22
- package/dist/cjs/utils/getSelectedEntries.js +30 -13
- package/dist/cjs/utils/getServerInternalPlugins.js +24 -7
- package/dist/cjs/utils/printInstructions.js +27 -10
- package/dist/cjs/utils/restart.js +30 -13
- package/dist/cjs/utils/routes.js +37 -11
- package/dist/cjs/utils/types.js +15 -3
- package/dist/esm/analyze/constants.js +48 -22
- package/dist/esm/analyze/generateCode.js +38 -33
- package/dist/esm/analyze/getBundleEntry.js +4 -1
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +12 -9
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +12 -9
- package/dist/esm/analyze/getClientRoutes/index.js +6 -2
- package/dist/esm/analyze/getClientRoutes/utils.js +9 -4
- package/dist/esm/analyze/getFileSystemEntry.js +10 -7
- package/dist/esm/analyze/getHtmlTemplate.js +7 -4
- package/dist/esm/analyze/getServerRoutes.js +8 -5
- package/dist/esm/analyze/index.js +27 -24
- package/dist/esm/analyze/isDefaultExportFunction.js +4 -1
- package/dist/esm/analyze/makeLegalIdentifier.js +4 -1
- package/dist/esm/analyze/nestedRoutes.js +90 -30
- package/dist/esm/analyze/templates.js +121 -30
- package/dist/esm/analyze/utils.js +103 -18
- package/dist/esm/builder/builder-rspack/adapterCopy.js +4 -1
- package/dist/esm/builder/builder-rspack/index.js +4 -1
- package/dist/esm/builder/builder-webpack/adapterModern.js +4 -1
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +8 -4
- package/dist/esm/builder/builder-webpack/index.js +4 -1
- package/dist/esm/builder/generator/createBuilderOptions.js +5 -2
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +4 -1
- package/dist/esm/builder/generator/getBuilderTargets.js +4 -1
- package/dist/esm/builder/generator/index.js +5 -2
- package/dist/esm/builder/index.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +11 -8
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +10 -7
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +4 -1
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +4 -1
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +7 -4
- package/dist/esm/builder/shared/createCopyInfo.js +7 -4
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +4 -1
- package/dist/esm/builder/shared/types.js +0 -1
- package/dist/esm/commands/build.js +6 -3
- package/dist/esm/commands/deploy.js +4 -1
- package/dist/esm/commands/dev.js +12 -9
- package/dist/esm/commands/inspect.js +4 -1
- package/dist/esm/commands/serve.js +7 -4
- package/dist/esm/config/default.js +12 -8
- package/dist/esm/config/initialize/index.js +4 -1
- package/dist/esm/config/initialize/inits.js +6 -2
- package/dist/esm/config/legacy/createHtmlConfig.js +17 -14
- package/dist/esm/config/legacy/createOutputConfig.js +19 -16
- package/dist/esm/config/legacy/createSourceConfig.js +14 -11
- package/dist/esm/config/legacy/createToolsConfig.js +18 -15
- package/dist/esm/config/legacy/index.js +21 -16
- package/dist/esm/defineConfig.js +6 -2
- package/dist/esm/exports/server.js +4 -1
- package/dist/esm/hooks.js +4 -1
- package/dist/esm/index.js +19 -11
- package/dist/esm/initialize/index.js +9 -6
- package/dist/esm/locale/en.js +4 -1
- package/dist/esm/locale/index.js +4 -1
- package/dist/esm/locale/zh.js +4 -1
- package/dist/esm/schema/Schema.js +6 -3
- package/dist/esm/schema/index.js +5 -2
- package/dist/esm/schema/legacy.js +4 -1
- package/dist/esm/types/config/deploy.js +0 -1
- package/dist/esm/types/config/dev.js +0 -1
- package/dist/esm/types/config/experiments.js +0 -1
- package/dist/esm/types/config/html.js +0 -1
- package/dist/esm/types/config/output.js +0 -1
- package/dist/esm/types/config/performance.js +0 -1
- package/dist/esm/types/config/security.js +0 -1
- package/dist/esm/types/config/source.js +0 -1
- package/dist/esm/types/config/testing.js +0 -1
- package/dist/esm/types/config/tools.js +0 -1
- package/dist/esm/types/hooks.js +0 -1
- package/dist/esm/types/legacyConfig/deploy.js +0 -1
- package/dist/esm/types/legacyConfig/dev.js +0 -1
- package/dist/esm/types/legacyConfig/index.js +0 -1
- package/dist/esm/types/legacyConfig/output.js +0 -1
- package/dist/esm/types/legacyConfig/source.js +0 -1
- package/dist/esm/types/legacyConfig/testing.js +0 -1
- package/dist/esm/types/legacyConfig/tools.js +0 -1
- package/dist/esm/types/utils.js +0 -1
- package/dist/esm/utils/config.js +12 -6
- package/dist/esm/utils/createServer.js +12 -5
- package/dist/esm/utils/env.js +4 -1
- package/dist/esm/utils/generateWatchFiles.js +6 -2
- package/dist/esm/utils/getSelectedEntries.js +4 -1
- package/dist/esm/utils/getServerInternalPlugins.js +5 -2
- package/dist/esm/utils/printInstructions.js +4 -1
- package/dist/esm/utils/restart.js +4 -1
- package/dist/esm/utils/routes.js +3 -1
- package/dist/esm/utils/types.js +0 -1
- package/dist/esm-node/analyze/constants.js +48 -22
- package/dist/esm-node/analyze/generateCode.js +8 -3
- package/dist/esm-node/analyze/getBundleEntry.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/index.js +6 -2
- package/dist/esm-node/analyze/getClientRoutes/utils.js +9 -4
- package/dist/esm-node/analyze/getFileSystemEntry.js +4 -1
- package/dist/esm-node/analyze/getHtmlTemplate.js +4 -1
- package/dist/esm-node/analyze/getServerRoutes.js +4 -1
- package/dist/esm-node/analyze/index.js +4 -1
- package/dist/esm-node/analyze/isDefaultExportFunction.js +4 -1
- package/dist/esm-node/analyze/makeLegalIdentifier.js +4 -1
- package/dist/esm-node/analyze/nestedRoutes.js +39 -9
- package/dist/esm-node/analyze/templates.js +93 -18
- package/dist/esm-node/analyze/utils.js +48 -16
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +4 -1
- package/dist/esm-node/builder/builder-rspack/index.js +4 -1
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +4 -1
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +6 -2
- package/dist/esm-node/builder/builder-webpack/index.js +4 -1
- package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -1
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +4 -1
- package/dist/esm-node/builder/generator/getBuilderTargets.js +4 -1
- package/dist/esm-node/builder/generator/index.js +4 -1
- package/dist/esm-node/builder/index.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +4 -1
- package/dist/esm-node/builder/shared/createCopyInfo.js +4 -1
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +4 -1
- package/dist/esm-node/builder/shared/types.js +0 -1
- package/dist/esm-node/commands/build.js +4 -1
- package/dist/esm-node/commands/deploy.js +4 -1
- package/dist/esm-node/commands/dev.js +4 -1
- package/dist/esm-node/commands/inspect.js +4 -1
- package/dist/esm-node/commands/serve.js +4 -1
- package/dist/esm-node/config/default.js +6 -2
- package/dist/esm-node/config/initialize/index.js +4 -1
- package/dist/esm-node/config/initialize/inits.js +6 -2
- package/dist/esm-node/config/legacy/createHtmlConfig.js +4 -1
- package/dist/esm-node/config/legacy/createOutputConfig.js +4 -1
- package/dist/esm-node/config/legacy/createSourceConfig.js +4 -1
- package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm-node/config/legacy/index.js +7 -2
- package/dist/esm-node/defineConfig.js +6 -2
- package/dist/esm-node/exports/server.js +4 -1
- package/dist/esm-node/hooks.js +4 -1
- package/dist/esm-node/index.js +14 -6
- package/dist/esm-node/initialize/index.js +4 -1
- package/dist/esm-node/locale/en.js +4 -1
- package/dist/esm-node/locale/index.js +4 -1
- package/dist/esm-node/locale/zh.js +4 -1
- package/dist/esm-node/schema/Schema.js +4 -1
- package/dist/esm-node/schema/index.js +5 -2
- package/dist/esm-node/schema/legacy.js +4 -1
- package/dist/esm-node/types/config/deploy.js +0 -1
- package/dist/esm-node/types/config/dev.js +0 -1
- package/dist/esm-node/types/config/experiments.js +0 -1
- package/dist/esm-node/types/config/html.js +0 -1
- package/dist/esm-node/types/config/output.js +0 -1
- package/dist/esm-node/types/config/performance.js +0 -1
- package/dist/esm-node/types/config/security.js +0 -1
- package/dist/esm-node/types/config/source.js +0 -1
- package/dist/esm-node/types/config/testing.js +0 -1
- package/dist/esm-node/types/config/tools.js +0 -1
- package/dist/esm-node/types/hooks.js +0 -1
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -1
- package/dist/esm-node/types/legacyConfig/dev.js +0 -1
- package/dist/esm-node/types/legacyConfig/index.js +0 -1
- package/dist/esm-node/types/legacyConfig/output.js +0 -1
- package/dist/esm-node/types/legacyConfig/source.js +0 -1
- package/dist/esm-node/types/legacyConfig/testing.js +0 -1
- package/dist/esm-node/types/legacyConfig/tools.js +0 -1
- package/dist/esm-node/types/utils.js +0 -1
- package/dist/esm-node/utils/config.js +10 -4
- package/dist/esm-node/utils/createServer.js +12 -5
- package/dist/esm-node/utils/env.js +4 -1
- package/dist/esm-node/utils/generateWatchFiles.js +6 -2
- package/dist/esm-node/utils/getSelectedEntries.js +4 -1
- package/dist/esm-node/utils/getServerInternalPlugins.js +4 -1
- package/dist/esm-node/utils/printInstructions.js +4 -1
- package/dist/esm-node/utils/restart.js +4 -1
- package/dist/esm-node/utils/routes.js +3 -1
- package/dist/esm-node/utils/types.js +0 -1
- package/dist/js/modern/analyze/constants.js +54 -0
- package/dist/js/modern/analyze/generateCode.js +247 -0
- package/dist/js/modern/analyze/getBundleEntry.js +71 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
- package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +109 -0
- package/dist/js/modern/analyze/getHtmlTemplate.js +115 -0
- package/dist/js/modern/analyze/getServerRoutes.js +175 -0
- package/dist/js/modern/analyze/index.js +332 -0
- package/dist/js/modern/analyze/isDefaultExportFunction.js +42 -0
- package/dist/js/modern/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/modern/analyze/nestedRoutes.js +157 -0
- package/dist/js/modern/analyze/templates.js +334 -0
- package/dist/js/modern/analyze/utils.js +141 -0
- package/dist/js/modern/builder/builderPlugins/compatModern.js +233 -0
- package/dist/js/modern/builder/index.js +159 -0
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/share.js +46 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
- package/dist/js/modern/commands/build.js +91 -0
- package/dist/js/modern/commands/deploy.js +28 -0
- package/dist/js/modern/commands/dev.js +109 -0
- package/dist/js/modern/commands/index.js +3 -0
- package/dist/js/modern/commands/inspect.js +38 -0
- package/dist/js/modern/commands/serve.js +54 -0
- package/dist/js/modern/config/default.js +175 -0
- package/dist/js/modern/config/index.js +8 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
- package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
- package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
- package/dist/js/modern/config/initial/index.js +16 -0
- package/dist/js/modern/config/initial/inits.js +152 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
- package/dist/js/modern/defineConfig.js +27 -0
- package/dist/js/modern/exports/server.js +4 -0
- package/dist/js/modern/hooks.js +35 -0
- package/dist/js/modern/index.js +211 -0
- package/dist/js/modern/initialize/index.js +124 -0
- package/dist/js/modern/locale/en.js +36 -0
- package/dist/js/modern/locale/index.js +9 -0
- package/dist/js/modern/locale/zh.js +36 -0
- package/dist/js/modern/schema/Schema.js +40 -0
- package/dist/js/modern/schema/index.js +88 -0
- package/dist/js/modern/schema/legacy.js +148 -0
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +1 -0
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +3 -0
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +0 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/utils/config.js +128 -0
- package/dist/js/modern/utils/createServer.js +75 -0
- package/dist/js/modern/utils/env.js +15 -0
- package/dist/js/modern/utils/generateWatchFiles.js +55 -0
- package/dist/js/modern/utils/getSelectedEntries.js +58 -0
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/modern/utils/language.js +8 -0
- package/dist/js/modern/utils/printInstructions.js +31 -0
- package/dist/js/modern/utils/restart.js +44 -0
- package/dist/js/modern/utils/routes.js +30 -0
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +98 -0
- package/dist/js/node/analyze/generateCode.js +271 -0
- package/dist/js/node/analyze/getBundleEntry.js +95 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
- package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +131 -0
- package/dist/js/node/analyze/getHtmlTemplate.js +144 -0
- package/dist/js/node/analyze/getServerRoutes.js +194 -0
- package/dist/js/node/analyze/index.js +339 -0
- package/dist/js/node/analyze/isDefaultExportFunction.js +71 -0
- package/dist/js/node/analyze/makeLegalIdentifier.js +36 -0
- package/dist/js/node/analyze/nestedRoutes.js +184 -0
- package/dist/js/node/analyze/templates.js +365 -0
- package/dist/js/node/analyze/utils.js +172 -0
- package/dist/js/node/builder/builderPlugins/compatModern.js +258 -0
- package/dist/js/node/builder/index.js +177 -0
- package/dist/js/node/builder/loaders/routerLoader.js +38 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
- package/dist/js/node/builder/share.js +75 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
- package/dist/js/node/commands/build.js +112 -0
- package/dist/js/node/commands/deploy.js +51 -0
- package/dist/js/node/commands/dev.js +126 -0
- package/dist/js/node/commands/index.js +19 -0
- package/dist/js/node/commands/inspect.js +61 -0
- package/dist/js/node/commands/serve.js +83 -0
- package/dist/js/node/config/default.js +197 -0
- package/dist/js/node/config/index.js +34 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
- package/dist/js/node/config/initial/createOutputConfig.js +91 -0
- package/dist/js/node/config/initial/createSourceConfig.js +62 -0
- package/dist/js/node/config/initial/createToolsConfig.js +65 -0
- package/dist/js/node/config/initial/index.js +41 -0
- package/dist/js/node/config/initial/inits.js +175 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
- package/dist/js/node/defineConfig.js +49 -0
- package/dist/js/node/exports/server.js +27 -0
- package/dist/js/node/hooks.js +54 -0
- package/dist/js/node/index.js +235 -0
- package/dist/js/node/initialize/index.js +134 -0
- package/dist/js/node/locale/en.js +59 -0
- package/dist/js/node/locale/index.js +33 -0
- package/dist/js/node/locale/zh.js +59 -0
- package/dist/js/node/schema/Schema.js +63 -0
- package/dist/js/node/schema/index.js +118 -0
- package/dist/js/node/schema/legacy.js +169 -0
- package/dist/js/node/types/config/deploy.js +15 -0
- package/dist/js/node/types/config/dev.js +15 -0
- package/dist/js/node/types/config/experiments.js +15 -0
- package/dist/js/node/types/config/html.js +15 -0
- package/dist/js/node/types/config/index.js +17 -0
- package/dist/js/node/types/config/output.js +15 -0
- package/dist/js/node/types/config/performance.js +15 -0
- package/dist/js/node/types/config/security.js +15 -0
- package/dist/js/node/types/config/source.js +15 -0
- package/dist/js/node/types/config/tools.js +15 -0
- package/dist/js/node/types/hooks.js +15 -0
- package/dist/js/node/types/index.js +19 -0
- package/dist/js/node/types/legacyConfig/deploy.js +15 -0
- package/dist/js/node/types/legacyConfig/dev.js +15 -0
- package/dist/js/node/types/legacyConfig/index.js +15 -0
- package/dist/js/node/types/legacyConfig/output.js +15 -0
- package/dist/js/node/types/legacyConfig/source.js +15 -0
- package/dist/js/node/types/legacyConfig/tools.js +15 -0
- package/dist/js/node/utils/config.js +153 -0
- package/dist/js/node/utils/createServer.js +106 -0
- package/dist/js/node/utils/env.js +38 -0
- package/dist/js/node/utils/generateWatchFiles.js +85 -0
- package/dist/js/node/utils/getSelectedEntries.js +81 -0
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/language.js +31 -0
- package/dist/js/node/utils/printInstructions.js +54 -0
- package/dist/js/node/utils/restart.js +67 -0
- package/dist/js/node/utils/routes.js +59 -0
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/constants.js +40 -0
- package/dist/js/treeshaking/analyze/generateCode.js +485 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +62 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
- package/dist/js/treeshaking/analyze/index.js +697 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +384 -0
- package/dist/js/treeshaking/analyze/templates.js +468 -0
- package/dist/js/treeshaking/analyze/utils.js +374 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +304 -0
- package/dist/js/treeshaking/builder/index.js +374 -0
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/share.js +40 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +343 -0
- package/dist/js/treeshaking/commands/build.js +291 -0
- package/dist/js/treeshaking/commands/deploy.js +154 -0
- package/dist/js/treeshaking/commands/dev.js +301 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +149 -0
- package/dist/js/treeshaking/commands/serve.js +199 -0
- package/dist/js/treeshaking/config/default.js +210 -0
- package/dist/js/treeshaking/config/index.js +3 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
- package/dist/js/treeshaking/config/initial/index.js +12 -0
- package/dist/js/treeshaking/config/initial/inits.js +209 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
- package/dist/js/treeshaking/defineConfig.js +61 -0
- package/dist/js/treeshaking/exports/server.js +2 -0
- package/dist/js/treeshaking/hooks.js +29 -0
- package/dist/js/treeshaking/index.js +706 -0
- package/dist/js/treeshaking/initialize/index.js +276 -0
- package/dist/js/treeshaking/locale/en.js +38 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +38 -0
- package/dist/js/treeshaking/schema/Schema.js +273 -0
- package/dist/js/treeshaking/schema/index.js +181 -0
- package/dist/js/treeshaking/schema/legacy.js +337 -0
- package/dist/js/treeshaking/types/config/deploy.js +1 -0
- package/dist/js/treeshaking/types/config/dev.js +1 -0
- package/dist/js/treeshaking/types/config/experiments.js +1 -0
- package/dist/js/treeshaking/types/config/html.js +1 -0
- package/dist/js/treeshaking/types/config/index.js +1 -0
- package/dist/js/treeshaking/types/config/output.js +1 -0
- package/dist/js/treeshaking/types/config/performance.js +1 -0
- package/dist/js/treeshaking/types/config/security.js +1 -0
- package/dist/js/treeshaking/types/config/source.js +1 -0
- package/dist/js/treeshaking/types/config/tools.js +1 -0
- package/dist/js/treeshaking/types/hooks.js +1 -0
- package/dist/js/treeshaking/types/index.js +3 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
- package/dist/js/treeshaking/utils/config.js +302 -0
- package/dist/js/treeshaking/utils/createServer.js +258 -0
- package/dist/js/treeshaking/utils/env.js +13 -0
- package/dist/js/treeshaking/utils/generateWatchFiles.js +214 -0
- package/dist/js/treeshaking/utils/getSelectedEntries.js +186 -0
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/js/treeshaking/utils/language.js +6 -0
- package/dist/js/treeshaking/utils/printInstructions.js +152 -0
- package/dist/js/treeshaking/utils/restart.js +187 -0
- package/dist/js/treeshaking/utils/routes.js +153 -0
- package/dist/js/treeshaking/utils/types.js +1 -0
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/types/config/index.d.ts +3 -2
- package/package.json +12 -12
@@ -1,40 +1,62 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var getRoutes_exports = {};
|
30
|
+
__export(getRoutes_exports, {
|
31
|
+
getClientRoutes: () => getClientRoutes
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
33
|
+
module.exports = __toCommonJS(getRoutes_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
var import_makeLegalIdentifier = require("../makeLegalIdentifier");
|
37
|
+
var import_constants = require("../constants");
|
38
|
+
var import_utils2 = require("../utils");
|
39
|
+
var import_utils3 = require("./utils");
|
18
40
|
const compName = (srcDirectory, filePath) => {
|
19
|
-
const legalCompName = (0,
|
41
|
+
const legalCompName = (0, import_makeLegalIdentifier.makeLegalIdentifier)(import_path.default.relative(srcDirectory, filePath));
|
20
42
|
return `Comp_${legalCompName}`;
|
21
43
|
};
|
22
44
|
const layoutNameAbbr = (filePath) => {
|
23
45
|
const prefix = "L_";
|
24
|
-
const dirName =
|
25
|
-
return `${prefix}${(0,
|
46
|
+
const dirName = import_path.default.dirname(filePath).split("/").pop() || "";
|
47
|
+
return `${prefix}${(0, import_makeLegalIdentifier.makeLegalIdentifier)(dirName)}`;
|
26
48
|
};
|
27
49
|
const parents = [];
|
28
50
|
const recursiveReadDir = ({ dir, routes, basePath = "/", srcDirectory, srcAlias }) => {
|
29
51
|
let hasDynamicRoute = false;
|
30
52
|
let resetParent = false;
|
31
53
|
let parent = parents[parents.length - 1];
|
32
|
-
const layout = (0,
|
54
|
+
const layout = (0, import_utils3.findLayout)(dir);
|
33
55
|
if (layout) {
|
34
56
|
if (basePath === "/") {
|
35
57
|
throw new Error(`should use _app instead of _layout in ${dir}`);
|
36
58
|
} else {
|
37
|
-
const alias = (0,
|
59
|
+
const alias = (0, import_utils2.replaceWithAlias)(srcDirectory, layout, srcAlias);
|
38
60
|
const componentName = compName(srcDirectory, layout);
|
39
61
|
const route = {
|
40
62
|
path: `${basePath.substring(0, basePath.length - 1)}`,
|
@@ -51,13 +73,13 @@ const recursiveReadDir = ({ dir, routes, basePath = "/", srcDirectory, srcAlias
|
|
51
73
|
routes = route.children;
|
52
74
|
}
|
53
75
|
}
|
54
|
-
for (const relative of
|
55
|
-
const filePath =
|
56
|
-
if (!(0,
|
57
|
-
const filename =
|
58
|
-
const alias = (0,
|
76
|
+
for (const relative of import_utils.fs.readdirSync(dir)) {
|
77
|
+
const filePath = import_path.default.join(dir, relative);
|
78
|
+
if (!(0, import_utils3.shouldSkip)(filePath)) {
|
79
|
+
const filename = import_path.default.basename(filePath, import_path.default.extname(filePath));
|
80
|
+
const alias = (0, import_utils2.replaceWithAlias)(srcDirectory, filePath, srcAlias);
|
59
81
|
const componentName = compName(srcDirectory, filePath);
|
60
|
-
const dynamicRouteMatched =
|
82
|
+
const dynamicRouteMatched = import_constants.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP.exec(filename);
|
61
83
|
if (dynamicRouteMatched) {
|
62
84
|
if (hasDynamicRoute) {
|
63
85
|
throw new Error(`Can't set two dynamic route in one directory: ${dir}`);
|
@@ -72,7 +94,7 @@ const recursiveReadDir = ({ dir, routes, basePath = "/", srcDirectory, srcAlias
|
|
72
94
|
parent,
|
73
95
|
type: "page"
|
74
96
|
};
|
75
|
-
if (
|
97
|
+
if (import_utils.fs.statSync(filePath).isDirectory()) {
|
76
98
|
recursiveReadDir({
|
77
99
|
dir: filePath,
|
78
100
|
routes,
|
@@ -82,10 +104,10 @@ const recursiveReadDir = ({ dir, routes, basePath = "/", srcDirectory, srcAlias
|
|
82
104
|
});
|
83
105
|
continue;
|
84
106
|
}
|
85
|
-
if (filename ===
|
107
|
+
if (filename === import_constants.FILE_SYSTEM_ROUTES_LAYOUT) {
|
86
108
|
continue;
|
87
109
|
}
|
88
|
-
if (filename ===
|
110
|
+
if (filename === import_constants.FILE_SYSTEM_ROUTES_INDEX) {
|
89
111
|
route.path = basePath === "/" ? basePath : `${basePath.substring(0, basePath.length - 1)}`;
|
90
112
|
}
|
91
113
|
if (filename === "404" && basePath === "/") {
|
@@ -117,13 +139,13 @@ const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory,
|
|
117
139
|
codes.push(`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`);
|
118
140
|
lastComponent = currentComponent;
|
119
141
|
}
|
120
|
-
const file =
|
121
|
-
|
142
|
+
const file = import_path.default.resolve(internalComponentsDir, `${lastComponent}.jsx`);
|
143
|
+
import_utils.fs.outputFileSync(file, `${imports.join("\n")}
|
122
144
|
${codes.join("\n")}
|
123
145
|
export default ${lastComponent}`);
|
124
146
|
return {
|
125
147
|
component: lastComponent,
|
126
|
-
_component: (0,
|
148
|
+
_component: (0, import_utils2.replaceWithAlias)(internalDirectory, file, internalDirAlias)
|
127
149
|
};
|
128
150
|
};
|
129
151
|
const normalized = flat(nested).map((route) => route.parent ? {
|
@@ -141,10 +163,10 @@ const getClientRoutes = ({ entrypoint, srcDirectory, srcAlias, internalDirectory
|
|
141
163
|
if (!pageRoutesEntry) {
|
142
164
|
return [];
|
143
165
|
}
|
144
|
-
if (!
|
166
|
+
if (!import_utils.fs.existsSync(pageRoutesEntry)) {
|
145
167
|
throw new Error(`generate file system routes error, ${pageRoutesEntry} directory not found.`);
|
146
168
|
}
|
147
|
-
if (!(
|
169
|
+
if (!(import_utils.fs.existsSync(pageRoutesEntry) && import_utils.fs.statSync(pageRoutesEntry).isDirectory())) {
|
148
170
|
throw new Error(`generate file system routes error, ${pageRoutesEntry} should be directory.`);
|
149
171
|
}
|
150
172
|
let routes = [];
|
@@ -155,17 +177,21 @@ const getClientRoutes = ({ entrypoint, srcDirectory, srcAlias, internalDirectory
|
|
155
177
|
srcDirectory,
|
156
178
|
srcAlias
|
157
179
|
});
|
158
|
-
const internalComponentsDir =
|
159
|
-
|
180
|
+
const internalComponentsDir = import_path.default.resolve(internalDirectory, `${entryName}/${import_constants.FILE_SYSTEM_ROUTES_COMPONENTS_DIR}`);
|
181
|
+
import_utils.fs.emptyDirSync(internalComponentsDir);
|
160
182
|
routes = normalizeNestedRoutes(routes, internalComponentsDir, internalDirectory, internalDirAlias);
|
161
183
|
parents.length = 0;
|
162
184
|
routes.sort((a, b) => {
|
163
|
-
const delta = (0,
|
185
|
+
const delta = (0, import_utils3.getRouteWeight)(a.path) - (0, import_utils3.getRouteWeight)(b.path);
|
164
186
|
if (delta === 0) {
|
165
187
|
return a.path.length - b.path.length;
|
166
188
|
}
|
167
189
|
return delta;
|
168
190
|
});
|
169
|
-
(0,
|
191
|
+
(0, import_utils3.debug)(`fileSystem routes: %o`, routes);
|
170
192
|
return routes;
|
171
193
|
};
|
194
|
+
// Annotate the CommonJS export names for ESM import in node:
|
195
|
+
0 && (module.exports = {
|
196
|
+
getClientRoutes
|
197
|
+
});
|
@@ -1,40 +1,62 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var getRoutesLegacy_exports = {};
|
30
|
+
__export(getRoutesLegacy_exports, {
|
31
|
+
getClientRoutes: () => getClientRoutes
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
33
|
+
module.exports = __toCommonJS(getRoutesLegacy_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
var import_makeLegalIdentifier = require("../makeLegalIdentifier");
|
37
|
+
var import_constants = require("../constants");
|
38
|
+
var import_utils2 = require("../utils");
|
39
|
+
var import_utils3 = require("./utils");
|
18
40
|
const compName = (srcDirectory, filePath) => {
|
19
|
-
const legalCompName = (0,
|
41
|
+
const legalCompName = (0, import_makeLegalIdentifier.makeLegalIdentifier)(import_path.default.relative(srcDirectory, filePath));
|
20
42
|
return `Comp_${legalCompName}`;
|
21
43
|
};
|
22
44
|
const layoutNameAbbr = (filePath) => {
|
23
45
|
const prefix = "L_";
|
24
|
-
const dirName =
|
25
|
-
return `${prefix}${(0,
|
46
|
+
const dirName = import_path.default.dirname(filePath).split("/").pop() || "";
|
47
|
+
return `${prefix}${(0, import_makeLegalIdentifier.makeLegalIdentifier)(dirName)}`;
|
26
48
|
};
|
27
49
|
const parents = [];
|
28
50
|
const recursiveReadDirLegacy = ({ dir, routes, basePath = "/", srcDirectory, srcAlias }) => {
|
29
51
|
let hasDynamicRoute = false;
|
30
52
|
let resetParent = false;
|
31
53
|
let parent = parents[parents.length - 1];
|
32
|
-
const layout = (0,
|
54
|
+
const layout = (0, import_utils3.findLayout)(dir);
|
33
55
|
if (layout) {
|
34
56
|
if (basePath === "/") {
|
35
57
|
throw new Error(`should use _app instead of _layout in ${dir}`);
|
36
58
|
} else {
|
37
|
-
const alias = (0,
|
59
|
+
const alias = (0, import_utils2.replaceWithAlias)(srcDirectory, layout, srcAlias);
|
38
60
|
const componentName = compName(srcDirectory, layout);
|
39
61
|
const route = {
|
40
62
|
path: `${basePath.substring(0, basePath.length - 1)}`,
|
@@ -51,13 +73,13 @@ const recursiveReadDirLegacy = ({ dir, routes, basePath = "/", srcDirectory, src
|
|
51
73
|
routes = route.routes;
|
52
74
|
}
|
53
75
|
}
|
54
|
-
for (const relative of
|
55
|
-
const filePath =
|
56
|
-
if (!(0,
|
57
|
-
const filename =
|
58
|
-
const alias = (0,
|
76
|
+
for (const relative of import_utils.fs.readdirSync(dir)) {
|
77
|
+
const filePath = import_path.default.join(dir, relative);
|
78
|
+
if (!(0, import_utils3.shouldSkip)(filePath)) {
|
79
|
+
const filename = import_path.default.basename(filePath, import_path.default.extname(filePath));
|
80
|
+
const alias = (0, import_utils2.replaceWithAlias)(srcDirectory, filePath, srcAlias);
|
59
81
|
const componentName = compName(srcDirectory, filePath);
|
60
|
-
const dynamicRouteMatched =
|
82
|
+
const dynamicRouteMatched = import_constants.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP.exec(filename);
|
61
83
|
if (dynamicRouteMatched) {
|
62
84
|
if (hasDynamicRoute) {
|
63
85
|
throw new Error(`Can't set two dynamic route in one directory: ${dir}`);
|
@@ -72,7 +94,7 @@ const recursiveReadDirLegacy = ({ dir, routes, basePath = "/", srcDirectory, src
|
|
72
94
|
exact: true,
|
73
95
|
parent
|
74
96
|
};
|
75
|
-
if (
|
97
|
+
if (import_utils.fs.statSync(filePath).isDirectory()) {
|
76
98
|
recursiveReadDirLegacy({
|
77
99
|
dir: filePath,
|
78
100
|
routes,
|
@@ -82,10 +104,10 @@ const recursiveReadDirLegacy = ({ dir, routes, basePath = "/", srcDirectory, src
|
|
82
104
|
});
|
83
105
|
continue;
|
84
106
|
}
|
85
|
-
if (filename ===
|
107
|
+
if (filename === import_constants.FILE_SYSTEM_ROUTES_LAYOUT) {
|
86
108
|
continue;
|
87
109
|
}
|
88
|
-
if (filename ===
|
110
|
+
if (filename === import_constants.FILE_SYSTEM_ROUTES_INDEX) {
|
89
111
|
route.path = basePath === "/" ? basePath : `${basePath.substring(0, basePath.length - 1)}`;
|
90
112
|
}
|
91
113
|
if (filename === "404" && basePath === "/") {
|
@@ -118,13 +140,13 @@ const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory,
|
|
118
140
|
codes.push(`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`);
|
119
141
|
lastComponent = currentComponent;
|
120
142
|
}
|
121
|
-
const file =
|
122
|
-
|
143
|
+
const file = import_path.default.resolve(internalComponentsDir, `${lastComponent}.jsx`);
|
144
|
+
import_utils.fs.outputFileSync(file, `${imports.join("\n")}
|
123
145
|
${codes.join("\n")}
|
124
146
|
export default ${lastComponent}`);
|
125
147
|
return {
|
126
148
|
component: lastComponent,
|
127
|
-
_component: (0,
|
149
|
+
_component: (0, import_utils2.replaceWithAlias)(internalDirectory, file, internalDirAlias)
|
128
150
|
};
|
129
151
|
};
|
130
152
|
const normalized = flat(nested).map((route) => route.parent ? {
|
@@ -139,10 +161,10 @@ export default ${lastComponent}`);
|
|
139
161
|
};
|
140
162
|
const getClientRoutes = ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias }) => {
|
141
163
|
const { entry, entryName } = entrypoint;
|
142
|
-
if (!
|
164
|
+
if (!import_utils.fs.existsSync(entry)) {
|
143
165
|
throw new Error(`generate file system routes error, ${entry} directory not found.`);
|
144
166
|
}
|
145
|
-
if (!(
|
167
|
+
if (!(import_utils.fs.existsSync(entry) && import_utils.fs.statSync(entry).isDirectory())) {
|
146
168
|
throw new Error(`generate file system routes error, ${entry} should be directory.`);
|
147
169
|
}
|
148
170
|
let routes = [];
|
@@ -153,17 +175,21 @@ const getClientRoutes = ({ entrypoint, srcDirectory, srcAlias, internalDirectory
|
|
153
175
|
srcDirectory,
|
154
176
|
srcAlias
|
155
177
|
});
|
156
|
-
const internalComponentsDir =
|
157
|
-
|
178
|
+
const internalComponentsDir = import_path.default.resolve(internalDirectory, `${entryName}/${import_constants.FILE_SYSTEM_ROUTES_COMPONENTS_DIR}`);
|
179
|
+
import_utils.fs.emptyDirSync(internalComponentsDir);
|
158
180
|
routes = normalizeNestedRoutes(routes, internalComponentsDir, internalDirectory, internalDirAlias);
|
159
181
|
parents.length = 0;
|
160
182
|
routes.sort((a, b) => {
|
161
|
-
const delta = (0,
|
183
|
+
const delta = (0, import_utils3.getRouteWeight)(a.path) - (0, import_utils3.getRouteWeight)(b.path);
|
162
184
|
if (delta === 0) {
|
163
185
|
return a.path.length - b.path.length;
|
164
186
|
}
|
165
187
|
return delta;
|
166
188
|
});
|
167
|
-
(0,
|
189
|
+
(0, import_utils3.debug)(`fileSystem routes: %o`, routes);
|
168
190
|
return routes;
|
169
191
|
};
|
192
|
+
// Annotate the CommonJS export names for ESM import in node:
|
193
|
+
0 && (module.exports = {
|
194
|
+
getClientRoutes
|
195
|
+
});
|
@@ -1,21 +1,31 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return _getRoutes.getClientRoutes;
|
15
|
-
},
|
16
|
-
getClientRoutesLegacy: function() {
|
17
|
-
return _getRoutesLegacy.getClientRoutes;
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var getClientRoutes_exports = {};
|
20
|
+
__export(getClientRoutes_exports, {
|
21
|
+
getClientRoutes: () => import_getRoutes.getClientRoutes,
|
22
|
+
getClientRoutesLegacy: () => import_getRoutesLegacy.getClientRoutes
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(getClientRoutes_exports);
|
25
|
+
var import_getRoutes = require("./getRoutes");
|
26
|
+
var import_getRoutesLegacy = require("./getRoutesLegacy");
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
28
|
+
0 && (module.exports = {
|
29
|
+
getClientRoutes,
|
30
|
+
getClientRoutesLegacy
|
19
31
|
});
|
20
|
-
const _getRoutes = require("./getRoutes");
|
21
|
-
const _getRoutesLegacy = require("./getRoutesLegacy");
|
@@ -1,42 +1,59 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
6
9
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return debug;
|
15
|
-
},
|
16
|
-
findLayout: function() {
|
17
|
-
return findLayout;
|
18
|
-
},
|
19
|
-
getRouteWeight: function() {
|
20
|
-
return getRouteWeight;
|
21
|
-
},
|
22
|
-
shouldSkip: function() {
|
23
|
-
return shouldSkip;
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
24
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var utils_exports = {};
|
30
|
+
__export(utils_exports, {
|
31
|
+
debug: () => debug,
|
32
|
+
findLayout: () => findLayout,
|
33
|
+
getRouteWeight: () => getRouteWeight,
|
34
|
+
shouldSkip: () => shouldSkip
|
25
35
|
});
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
const debug = (0,
|
31
|
-
const findLayout = (dir) => (0,
|
36
|
+
module.exports = __toCommonJS(utils_exports);
|
37
|
+
var import_path = __toESM(require("path"));
|
38
|
+
var import_utils = require("@modern-js/utils");
|
39
|
+
var import_constants = require("../constants");
|
40
|
+
const debug = (0, import_utils.createDebugger)("get-client-routes");
|
41
|
+
const findLayout = (dir) => (0, import_utils.findExists)(import_constants.JS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, `${import_constants.FILE_SYSTEM_ROUTES_LAYOUT}${ext}`)));
|
32
42
|
const getRouteWeight = (route) => route === "*" ? 999 : route.split(":").length - 1;
|
33
43
|
const shouldSkip = (file) => {
|
34
|
-
if (
|
44
|
+
if (import_utils.fs.statSync(file).isDirectory()) {
|
35
45
|
return false;
|
36
46
|
}
|
37
|
-
const ext =
|
38
|
-
if (
|
47
|
+
const ext = import_path.default.extname(file);
|
48
|
+
if (import_constants.FILE_SYSTEM_ROUTES_IGNORED_REGEX.test(file) || !import_constants.JS_EXTENSIONS.includes(ext) || import_constants.FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT === import_path.default.basename(file, ext)) {
|
39
49
|
return true;
|
40
50
|
}
|
41
51
|
return false;
|
42
52
|
};
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
54
|
+
0 && (module.exports = {
|
55
|
+
debug,
|
56
|
+
findLayout,
|
57
|
+
getRouteWeight,
|
58
|
+
shouldSkip
|
59
|
+
});
|
@@ -1,34 +1,56 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var getFileSystemEntry_exports = {};
|
30
|
+
__export(getFileSystemEntry_exports, {
|
31
|
+
getFileSystemEntry: () => getFileSystemEntry
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
const hasIndex = (dir) => (0,
|
18
|
-
const hasApp = (dir) => (0,
|
19
|
-
const hasPages = (dir) =>
|
20
|
-
const hasNestedRoutes = (dir) =>
|
33
|
+
module.exports = __toCommonJS(getFileSystemEntry_exports);
|
34
|
+
var import_fs = __toESM(require("fs"));
|
35
|
+
var import_path = __toESM(require("path"));
|
36
|
+
var import_utils = require("@modern-js/utils");
|
37
|
+
var import_isDefaultExportFunction = require("./isDefaultExportFunction");
|
38
|
+
var import_constants = require("./constants");
|
39
|
+
const hasIndex = (dir) => (0, import_utils.findExists)(import_constants.JS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, `${import_constants.INDEX_FILE_NAME}${ext}`)));
|
40
|
+
const hasApp = (dir) => (0, import_utils.findExists)(import_constants.JS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, `${import_constants.APP_FILE_NAME}${ext}`)));
|
41
|
+
const hasPages = (dir) => import_fs.default.existsSync(import_path.default.join(dir, import_constants.PAGES_DIR_NAME));
|
42
|
+
const hasNestedRoutes = (dir) => import_fs.default.existsSync(import_path.default.join(dir, import_constants.NESTED_ROUTES_DIR));
|
21
43
|
const isBundleEntry = (dir) => hasApp(dir) || hasPages(dir) || hasIndex(dir) || hasNestedRoutes(dir);
|
22
44
|
const scanDir = (dirs) => dirs.map((dir) => {
|
23
45
|
const indexFile = hasIndex(dir);
|
24
|
-
const customBootstrap = (0,
|
25
|
-
const entryName =
|
46
|
+
const customBootstrap = (0, import_isDefaultExportFunction.isDefaultExportFunction)(indexFile) ? indexFile : false;
|
47
|
+
const entryName = import_path.default.basename(dir);
|
26
48
|
if (indexFile && !customBootstrap) {
|
27
49
|
return {
|
28
50
|
entryName,
|
29
51
|
isMainEntry: false,
|
30
52
|
entry: indexFile,
|
31
|
-
absoluteEntryDir:
|
53
|
+
absoluteEntryDir: import_path.default.resolve(dir),
|
32
54
|
isAutoMount: false
|
33
55
|
};
|
34
56
|
}
|
@@ -37,9 +59,9 @@ const scanDir = (dirs) => dirs.map((dir) => {
|
|
37
59
|
return {
|
38
60
|
entryName,
|
39
61
|
isMainEntry: false,
|
40
|
-
entry:
|
62
|
+
entry: import_path.default.join(dir, import_constants.APP_FILE_NAME),
|
41
63
|
isAutoMount: true,
|
42
|
-
absoluteEntryDir:
|
64
|
+
absoluteEntryDir: import_path.default.resolve(dir),
|
43
65
|
customBootstrap
|
44
66
|
};
|
45
67
|
}
|
@@ -51,18 +73,18 @@ const scanDir = (dirs) => dirs.map((dir) => {
|
|
51
73
|
isMainEntry: false,
|
52
74
|
entry: "",
|
53
75
|
fileSystemRoutes: {
|
54
|
-
globalApp: (0,
|
76
|
+
globalApp: (0, import_utils.findExists)(import_constants.JS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, `./${import_constants.PAGES_DIR_NAME}/${import_constants.FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT}${ext}`)))
|
55
77
|
},
|
56
78
|
isAutoMount: true,
|
57
|
-
absoluteEntryDir:
|
79
|
+
absoluteEntryDir: import_path.default.resolve(dir),
|
58
80
|
customBootstrap
|
59
81
|
};
|
60
82
|
if (isHasPages) {
|
61
|
-
entrypoint.entry =
|
83
|
+
entrypoint.entry = import_path.default.join(dir, import_constants.PAGES_DIR_NAME);
|
62
84
|
entrypoint.pageRoutesEntry = entrypoint.entry;
|
63
85
|
}
|
64
86
|
if (isHasNestedRoutes) {
|
65
|
-
entrypoint.entry =
|
87
|
+
entrypoint.entry = import_path.default.join(dir, import_constants.NESTED_ROUTES_DIR);
|
66
88
|
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
67
89
|
}
|
68
90
|
return entrypoint;
|
@@ -71,7 +93,7 @@ const scanDir = (dirs) => dirs.map((dir) => {
|
|
71
93
|
entryName,
|
72
94
|
isMainEntry: false,
|
73
95
|
entry: indexFile,
|
74
|
-
absoluteEntryDir:
|
96
|
+
absoluteEntryDir: import_path.default.resolve(dir),
|
75
97
|
isAutoMount: false
|
76
98
|
};
|
77
99
|
});
|
@@ -80,14 +102,14 @@ const getFileSystemEntry = (appContext, config) => {
|
|
80
102
|
const { source: { entriesDir, disableEntryDirs } } = config;
|
81
103
|
let disabledDirs = [];
|
82
104
|
if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
|
83
|
-
disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map((dir) => (0,
|
105
|
+
disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map((dir) => (0, import_utils.ensureAbsolutePath)(appDirectory, dir));
|
84
106
|
}
|
85
|
-
const src = (0,
|
86
|
-
if (
|
87
|
-
if (
|
107
|
+
const src = (0, import_utils.ensureAbsolutePath)(appDirectory, entriesDir || "");
|
108
|
+
if (import_fs.default.existsSync(src)) {
|
109
|
+
if (import_fs.default.statSync(src).isDirectory()) {
|
88
110
|
return scanDir(isBundleEntry(src) ? [
|
89
111
|
src
|
90
|
-
] :
|
112
|
+
] : import_fs.default.readdirSync(src).map((file) => import_path.default.join(src, file)).filter((file) => import_fs.default.statSync(file).isDirectory() && isBundleEntry(file) && !disabledDirs.includes(file)));
|
91
113
|
} else {
|
92
114
|
throw Error(`source.entriesDir accept a directory.`);
|
93
115
|
}
|
@@ -95,3 +117,7 @@ const getFileSystemEntry = (appContext, config) => {
|
|
95
117
|
throw Error(`src dir ${entriesDir} not found.`);
|
96
118
|
}
|
97
119
|
};
|
120
|
+
// Annotate the CommonJS export names for ESM import in node:
|
121
|
+
0 && (module.exports = {
|
122
|
+
getFileSystemEntry
|
123
|
+
});
|