@modern-js/app-tools 2.35.0 → 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 +69 -75
- package/dist/cjs/analyze/generateCode.js +77 -61
- 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 -33
- package/dist/cjs/analyze/getHtmlTemplate.js +45 -20
- package/dist/cjs/analyze/getServerRoutes.js +59 -34
- 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 +117 -65
- package/dist/cjs/analyze/templates.js +139 -57
- 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 +27 -11
- 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 +39 -38
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +58 -34
- 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 +43 -26
- 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 +34 -18
- 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 -10
- package/dist/cjs/commands/serve.js +49 -23
- 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 +196 -184
- 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 +49 -22
- package/dist/esm/analyze/generateCode.js +42 -37
- 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 +11 -9
- package/dist/esm/analyze/getHtmlTemplate.js +7 -4
- package/dist/esm/analyze/getServerRoutes.js +12 -10
- 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 +99 -30
- package/dist/esm/analyze/templates.js +125 -34
- 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 +5 -3
- package/dist/esm/builder/generator/getBuilderTargets.js +4 -1
- package/dist/esm/builder/generator/index.js +5 -2
- package/dist/esm/builder/index.js +5 -2
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +23 -51
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +22 -21
- 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 +9 -6
- 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 +9 -6
- package/dist/esm/commands/deploy.js +4 -1
- package/dist/esm/commands/dev.js +12 -9
- package/dist/esm/commands/inspect.js +6 -3
- package/dist/esm/commands/serve.js +11 -8
- 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 +21 -14
- 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 +14 -8
- 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 +5 -2
- 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 +49 -22
- package/dist/esm-node/analyze/generateCode.js +11 -7
- 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 +5 -3
- package/dist/esm-node/analyze/getHtmlTemplate.js +4 -1
- package/dist/esm-node/analyze/getServerRoutes.js +8 -6
- 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 +49 -10
- package/dist/esm-node/analyze/templates.js +97 -22
- 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 +5 -3
- 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 +5 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +8 -20
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +16 -15
- 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 +6 -3
- 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 +6 -4
- 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 +5 -3
- package/dist/esm-node/commands/serve.js +8 -5
- 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 +140 -135
- 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 +12 -6
- 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 +5 -2
- 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 +2 -0
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
- package/dist/types/types/config/index.d.ts +3 -2
- package/package.json +24 -25
@@ -1,19 +1,40 @@
|
|
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 getHtmlTemplate_exports = {};
|
30
|
+
__export(getHtmlTemplate_exports, {
|
31
|
+
getHtmlTemplate: () => getHtmlTemplate
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const _templates = /* @__PURE__ */ _interop_require_wildcard._(require("./templates"));
|
33
|
+
module.exports = __toCommonJS(getHtmlTemplate_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
var import_constants = require("./constants");
|
37
|
+
var templates = __toESM(require("./templates"));
|
17
38
|
var PartialPosition;
|
18
39
|
(function(PartialPosition2) {
|
19
40
|
PartialPosition2["TOP"] = "top";
|
@@ -23,12 +44,12 @@ var PartialPosition;
|
|
23
44
|
PartialPosition2["INDEX"] = "index";
|
24
45
|
})(PartialPosition || (PartialPosition = {}));
|
25
46
|
const findPartials = (dir, entryName, position) => {
|
26
|
-
if (
|
27
|
-
const base = (0,
|
28
|
-
const file = entryName ? (0,
|
47
|
+
if (import_utils.fs.existsSync(dir)) {
|
48
|
+
const base = (0, import_utils.findExists)(import_constants.HTML_PARTIALS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, `${position}${ext}`)));
|
49
|
+
const file = entryName ? (0, import_utils.findExists)(import_constants.HTML_PARTIALS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, entryName, `${position}${ext}`))) || base : base;
|
29
50
|
return file ? {
|
30
51
|
file,
|
31
|
-
content:
|
52
|
+
content: import_utils.fs.readFileSync(file, "utf8")
|
32
53
|
} : null;
|
33
54
|
}
|
34
55
|
return null;
|
@@ -36,7 +57,7 @@ const findPartials = (dir, entryName, position) => {
|
|
36
57
|
const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
37
58
|
const { appDirectory, internalDirectory } = appContext;
|
38
59
|
const { source: { configDir } } = config;
|
39
|
-
const htmlDir =
|
60
|
+
const htmlDir = import_path.default.resolve(appDirectory, configDir || "", import_constants.HTML_PARTIALS_FOLDER);
|
40
61
|
const htmlTemplates = {};
|
41
62
|
const partialsByEntrypoint = {};
|
42
63
|
for (const entrypoint of entrypoints) {
|
@@ -65,8 +86,8 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
65
86
|
body: []
|
66
87
|
})
|
67
88
|
});
|
68
|
-
const templatePath =
|
69
|
-
|
89
|
+
const templatePath = import_path.default.resolve(internalDirectory, entryName, "index.html");
|
90
|
+
import_utils.fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
70
91
|
htmlTemplates[entryName] = templatePath;
|
71
92
|
partialsByEntrypoint[entryName] = partials;
|
72
93
|
const bottomTemplate = findPartials(htmlDir, name, PartialPosition.BOTTOM);
|
@@ -81,3 +102,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
81
102
|
});
|
82
103
|
return htmlTemplates;
|
83
104
|
};
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
106
|
+
0 && (module.exports = {
|
107
|
+
getHtmlTemplate
|
108
|
+
});
|
@@ -1,18 +1,40 @@
|
|
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 getServerRoutes_exports = {};
|
30
|
+
__export(getServerRoutes_exports, {
|
31
|
+
getServerRoutes: () => getServerRoutes
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
33
|
+
module.exports = __toCommonJS(getServerRoutes_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_fs = __toESM(require("fs"));
|
36
|
+
var import_utils = require("@modern-js/utils");
|
37
|
+
var import_utils2 = require("./utils");
|
16
38
|
const applyBaseUrl = (baseUrl, routes) => {
|
17
39
|
if (baseUrl) {
|
18
40
|
if (Array.isArray(baseUrl)) {
|
@@ -22,10 +44,10 @@ const applyBaseUrl = (baseUrl, routes) => {
|
|
22
44
|
], []);
|
23
45
|
} else {
|
24
46
|
return routes.map((route) => {
|
25
|
-
const urlPath = (0,
|
47
|
+
const urlPath = (0, import_utils.urlJoin)(baseUrl, route.urlPath);
|
26
48
|
return {
|
27
49
|
...route,
|
28
|
-
urlPath: urlPath === "/" ? urlPath : (0,
|
50
|
+
urlPath: urlPath === "/" ? urlPath : (0, import_utils.removeTailSlash)(urlPath)
|
29
51
|
};
|
30
52
|
});
|
31
53
|
}
|
@@ -35,12 +57,12 @@ const applyBaseUrl = (baseUrl, routes) => {
|
|
35
57
|
const applyRouteOptions = (original, routeOptions) => {
|
36
58
|
const { route, disableSpa } = routeOptions;
|
37
59
|
original.isSPA = !disableSpa;
|
38
|
-
!original.isSPA && (original.entryPath =
|
60
|
+
!original.isSPA && (original.entryPath = import_path.default.dirname(original.entryPath));
|
39
61
|
let routes;
|
40
62
|
if (route) {
|
41
63
|
if (Array.isArray(route)) {
|
42
64
|
routes = route.map((url) => {
|
43
|
-
if ((0,
|
65
|
+
if ((0, import_utils.isPlainObject)(url)) {
|
44
66
|
const { path: urlPath, ...other } = url;
|
45
67
|
return {
|
46
68
|
...original,
|
@@ -54,7 +76,7 @@ const applyRouteOptions = (original, routeOptions) => {
|
|
54
76
|
};
|
55
77
|
}
|
56
78
|
});
|
57
|
-
} else if ((0,
|
79
|
+
} else if ((0, import_utils.isPlainObject)(route)) {
|
58
80
|
const { path: urlPath, ...other } = route;
|
59
81
|
routes = [
|
60
82
|
{
|
@@ -79,31 +101,30 @@ const applyRouteOptions = (original, routeOptions) => {
|
|
79
101
|
return routes;
|
80
102
|
};
|
81
103
|
const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
82
|
-
var _deploy_worker
|
104
|
+
var _deploy_worker;
|
83
105
|
const { source: { mainEntryName }, html: { disableHtmlFolder }, output: { distPath: { html: htmlPath } = {} }, server: { baseUrl, routes, ssr, ssrByEntries }, deploy } = config;
|
84
106
|
const { packageName } = appContext;
|
85
|
-
const workerSSR =
|
107
|
+
const workerSSR = deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr;
|
86
108
|
let htmlRoutes = entrypoints.reduce((previous, { entryName }) => {
|
87
|
-
|
88
|
-
const
|
89
|
-
const entryOptions = (0, _utils.getEntryOptions)(entryName, isMainEntry, ssr, ssrByEntries, packageName);
|
109
|
+
const isMainEntry = entryName === (mainEntryName || import_utils.MAIN_ENTRY_NAME);
|
110
|
+
const entryOptions = (0, import_utils.getEntryOptions)(entryName, isMainEntry, ssr, ssrByEntries, packageName);
|
90
111
|
const isSSR = Boolean(entryOptions);
|
91
112
|
const isWorker = Boolean(workerSSR);
|
92
113
|
const isStream = typeof entryOptions === "object" && (entryOptions.mode === "stream" || Boolean(entryOptions.preload));
|
93
|
-
const { resHeaders } = (
|
114
|
+
const { resHeaders } = (routes === null || routes === void 0 ? void 0 : routes[entryName]) || {};
|
94
115
|
let route = {
|
95
116
|
urlPath: `/${isMainEntry ? "" : entryName}`,
|
96
117
|
entryName,
|
97
|
-
entryPath: (0,
|
118
|
+
entryPath: (0, import_utils.removeLeadingSlash)(import_path.default.posix.normalize(`${htmlPath}/${entryName}${disableHtmlFolder ? ".html" : "/index.html"}`)),
|
98
119
|
isSPA: true,
|
99
120
|
isStream,
|
100
121
|
isSSR,
|
101
122
|
responseHeaders: resHeaders,
|
102
|
-
worker: isWorker ? `${
|
103
|
-
bundle: isSSR ? `${
|
123
|
+
worker: isWorker ? `${import_utils.SERVER_WORKER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0,
|
124
|
+
bundle: isSSR ? `${import_utils.SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0
|
104
125
|
};
|
105
|
-
if (
|
106
|
-
const routeOptions = (0,
|
126
|
+
if (routes === null || routes === void 0 ? void 0 : routes.hasOwnProperty(entryName)) {
|
127
|
+
const routeOptions = (0, import_utils.isPlainObject)(routes[entryName]) ? routes[entryName] : {
|
107
128
|
route: routes[entryName]
|
108
129
|
};
|
109
130
|
route = applyRouteOptions(route, routeOptions);
|
@@ -122,14 +143,14 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
122
143
|
const collectStaticRoutes = (appContext, config) => {
|
123
144
|
const { appDirectory } = appContext;
|
124
145
|
const { source: { configDir }, server: { publicRoutes = {} } } = config;
|
125
|
-
const publicFolder =
|
126
|
-
return
|
127
|
-
const urlPath = `${(0,
|
146
|
+
const publicFolder = import_path.default.resolve(appDirectory, configDir || "", "public");
|
147
|
+
return import_fs.default.existsSync(publicFolder) ? (0, import_utils2.walkDirectory)(publicFolder).map((filePath) => {
|
148
|
+
const urlPath = `${(0, import_utils.urlJoin)(toPosix(filePath).slice(toPosix(publicFolder).length))}`;
|
128
149
|
return {
|
129
|
-
urlPath: publicRoutes[(0,
|
150
|
+
urlPath: publicRoutes[(0, import_utils.removeLeadingSlash)(urlPath)] || urlPath,
|
130
151
|
isSPA: true,
|
131
152
|
isSSR: false,
|
132
|
-
entryPath: toPosix(
|
153
|
+
entryPath: toPosix(import_path.default.relative(import_path.default.resolve(appDirectory, configDir || ""), filePath))
|
133
154
|
};
|
134
155
|
}) : [];
|
135
156
|
};
|
@@ -137,4 +158,8 @@ const getServerRoutes = (entrypoints, { appContext, config }) => [
|
|
137
158
|
...collectHtmlRoutes(entrypoints, appContext, config),
|
138
159
|
...collectStaticRoutes(appContext, config)
|
139
160
|
];
|
140
|
-
const toPosix = (pathStr) => pathStr.split(
|
161
|
+
const toPosix = (pathStr) => pathStr.split(import_path.default.sep).join(import_path.default.posix.sep);
|
162
|
+
// Annotate the CommonJS export names for ESM import in node:
|
163
|
+
0 && (module.exports = {
|
164
|
+
getServerRoutes
|
165
|
+
});
|
@@ -1,28 +1,50 @@
|
|
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 analyze_exports = {};
|
30
|
+
__export(analyze_exports, {
|
31
|
+
default: () => analyze_default
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const debug = (0,
|
25
|
-
|
33
|
+
module.exports = __toCommonJS(analyze_exports);
|
34
|
+
var path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
37
|
+
var import_printInstructions = require("../utils/printInstructions");
|
38
|
+
var import_routes = require("../utils/routes");
|
39
|
+
var import_config = require("../utils/config");
|
40
|
+
var import_getSelectedEntries = require("../utils/getSelectedEntries");
|
41
|
+
var import_config2 = require("../config");
|
42
|
+
var import_builder = require("../builder");
|
43
|
+
var import_utils2 = require("./utils");
|
44
|
+
var import_constants = require("./constants");
|
45
|
+
var import_generateCode = require("./generateCode");
|
46
|
+
const debug = (0, import_utils.createDebugger)("plugin-analyze");
|
47
|
+
var analyze_default = ({ bundler }) => ({
|
26
48
|
name: "@modern-js/plugin-analyze",
|
27
49
|
setup: (api) => {
|
28
50
|
let pagesDir = [];
|
@@ -35,12 +57,12 @@ const _default = ({ bundler }) => ({
|
|
35
57
|
const resolvedConfig = api.useResolvedConfigContext();
|
36
58
|
const hookRunners = api.useHookRunners();
|
37
59
|
try {
|
38
|
-
if ((0,
|
39
|
-
|
60
|
+
if ((0, import_utils2.checkIsBuildCommands)()) {
|
61
|
+
import_utils.fs.emptydirSync(appContext.internalDirectory);
|
40
62
|
}
|
41
63
|
} catch {
|
42
64
|
}
|
43
|
-
const apiOnly = await (0,
|
65
|
+
const apiOnly = await (0, import_utils.isApiOnly)(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory);
|
44
66
|
await hookRunners.addRuntimeExports();
|
45
67
|
if (apiOnly) {
|
46
68
|
const { routes: routes2 } = await hookRunners.modifyServerRoutes({
|
@@ -56,10 +78,10 @@ const _default = ({ bundler }) => ({
|
|
56
78
|
return;
|
57
79
|
}
|
58
80
|
const [{ getBundleEntry }, { getServerRoutes }, { generateCode }, { getHtmlTemplate }] = await Promise.all([
|
59
|
-
Promise.resolve().then(() =>
|
60
|
-
Promise.resolve().then(() =>
|
61
|
-
Promise.resolve().then(() =>
|
62
|
-
Promise.resolve().then(() =>
|
81
|
+
Promise.resolve().then(() => __toESM(require("./getBundleEntry"))),
|
82
|
+
Promise.resolve().then(() => __toESM(require("./getServerRoutes"))),
|
83
|
+
Promise.resolve().then(() => __toESM(require("./generateCode"))),
|
84
|
+
Promise.resolve().then(() => __toESM(require("./getHtmlTemplate")))
|
63
85
|
]);
|
64
86
|
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
65
87
|
debug(`entrypoints: %o`, entrypoints);
|
@@ -78,8 +100,8 @@ const _default = ({ bundler }) => ({
|
|
78
100
|
};
|
79
101
|
api.setAppContext(appContext);
|
80
102
|
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
81
|
-
pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !
|
82
|
-
originEntrypoints = (0,
|
103
|
+
pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !path.extname(entry)).concat(nestedRouteEntries);
|
104
|
+
originEntrypoints = (0, import_lodash.cloneDeep)(entrypoints);
|
83
105
|
const { importsStatemets } = await generateCode(appContext, resolvedConfig, entrypoints, api);
|
84
106
|
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
85
107
|
appContext,
|
@@ -89,9 +111,9 @@ const _default = ({ bundler }) => ({
|
|
89
111
|
await hookRunners.addDefineTypes();
|
90
112
|
debug(`add Define Types`);
|
91
113
|
let checkedEntries = entrypoints.map((point) => point.entryName);
|
92
|
-
if ((0,
|
93
|
-
const { entry } = (0,
|
94
|
-
checkedEntries = await (0,
|
114
|
+
if ((0, import_utils.isDevCommand)()) {
|
115
|
+
const { entry } = (0, import_utils.minimist)((0, import_utils.getArgv)());
|
116
|
+
checkedEntries = await (0, import_getSelectedEntries.getSelectedEntries)(typeof entry === "string" ? entry.split(",") : entry, entrypoints);
|
95
117
|
}
|
96
118
|
appContext = {
|
97
119
|
...api.useAppContext(),
|
@@ -102,16 +124,16 @@ const _default = ({ bundler }) => ({
|
|
102
124
|
htmlTemplates
|
103
125
|
};
|
104
126
|
api.setAppContext(appContext);
|
105
|
-
if ((0,
|
127
|
+
if ((0, import_utils2.checkIsBuildCommands)()) {
|
106
128
|
const normalizedConfig = api.useResolvedConfigContext();
|
107
|
-
const createBuilderForModern = await (0,
|
129
|
+
const createBuilderForModern = await (0, import_builder.createBuilderGenerator)(bundler);
|
108
130
|
const builder = await createBuilderForModern({
|
109
131
|
normalizedConfig,
|
110
132
|
appContext
|
111
133
|
});
|
112
134
|
builder.onBeforeBuild(async ({ bundlerConfigs }) => {
|
113
135
|
const hookRunners2 = api.useHookRunners();
|
114
|
-
await (0,
|
136
|
+
await (0, import_routes.generateRoutes)(appContext);
|
115
137
|
await hookRunners2.beforeBuild({
|
116
138
|
bundlerConfigs
|
117
139
|
});
|
@@ -121,7 +143,7 @@ const _default = ({ bundler }) => ({
|
|
121
143
|
await hookRunners2.afterBuild({
|
122
144
|
stats
|
123
145
|
});
|
124
|
-
await (0,
|
146
|
+
await (0, import_config.emitResolvedConfig)(appContext.appDirectory, normalizedConfig);
|
125
147
|
});
|
126
148
|
builder.onDevCompileDone(async ({ isFirstCompile }) => {
|
127
149
|
const hookRunners2 = api.useHookRunners();
|
@@ -130,13 +152,13 @@ const _default = ({ bundler }) => ({
|
|
130
152
|
isFirstCompile
|
131
153
|
});
|
132
154
|
if (isFirstCompile) {
|
133
|
-
(0,
|
155
|
+
(0, import_printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
134
156
|
}
|
135
157
|
}
|
136
158
|
});
|
137
159
|
builder.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {
|
138
160
|
const hookRunners2 = api.useHookRunners();
|
139
|
-
await (0,
|
161
|
+
await (0, import_generateCode.generateIndexCode)({
|
140
162
|
appContext,
|
141
163
|
config: resolvedConfig,
|
142
164
|
entrypoints,
|
@@ -170,7 +192,7 @@ const _default = ({ bundler }) => ({
|
|
170
192
|
},
|
171
193
|
resolvedConfig({ resolved }) {
|
172
194
|
const appContext = api.useAppContext();
|
173
|
-
const config = (0,
|
195
|
+
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext, bundler);
|
174
196
|
return {
|
175
197
|
resolved: config
|
176
198
|
};
|
@@ -181,40 +203,40 @@ const _default = ({ bundler }) => ({
|
|
181
203
|
const { srcDirectory, internalSrcAlias } = appContext;
|
182
204
|
const { fileSystemRoutes, nestedRoutesEntry } = entrypoint;
|
183
205
|
if (fileSystemRoutes && nestedRoutesEntry) {
|
184
|
-
const rootLayoutPath =
|
185
|
-
const rootLayoutFile = (0,
|
206
|
+
const rootLayoutPath = path.join(nestedRoutesEntry, "layout");
|
207
|
+
const rootLayoutFile = (0, import_utils.findExists)([
|
186
208
|
".js",
|
187
209
|
".ts",
|
188
210
|
".jsx",
|
189
211
|
".tsx"
|
190
212
|
].map((ext) => `${rootLayoutPath}${ext}`));
|
191
213
|
if (rootLayoutFile) {
|
192
|
-
const rootLayoutBuffer = await
|
214
|
+
const rootLayoutBuffer = await import_utils.fs.readFile(rootLayoutFile);
|
193
215
|
const rootLayout = rootLayoutBuffer.toString();
|
194
|
-
const [, moduleExports] = await (0,
|
216
|
+
const [, moduleExports] = await (0, import_utils2.parseModule)({
|
195
217
|
source: rootLayout.toString(),
|
196
218
|
filename: rootLayoutFile
|
197
219
|
});
|
198
|
-
const hasAppConfig = moduleExports.some((e) => e.n ===
|
199
|
-
const generateLayoutPath = (0,
|
220
|
+
const hasAppConfig = moduleExports.some((e) => e.n === import_constants.APP_CONFIG_NAME);
|
221
|
+
const generateLayoutPath = (0, import_utils2.replaceWithAlias)(srcDirectory, rootLayoutFile, internalSrcAlias);
|
200
222
|
if (hasAppConfig) {
|
201
223
|
imports.push({
|
202
224
|
value: generateLayoutPath,
|
203
225
|
specifiers: [
|
204
226
|
{
|
205
|
-
imported:
|
227
|
+
imported: import_constants.APP_CONFIG_NAME
|
206
228
|
}
|
207
229
|
]
|
208
230
|
});
|
209
231
|
}
|
210
|
-
const hasAppInit = moduleExports.some((e) => e.n ===
|
232
|
+
const hasAppInit = moduleExports.some((e) => e.n === import_constants.APP_INIT_EXPORTED);
|
211
233
|
if (hasAppInit) {
|
212
234
|
imports.push({
|
213
235
|
value: generateLayoutPath,
|
214
236
|
specifiers: [
|
215
237
|
{
|
216
|
-
imported:
|
217
|
-
local:
|
238
|
+
imported: import_constants.APP_INIT_EXPORTED,
|
239
|
+
local: import_constants.APP_INIT_IMPORTED
|
218
240
|
}
|
219
241
|
]
|
220
242
|
});
|
@@ -239,12 +261,12 @@ const _default = ({ bundler }) => ({
|
|
239
261
|
const { appDirectory } = appContext;
|
240
262
|
const { filename, eventType } = e;
|
241
263
|
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
242
|
-
const absoluteFilePath =
|
243
|
-
const isRouteComponent = isPageFile(absoluteFilePath) && (0,
|
264
|
+
const absoluteFilePath = path.resolve(appDirectory, filename);
|
265
|
+
const isRouteComponent = isPageFile(absoluteFilePath) && (0, import_utils2.isPageComponentFile)(absoluteFilePath);
|
244
266
|
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
245
267
|
const resolvedConfig = api.useResolvedConfigContext();
|
246
|
-
const { generateCode } = await Promise.resolve().then(() =>
|
247
|
-
const entrypoints = (0,
|
268
|
+
const { generateCode } = await Promise.resolve().then(() => __toESM(require("./generateCode")));
|
269
|
+
const entrypoints = (0, import_lodash.cloneDeep)(originEntrypoints);
|
248
270
|
generateCode(appContext, resolvedConfig, entrypoints, api);
|
249
271
|
}
|
250
272
|
}
|
@@ -1,25 +1,46 @@
|
|
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 isDefaultExportFunction_exports = {};
|
30
|
+
__export(isDefaultExportFunction_exports, {
|
31
|
+
isDefaultExportFunction: () => isDefaultExportFunction
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const
|
17
|
-
const isFunction = (node) => _types.isFunctionDeclaration(node) || _types.isFunctionExpression(node) || _types.isArrowFunctionExpression(node);
|
33
|
+
module.exports = __toCommonJS(isDefaultExportFunction_exports);
|
34
|
+
var import_fs = __toESM(require("fs"));
|
35
|
+
var import_parser = require("@babel/parser");
|
36
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
37
|
+
var t = __toESM(require("@babel/types"));
|
38
|
+
const isFunction = (node) => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
18
39
|
const isDefaultExportFunction = (file) => {
|
19
|
-
if (!file || !
|
40
|
+
if (!file || !import_fs.default.existsSync(file)) {
|
20
41
|
return false;
|
21
42
|
}
|
22
|
-
const ast = (0,
|
43
|
+
const ast = (0, import_parser.parse)(import_fs.default.readFileSync(file, "utf8"), {
|
23
44
|
sourceType: "unambiguous",
|
24
45
|
plugins: [
|
25
46
|
"jsx",
|
@@ -44,7 +65,7 @@ const isDefaultExportFunction = (file) => {
|
|
44
65
|
]
|
45
66
|
});
|
46
67
|
let isExportFunction = false;
|
47
|
-
(0,
|
68
|
+
(0, import_traverse.default)(ast, {
|
48
69
|
ExportDefaultDeclaration: (path) => {
|
49
70
|
const { declaration } = path.node;
|
50
71
|
if (isFunction(declaration)) {
|
@@ -54,3 +75,7 @@ const isDefaultExportFunction = (file) => {
|
|
54
75
|
});
|
55
76
|
return isExportFunction;
|
56
77
|
};
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
79
|
+
0 && (module.exports = {
|
80
|
+
isDefaultExportFunction
|
81
|
+
});
|
@@ -1,13 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
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) => {
|
7
|
+
for (var name in all)
|
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 });
|
9
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var makeLegalIdentifier_exports = {};
|
20
|
+
__export(makeLegalIdentifier_exports, {
|
21
|
+
makeLegalIdentifier: () => makeLegalIdentifier
|
10
22
|
});
|
23
|
+
module.exports = __toCommonJS(makeLegalIdentifier_exports);
|
11
24
|
const reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
|
12
25
|
const builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
|
13
26
|
const forbidList = new Set(`${reservedWords} ${builtins}`.split(" "));
|
@@ -18,3 +31,7 @@ function makeLegalIdentifier(str) {
|
|
18
31
|
}
|
19
32
|
return identifier || "_";
|
20
33
|
}
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
35
|
+
0 && (module.exports = {
|
36
|
+
makeLegalIdentifier
|
37
|
+
});
|