@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
@@ -7,11 +7,11 @@ import path from "path";
|
|
7
7
|
import { fs, getEntryOptions, isSSGEntry, slash } from "@modern-js/utils";
|
8
8
|
import { APP_CONFIG_NAME, TEMP_LOADERS_DIR } from "./constants";
|
9
9
|
import { getServerLoadersFile } from "./utils";
|
10
|
-
|
10
|
+
var index = function(param) {
|
11
11
|
var mountId = param.mountId, imports = param.imports, renderFunction2 = param.renderFunction, exportStatement = param.exportStatement;
|
12
12
|
return "\nconst IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';\nconst IS_REACT18 = process.env.IS_REACT18 === 'true';\nconst MOUNT_ID = '".concat(mountId, "';\n\n").concat(imports, "\n\nlet AppWrapper = null;\n\nlet root = null;\n\nfunction render() {\n ").concat(renderFunction2, "\n}\n\nAppWrapper = render();\n\n").concat(exportStatement, ";\n");
|
13
13
|
};
|
14
|
-
|
14
|
+
var renderFunction = function(param) {
|
15
15
|
var plugins = param.plugins, customBootstrap = param.customBootstrap, fileSystemRoutes2 = param.fileSystemRoutes;
|
16
16
|
var bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
|
17
17
|
return "\n const finalAppConfig = {\n ...App.config,\n ...typeof ".concat(APP_CONFIG_NAME, " === 'function' ? ").concat(APP_CONFIG_NAME, "() : {},\n }\n\n AppWrapper = createApp({\n plugins: [\n ").concat(plugins.map(function(param2) {
|
@@ -19,28 +19,46 @@ export var renderFunction = function(param) {
|
|
19
19
|
return "".concat(name, "({...").concat(options, ", ...finalAppConfig?.").concat(args || name, "}),");
|
20
20
|
}).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper, () => ".concat(bootstrap, ");") : "".concat(bootstrap, ";"), "\n }\n\n return AppWrapper\n");
|
21
21
|
};
|
22
|
-
|
22
|
+
var html = function(partials) {
|
23
23
|
return "\n<!DOCTYPE html>\n<html>\n<head>\n <%= meta %>\n <title><%= title %></title>\n\n ".concat(partials.top.join("\n"), "\n\n ").concat(partials.head.join("\n"), '\n\n</head>\n\n<body>\n <div id="<%= mountId %>"><!--<?- html ?>--></div>\n ').concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
|
24
24
|
};
|
25
|
-
|
25
|
+
var routesForServer = function(param) {
|
26
26
|
var routes = param.routes;
|
27
27
|
var loaders = [];
|
28
|
+
var actions = [];
|
29
|
+
var loadersMap = {};
|
28
30
|
var traverseRouteTree = function(route2) {
|
29
31
|
var children;
|
30
32
|
if ("children" in route2 && route2.children) {
|
31
|
-
var _route_children
|
32
|
-
children =
|
33
|
+
var _route_children;
|
34
|
+
children = route2 === null || route2 === void 0 ? void 0 : (_route_children = route2.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
|
33
35
|
}
|
34
36
|
var loader;
|
37
|
+
var action;
|
35
38
|
if (route2.type === "nested") {
|
36
|
-
if (route2.loader) {
|
39
|
+
if (route2.loader || route2.data) {
|
37
40
|
loaders.push(route2.loader);
|
38
|
-
|
41
|
+
var loaderId = loaders.length - 1;
|
42
|
+
loader = "loader_".concat(loaderId);
|
43
|
+
var inline = Boolean(route2.data);
|
44
|
+
loadersMap[loader] = {
|
45
|
+
loaderId,
|
46
|
+
routeId: route2.id,
|
47
|
+
filePath: route2.data || route2.loader,
|
48
|
+
clientData: Boolean(route2.clientData),
|
49
|
+
route: route2,
|
50
|
+
inline
|
51
|
+
};
|
52
|
+
if (route2.action) {
|
53
|
+
actions.push(route2.action);
|
54
|
+
action = "action_".concat(loaders.length - 1);
|
55
|
+
}
|
39
56
|
}
|
40
57
|
}
|
41
58
|
var finalRoute = _object_spread_props(_object_spread({}, route2), {
|
42
|
-
loader
|
43
|
-
|
59
|
+
loader,
|
60
|
+
action,
|
61
|
+
children
|
44
62
|
});
|
45
63
|
return finalRoute;
|
46
64
|
};
|
@@ -50,8 +68,16 @@ export var routesForServer = function(param) {
|
|
50
68
|
for (var _iterator = routes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
51
69
|
var route = _step.value;
|
52
70
|
if ("type" in route) {
|
71
|
+
var keywords = [
|
72
|
+
"loader",
|
73
|
+
"action"
|
74
|
+
];
|
75
|
+
var regs = keywords.map(createMatchReg);
|
53
76
|
var newRoute = traverseRouteTree(route);
|
54
|
-
|
77
|
+
var routeStr = JSON.stringify(newRoute, null, 2);
|
78
|
+
routesCode += regs.reduce(function(acc, reg) {
|
79
|
+
return acc.replace(reg, "$1$2");
|
80
|
+
}, routeStr).replace(/\\"/g, '"');
|
55
81
|
} else {
|
56
82
|
routesCode += "".concat(JSON.stringify(route, null, 2));
|
57
83
|
}
|
@@ -72,19 +98,43 @@ export var routesForServer = function(param) {
|
|
72
98
|
}
|
73
99
|
routesCode += "\n];";
|
74
100
|
var importLoadersCode = "";
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
101
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
102
|
+
try {
|
103
|
+
for (var _iterator1 = Object.entries(loadersMap)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
104
|
+
var _step_value = _sliced_to_array(_step1.value, 2), key = _step_value[0], loaderInfo = _step_value[1];
|
105
|
+
if (loaderInfo.inline) {
|
106
|
+
var route1 = loaderInfo.route;
|
107
|
+
if (route1.action) {
|
108
|
+
importLoadersCode += "import { loader as ".concat(key, ", action as action_").concat(loaderInfo.loaderId, ' } from "').concat(slash(loaderInfo.filePath), '";\n');
|
109
|
+
} else {
|
110
|
+
importLoadersCode += "import { loader as ".concat(key, ' } from "').concat(slash(loaderInfo.filePath), '";\n');
|
111
|
+
}
|
112
|
+
} else {
|
113
|
+
importLoadersCode += "import ".concat(key, ' from "').concat(slash(loaderInfo.filePath), '";\n');
|
114
|
+
}
|
115
|
+
}
|
116
|
+
} catch (err) {
|
117
|
+
_didIteratorError1 = true;
|
118
|
+
_iteratorError1 = err;
|
119
|
+
} finally {
|
120
|
+
try {
|
121
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
122
|
+
_iterator1.return();
|
123
|
+
}
|
124
|
+
} finally {
|
125
|
+
if (_didIteratorError1) {
|
126
|
+
throw _iteratorError1;
|
127
|
+
}
|
128
|
+
}
|
79
129
|
}
|
80
130
|
return "\n ".concat(importLoadersCode, "\n ").concat(routesCode, "\n ");
|
81
131
|
};
|
82
132
|
var createMatchReg = function(keyword) {
|
83
133
|
return new RegExp('("'.concat(keyword, '":\\s)"([^,]+)"'), "g");
|
84
134
|
};
|
85
|
-
|
135
|
+
var fileSystemRoutes = function() {
|
86
136
|
var _ref = _async_to_generator(function(param) {
|
87
|
-
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, _param_splitRouteChunks, splitRouteChunks, components, loadings, errors, loaders, loadersMap, configs, configsMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, routeStr, keywords, regs, newRouteStr, component, finalRoute, keywords1, routeStr1, regs1, newRouteStr1, importLoadingCode, importComponentsCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo, importConfigsCode, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value1, key1, configPath;
|
137
|
+
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, _param_splitRouteChunks, splitRouteChunks, components, loadings, errors, loaders, loadersMap, configs, configsMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, routeStr, keywords, regs, newRouteStr, component, finalRoute, keywords1, routeStr1, regs1, newRouteStr1, importLoadingCode, importComponentsCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo, route1, importConfigsCode, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value1, key1, configPath;
|
88
138
|
return _ts_generator(this, function(_state) {
|
89
139
|
switch (_state.label) {
|
90
140
|
case 0:
|
@@ -99,25 +149,27 @@ export var fileSystemRoutes = function() {
|
|
99
149
|
loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "map.json");
|
100
150
|
importLazyCode = '\n import { lazy } from "react";\n import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"\n ';
|
101
151
|
rootLayoutCode = "";
|
102
|
-
getDataLoaderPath = function(
|
152
|
+
getDataLoaderPath = function(param2) {
|
153
|
+
var loaderId = param2.loaderId, clientData = param2.clientData, action = param2.action, inline = param2.inline, routeId = param2.routeId;
|
103
154
|
if (!ssrMode) {
|
104
155
|
return "";
|
105
156
|
}
|
106
157
|
var clientDataStr = clientData ? "&clientData=".concat(clientData) : "";
|
107
158
|
if (nestedRoutesEntry) {
|
108
|
-
return "?
|
159
|
+
return "?loaderId=".concat(loaderId).concat(clientDataStr, "&action=").concat(action, "&inline=").concat(inline, "&routeId=").concat(routeId);
|
109
160
|
}
|
110
161
|
return "";
|
111
162
|
};
|
112
163
|
traverseRouteTree = function(route2) {
|
113
164
|
var children;
|
114
165
|
if ("children" in route2 && route2.children) {
|
115
|
-
var _route_children
|
116
|
-
children =
|
166
|
+
var _route_children;
|
167
|
+
children = route2 === null || route2 === void 0 ? void 0 : (_route_children = route2.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
|
117
168
|
}
|
118
169
|
var loading;
|
119
170
|
var error;
|
120
171
|
var loader;
|
172
|
+
var action;
|
121
173
|
var config;
|
122
174
|
var component2 = "";
|
123
175
|
var lazyImport = null;
|
@@ -134,13 +186,19 @@ export var fileSystemRoutes = function() {
|
|
134
186
|
loaders.push(route2.loader);
|
135
187
|
var loaderId = loaders.length - 1;
|
136
188
|
loader = "loader_".concat(loaderId);
|
189
|
+
var inline = Boolean(route2.data);
|
137
190
|
loadersMap[loader] = {
|
191
|
+
loaderId,
|
138
192
|
routeId: route2.id,
|
139
193
|
filePath: route2.data || route2.loader,
|
140
194
|
clientData: Boolean(route2.clientData),
|
141
|
-
|
195
|
+
route: route2,
|
196
|
+
inline
|
142
197
|
};
|
143
198
|
loader = "loader_".concat(loaderId);
|
199
|
+
if (route2.action) {
|
200
|
+
action = "action_".concat(loaderId);
|
201
|
+
}
|
144
202
|
}
|
145
203
|
if (typeof route2.config === "string") {
|
146
204
|
configs.push(route2.config);
|
@@ -154,10 +212,10 @@ export var fileSystemRoutes = function() {
|
|
154
212
|
rootLayoutCode = "import RootLayout from '".concat(route2._component, "'");
|
155
213
|
component2 = "RootLayout";
|
156
214
|
} else if (ssrMode === "string") {
|
157
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, "
|
215
|
+
lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, `" */ '`).concat(route2._component, "')");
|
158
216
|
component2 = "loadable(".concat(lazyImport, ")");
|
159
217
|
} else {
|
160
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, "
|
218
|
+
lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, `" */ '`).concat(route2._component, "')");
|
161
219
|
component2 = "lazy(".concat(lazyImport, ")");
|
162
220
|
}
|
163
221
|
} else {
|
@@ -175,12 +233,13 @@ export var fileSystemRoutes = function() {
|
|
175
233
|
}
|
176
234
|
}
|
177
235
|
var finalRoute2 = _object_spread_props(_object_spread({}, route2), {
|
178
|
-
lazyImport
|
179
|
-
loading
|
180
|
-
loader
|
181
|
-
|
182
|
-
|
183
|
-
|
236
|
+
lazyImport,
|
237
|
+
loading,
|
238
|
+
loader,
|
239
|
+
action,
|
240
|
+
config,
|
241
|
+
error,
|
242
|
+
children
|
184
243
|
});
|
185
244
|
if (route2._component) {
|
186
245
|
finalRoute2.component = component2;
|
@@ -199,6 +258,7 @@ export var fileSystemRoutes = function() {
|
|
199
258
|
"component",
|
200
259
|
"lazyImport",
|
201
260
|
"loader",
|
261
|
+
"action",
|
202
262
|
"loading",
|
203
263
|
"error",
|
204
264
|
"config"
|
@@ -211,7 +271,7 @@ export var fileSystemRoutes = function() {
|
|
211
271
|
} else {
|
212
272
|
component = "loadable(() => import('".concat(route._component, "'))");
|
213
273
|
finalRoute = _object_spread_props(_object_spread({}, route), {
|
214
|
-
component
|
274
|
+
component
|
215
275
|
});
|
216
276
|
keywords1 = [
|
217
277
|
"component",
|
@@ -255,9 +315,32 @@ export var fileSystemRoutes = function() {
|
|
255
315
|
for (_iterator1 = Object.entries(loadersMap)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
256
316
|
_step_value = _sliced_to_array(_step1.value, 2), key = _step_value[0], loaderInfo = _step_value[1];
|
257
317
|
if (loaderInfo.inline) {
|
258
|
-
|
318
|
+
route1 = loaderInfo.route;
|
319
|
+
if (route1.action) {
|
320
|
+
importLoadersCode += "import { loader as ".concat(key, ", action as action_").concat(loaderInfo.loaderId, ' } from "').concat(slash(loaderInfo.filePath)).concat(getDataLoaderPath({
|
321
|
+
loaderId: key,
|
322
|
+
clientData: loaderInfo.clientData,
|
323
|
+
action: route1.action,
|
324
|
+
inline: loaderInfo.inline,
|
325
|
+
routeId: loaderInfo.routeId
|
326
|
+
}), '";\n');
|
327
|
+
} else {
|
328
|
+
importLoadersCode += "import { loader as ".concat(key, ' } from "').concat(slash(loaderInfo.filePath)).concat(getDataLoaderPath({
|
329
|
+
loaderId: key,
|
330
|
+
clientData: loaderInfo.clientData,
|
331
|
+
action: false,
|
332
|
+
inline: loaderInfo.inline,
|
333
|
+
routeId: route1.id
|
334
|
+
}), '";\n');
|
335
|
+
}
|
259
336
|
} else {
|
260
|
-
importLoadersCode += "import ".concat(key, ' from "').concat(slash(loaderInfo.filePath)).concat(getDataLoaderPath(
|
337
|
+
importLoadersCode += "import ".concat(key, ' from "').concat(slash(loaderInfo.filePath)).concat(getDataLoaderPath({
|
338
|
+
loaderId: key,
|
339
|
+
clientData: loaderInfo.clientData,
|
340
|
+
action: false,
|
341
|
+
inline: loaderInfo.inline,
|
342
|
+
routeId: loaderInfo.routeId
|
343
|
+
}), '";\n');
|
261
344
|
}
|
262
345
|
}
|
263
346
|
} catch (err) {
|
@@ -318,7 +401,7 @@ export var fileSystemRoutes = function() {
|
|
318
401
|
return _ref.apply(this, arguments);
|
319
402
|
};
|
320
403
|
}();
|
321
|
-
|
404
|
+
function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext) {
|
322
405
|
var entryName = entrypoint.entryName, isMainEntry = entrypoint.isMainEntry;
|
323
406
|
var packageName = appContext.packageName, internalDirectory = appContext.internalDirectory;
|
324
407
|
var ssr = getEntryOptions(entryName, isMainEntry, config.server.ssr, config.server.ssrByEntries, packageName);
|
@@ -331,3 +414,11 @@ export function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appCont
|
|
331
414
|
}
|
332
415
|
return null;
|
333
416
|
}
|
417
|
+
export {
|
418
|
+
fileSystemRoutes,
|
419
|
+
html,
|
420
|
+
index,
|
421
|
+
renderFunction,
|
422
|
+
routesForServer,
|
423
|
+
ssrLoaderCombinedModule
|
424
|
+
};
|
@@ -7,8 +7,8 @@ import path from "path";
|
|
7
7
|
import { isReact18, normalizeToPosixPath, fs as fse, getCommand } from "@modern-js/utils";
|
8
8
|
import { transform } from "esbuild";
|
9
9
|
import { parse } from "es-module-lexer";
|
10
|
-
import { FILE_SYSTEM_ROUTES_FILE_NAME, JS_EXTENSIONS, LOADER_EXPORT_NAME } from "./constants";
|
11
|
-
|
10
|
+
import { ACTION_EXPORT_NAME, FILE_SYSTEM_ROUTES_FILE_NAME, JS_EXTENSIONS, LOADER_EXPORT_NAME } from "./constants";
|
11
|
+
var walkDirectory = function(dir) {
|
12
12
|
return fs.readdirSync(dir).reduce(function(previous, filename) {
|
13
13
|
var filePath = path.join(dir, filename);
|
14
14
|
if (fs.statSync(filePath).isDirectory()) {
|
@@ -20,7 +20,7 @@ export var walkDirectory = function(dir) {
|
|
20
20
|
}
|
21
21
|
}, []);
|
22
22
|
};
|
23
|
-
|
23
|
+
var getDefaultImports = function(param) {
|
24
24
|
var entrypoint = param.entrypoint, srcDirectory = param.srcDirectory, internalSrcAlias = param.internalSrcAlias, internalDirAlias = param.internalDirAlias, internalDirectory = param.internalDirectory;
|
25
25
|
var entryName = entrypoint.entryName, fileSystemRoutes = entrypoint.fileSystemRoutes, customBootstrap = entrypoint.customBootstrap, entry = entrypoint.entry;
|
26
26
|
var imports = [
|
@@ -94,7 +94,7 @@ export var getDefaultImports = function(param) {
|
|
94
94
|
}
|
95
95
|
return imports;
|
96
96
|
};
|
97
|
-
|
97
|
+
var isPageComponentFile = function(filePath) {
|
98
98
|
if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
|
99
99
|
return false;
|
100
100
|
}
|
@@ -108,14 +108,14 @@ export var isPageComponentFile = function(filePath) {
|
|
108
108
|
}
|
109
109
|
return false;
|
110
110
|
};
|
111
|
-
|
111
|
+
var replaceWithAlias = function(base, filePath, alias) {
|
112
112
|
if (filePath.includes(base)) {
|
113
113
|
return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
114
114
|
} else {
|
115
115
|
return filePath;
|
116
116
|
}
|
117
117
|
};
|
118
|
-
|
118
|
+
var parseModule = function() {
|
119
119
|
var _ref = _async_to_generator(function(param) {
|
120
120
|
var source, filename, content, result;
|
121
121
|
return _ts_generator(this, function(_state) {
|
@@ -158,26 +158,39 @@ export var parseModule = function() {
|
|
158
158
|
return _ref.apply(this, arguments);
|
159
159
|
};
|
160
160
|
}();
|
161
|
-
|
162
|
-
var _ref = _async_to_generator(function(filename) {
|
163
|
-
var
|
161
|
+
var hasLoader = function() {
|
162
|
+
var _ref = _async_to_generator(function(filename, source) {
|
163
|
+
var content, _ref2, moduleExports;
|
164
164
|
return _ts_generator(this, function(_state) {
|
165
165
|
switch (_state.label) {
|
166
166
|
case 0:
|
167
|
+
content = source;
|
168
|
+
if (!!source)
|
169
|
+
return [
|
170
|
+
3,
|
171
|
+
2
|
172
|
+
];
|
167
173
|
return [
|
168
174
|
4,
|
169
|
-
fse.readFile(filename)
|
175
|
+
fse.readFile(filename, "utf-8")
|
170
176
|
];
|
171
177
|
case 1:
|
172
|
-
|
178
|
+
content = _state.sent().toString();
|
179
|
+
_state.label = 2;
|
180
|
+
case 2:
|
181
|
+
if (!content)
|
182
|
+
return [
|
183
|
+
3,
|
184
|
+
4
|
185
|
+
];
|
173
186
|
return [
|
174
187
|
4,
|
175
188
|
parseModule({
|
176
|
-
source:
|
177
|
-
filename
|
189
|
+
source: content.toString(),
|
190
|
+
filename
|
178
191
|
})
|
179
192
|
];
|
180
|
-
case
|
193
|
+
case 3:
|
181
194
|
_ref2 = _sliced_to_array.apply(void 0, [
|
182
195
|
_state.sent(),
|
183
196
|
2
|
@@ -188,20 +201,80 @@ export var hasLoader = function() {
|
|
188
201
|
return e.n === LOADER_EXPORT_NAME;
|
189
202
|
})
|
190
203
|
];
|
204
|
+
case 4:
|
205
|
+
return [
|
206
|
+
2,
|
207
|
+
false
|
208
|
+
];
|
191
209
|
}
|
192
210
|
});
|
193
211
|
});
|
194
|
-
return function hasLoader2(filename) {
|
212
|
+
return function hasLoader2(filename, source) {
|
195
213
|
return _ref.apply(this, arguments);
|
196
214
|
};
|
197
215
|
}();
|
198
|
-
|
216
|
+
var hasAction = function() {
|
217
|
+
var _ref = _async_to_generator(function(filename, source) {
|
218
|
+
var content, _ref2, moduleExports;
|
219
|
+
return _ts_generator(this, function(_state) {
|
220
|
+
switch (_state.label) {
|
221
|
+
case 0:
|
222
|
+
content = source;
|
223
|
+
if (!!source)
|
224
|
+
return [
|
225
|
+
3,
|
226
|
+
2
|
227
|
+
];
|
228
|
+
return [
|
229
|
+
4,
|
230
|
+
fse.readFile(filename, "utf-8")
|
231
|
+
];
|
232
|
+
case 1:
|
233
|
+
content = _state.sent().toString();
|
234
|
+
_state.label = 2;
|
235
|
+
case 2:
|
236
|
+
if (!content)
|
237
|
+
return [
|
238
|
+
3,
|
239
|
+
4
|
240
|
+
];
|
241
|
+
return [
|
242
|
+
4,
|
243
|
+
parseModule({
|
244
|
+
source: content.toString(),
|
245
|
+
filename
|
246
|
+
})
|
247
|
+
];
|
248
|
+
case 3:
|
249
|
+
_ref2 = _sliced_to_array.apply(void 0, [
|
250
|
+
_state.sent(),
|
251
|
+
2
|
252
|
+
]), moduleExports = _ref2[1];
|
253
|
+
return [
|
254
|
+
2,
|
255
|
+
moduleExports.some(function(e) {
|
256
|
+
return e.n === ACTION_EXPORT_NAME;
|
257
|
+
})
|
258
|
+
];
|
259
|
+
case 4:
|
260
|
+
return [
|
261
|
+
2,
|
262
|
+
false
|
263
|
+
];
|
264
|
+
}
|
265
|
+
});
|
266
|
+
});
|
267
|
+
return function hasAction2(filename, source) {
|
268
|
+
return _ref.apply(this, arguments);
|
269
|
+
};
|
270
|
+
}();
|
271
|
+
var getServerLoadersFile = function(internalDirectory, entryName) {
|
199
272
|
return path.join(internalDirectory, entryName, "route-server-loaders.js");
|
200
273
|
};
|
201
|
-
|
274
|
+
var getServerCombinedModueFile = function(internalDirectory, entryName) {
|
202
275
|
return path.join(internalDirectory, entryName, "server-loader-combined.js");
|
203
276
|
};
|
204
|
-
|
277
|
+
var checkIsBuildCommands = function() {
|
205
278
|
var buildCommands = [
|
206
279
|
"dev",
|
207
280
|
"start",
|
@@ -213,3 +286,15 @@ export var checkIsBuildCommands = function() {
|
|
213
286
|
var command = getCommand();
|
214
287
|
return buildCommands.includes(command);
|
215
288
|
};
|
289
|
+
export {
|
290
|
+
checkIsBuildCommands,
|
291
|
+
getDefaultImports,
|
292
|
+
getServerCombinedModueFile,
|
293
|
+
getServerLoadersFile,
|
294
|
+
hasAction,
|
295
|
+
hasLoader,
|
296
|
+
isPageComponentFile,
|
297
|
+
parseModule,
|
298
|
+
replaceWithAlias,
|
299
|
+
walkDirectory
|
300
|
+
};
|
@@ -7,7 +7,7 @@ import path from "path";
|
|
7
7
|
import fs from "@modern-js/utils/fs-extra";
|
8
8
|
import { logger, removeTailSlash } from "@modern-js/utils";
|
9
9
|
import { createCopyInfo } from "../shared";
|
10
|
-
|
10
|
+
var builderPluginAdpaterCopy = function(options) {
|
11
11
|
return {
|
12
12
|
name: "builder-plugin-adapter-rspack-copy",
|
13
13
|
setup: function setup(api) {
|
@@ -156,3 +156,6 @@ function createConfigBuiltinCopy(options) {
|
|
156
156
|
}
|
157
157
|
];
|
158
158
|
}
|
159
|
+
export {
|
160
|
+
builderPluginAdpaterCopy
|
161
|
+
};
|
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
|
4
4
|
import { generateBuilder } from "../generator";
|
5
5
|
import { builderPluginAdpaterCopy } from "./adapterCopy";
|
6
|
-
|
6
|
+
function createRspackBuilderForModern(options) {
|
7
7
|
return _createRspackBuilderForModern.apply(this, arguments);
|
8
8
|
}
|
9
9
|
function _createRspackBuilderForModern() {
|
@@ -30,3 +30,6 @@ function _createRspackBuilderForModern() {
|
|
30
30
|
});
|
31
31
|
return _createRspackBuilderForModern.apply(this, arguments);
|
32
32
|
}
|
33
|
+
export {
|
34
|
+
createRspackBuilderForModern
|
35
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
2
2
|
import { join } from "path";
|
3
3
|
import { createPublicPattern } from "./createCopyPattern";
|
4
|
-
|
4
|
+
var builderPluginAdapterModern = function(options) {
|
5
5
|
return {
|
6
6
|
name: "builder-plugin-adapter-modern",
|
7
7
|
setup: function setup(api) {
|
@@ -26,3 +26,6 @@ export var builderPluginAdapterModern = function(options) {
|
|
26
26
|
}
|
27
27
|
};
|
28
28
|
};
|
29
|
+
export {
|
30
|
+
builderPluginAdapterModern
|
31
|
+
};
|
@@ -9,10 +9,10 @@ var info = function(file) {
|
|
9
9
|
minimized: minifiedJsRexExp.test(file.sourceFilename)
|
10
10
|
};
|
11
11
|
};
|
12
|
-
|
12
|
+
function createPublicPattern(appContext, config, chain) {
|
13
13
|
var publicDir = createCopyInfo(appContext, config).publicDir;
|
14
14
|
return {
|
15
|
-
info
|
15
|
+
info,
|
16
16
|
from: "**/*",
|
17
17
|
to: "public",
|
18
18
|
context: publicDir,
|
@@ -26,13 +26,17 @@ export function createPublicPattern(appContext, config, chain) {
|
|
26
26
|
}
|
27
27
|
};
|
28
28
|
}
|
29
|
-
|
29
|
+
function createUploadPattern(appContext, config) {
|
30
30
|
var uploadDir = createCopyInfo(appContext, config).uploadDir;
|
31
31
|
return {
|
32
|
-
info
|
32
|
+
info,
|
33
33
|
from: "**/*",
|
34
34
|
to: "upload",
|
35
35
|
context: uploadDir,
|
36
36
|
noErrorOnMissing: true
|
37
37
|
};
|
38
38
|
}
|
39
|
+
export {
|
40
|
+
createPublicPattern,
|
41
|
+
createUploadPattern
|
42
|
+
};
|
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
|
4
4
|
import { generateBuilder } from "../generator";
|
5
5
|
import { builderPluginAdapterModern } from "./adapterModern";
|
6
|
-
|
6
|
+
function createWebpackBuilderForModern(options) {
|
7
7
|
return _createWebpackBuilderForModern.apply(this, arguments);
|
8
8
|
}
|
9
9
|
function _createWebpackBuilderForModern() {
|
@@ -48,3 +48,6 @@ function _createWebpackBuilderForModern() {
|
|
48
48
|
});
|
49
49
|
return _createWebpackBuilderForModern.apply(this, arguments);
|
50
50
|
}
|
51
|
+
export {
|
52
|
+
createWebpackBuilderForModern
|
53
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
function createBuilderOptions(target, appContext) {
|
2
2
|
var entries = {};
|
3
3
|
var _appContext_entrypoints = appContext.entrypoints, entrypoints = _appContext_entrypoints === void 0 ? [] : _appContext_entrypoints, checkedEntries = appContext.checkedEntries;
|
4
4
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
@@ -33,9 +33,12 @@ export function createBuilderOptions(target, appContext) {
|
|
33
33
|
}
|
34
34
|
return {
|
35
35
|
cwd: appContext.appDirectory,
|
36
|
-
target
|
36
|
+
target,
|
37
37
|
configPath: appContext.configFile || void 0,
|
38
38
|
entry: entries,
|
39
39
|
framework: appContext.metaName
|
40
40
|
};
|
41
41
|
}
|
42
|
+
export {
|
43
|
+
createBuilderOptions
|
44
|
+
};
|
@@ -3,10 +3,9 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
4
4
|
import { createUploadPattern } from "../builder-webpack/createCopyPattern";
|
5
5
|
function modifyOutputConfig(config, appContext) {
|
6
|
-
var _copy;
|
7
6
|
var defaultCopyPattern = createUploadPattern(appContext, config);
|
8
7
|
var copy = config.output.copy;
|
9
|
-
var copyOptions = Array.isArray(copy) ? copy :
|
8
|
+
var copyOptions = Array.isArray(copy) ? copy : copy === null || copy === void 0 ? void 0 : copy.patterns;
|
10
9
|
var builderCopy = _to_consumable_array(copyOptions || []).concat([
|
11
10
|
defaultCopyPattern
|
12
11
|
]);
|
@@ -14,7 +13,7 @@ function modifyOutputConfig(config, appContext) {
|
|
14
13
|
copy: builderCopy
|
15
14
|
});
|
16
15
|
}
|
17
|
-
|
16
|
+
function createBuilderProviderConfig(resolveConfig, appContext) {
|
18
17
|
var htmlConfig = _object_spread({}, resolveConfig.html);
|
19
18
|
if (!htmlConfig.template) {
|
20
19
|
htmlConfig.templateByEntries = _object_spread({}, appContext.htmlTemplates, htmlConfig.templateByEntries);
|
@@ -32,3 +31,6 @@ export function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
32
31
|
modifyOutputConfig(config, appContext);
|
33
32
|
return config;
|
34
33
|
}
|
34
|
+
export {
|
35
|
+
createBuilderProviderConfig
|
36
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
|
2
|
-
|
2
|
+
function getBuilderTargets(normalizedConfig) {
|
3
3
|
var targets = [
|
4
4
|
"web"
|
5
5
|
];
|
@@ -13,3 +13,6 @@ export function getBuilderTargets(normalizedConfig) {
|
|
13
13
|
}
|
14
14
|
return targets;
|
15
15
|
}
|
16
|
+
export {
|
17
|
+
getBuilderTargets
|
18
|
+
};
|