@modern-js/app-tools 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/dist/{js/node → cjs}/analyze/constants.js +0 -0
- package/dist/cjs/analyze/generateCode.js +249 -0
- package/dist/{js/node → cjs}/analyze/getBundleEntry.js +6 -0
- package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutes.js +1 -18
- package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutesLegacy.js +1 -18
- package/dist/{js/node → cjs}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/node → cjs}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/node → cjs}/analyze/getFileSystemEntry.js +0 -0
- package/dist/{js/node → cjs}/analyze/getHtmlTemplate.js +4 -24
- package/dist/{js/node → cjs}/analyze/getServerRoutes.js +22 -42
- package/dist/cjs/analyze/index.js +290 -0
- package/dist/{js/node → cjs}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/node → cjs}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/node → cjs}/analyze/nestedRoutes.js +16 -50
- package/dist/{js/node → cjs}/analyze/templates.js +16 -49
- package/dist/{js/node → cjs}/analyze/utils.js +9 -29
- package/dist/{js/node → cjs}/builder/builder-rspack/index.js +0 -0
- package/dist/{js/node → cjs}/builder/builder-webpack/builderPlugins/compatModern.js +0 -0
- package/dist/{js/node → cjs}/builder/builder-webpack/index.js +22 -62
- package/dist/{js/node → cjs}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +7 -24
- package/dist/{js/node → cjs}/builder/builder-webpack/webpackPlugins/index.js +0 -0
- package/dist/{js/node → cjs}/builder/generator/createBuilderOptions.js +0 -0
- package/dist/{js/node → cjs}/builder/generator/createBuilderProviderConfig.js +14 -25
- package/dist/{js/node → cjs}/builder/generator/getBuilderTargets.js +4 -0
- package/dist/cjs/builder/generator/index.js +58 -0
- package/dist/{js/node → cjs}/builder/index.js +12 -34
- package/dist/{js/node → cjs}/builder/shared/builderPlugins/adapterModern.js +35 -34
- package/dist/{js/node → cjs}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/createCopyPattern.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/index.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/types.js +0 -0
- package/dist/{js/node → cjs}/commands/build.js +9 -46
- package/dist/cjs/commands/deploy.js +31 -0
- package/dist/{js/node → cjs}/commands/dev.js +17 -52
- package/dist/{js/node → cjs}/commands/index.js +0 -0
- package/dist/{js/node → cjs}/commands/inspect.js +2 -22
- package/dist/{js/node → cjs}/commands/serve.js +8 -28
- package/dist/{js/node → cjs}/config/default.js +15 -26
- package/dist/{js/node → cjs}/config/index.js +0 -0
- package/dist/{js/node → cjs}/config/initialize/index.js +0 -0
- package/dist/{js/node → cjs}/config/initialize/inits.js +4 -20
- package/dist/{js/node → cjs}/config/legacy/createHtmlConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/createOutputConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/createSourceConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/createToolsConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/index.js +0 -0
- package/dist/cjs/defineConfig.js +33 -0
- package/dist/{js/node → cjs}/exports/server.js +0 -0
- package/dist/{js/node → cjs}/hooks.js +0 -0
- package/dist/cjs/index.js +198 -0
- package/dist/cjs/initialize/index.js +102 -0
- package/dist/{js/node → cjs}/locale/en.js +0 -0
- package/dist/{js/node → cjs}/locale/index.js +0 -0
- package/dist/{js/node → cjs}/locale/zh.js +0 -0
- package/dist/{js/node → cjs}/schema/Schema.js +0 -0
- package/dist/{js/node → cjs}/schema/index.js +0 -0
- package/dist/{js/node → cjs}/schema/legacy.js +0 -0
- package/dist/{js/node → cjs}/types/config/deploy.js +0 -0
- package/dist/{js/node → cjs}/types/config/dev.js +0 -0
- package/dist/{js/node → cjs}/types/config/experiments.js +0 -0
- package/dist/{js/node → cjs}/types/config/html.js +0 -0
- package/dist/{js/node → cjs}/types/config/index.js +0 -0
- package/dist/{js/node → cjs}/types/config/output.js +0 -0
- package/dist/{js/node → cjs}/types/config/performance.js +0 -0
- package/dist/{js/node → cjs}/types/config/security.js +0 -0
- package/dist/{js/node → cjs}/types/config/source.js +0 -0
- package/dist/{js/node → cjs}/types/config/tools.js +0 -0
- package/dist/{js/node → cjs}/types/hooks.js +0 -0
- package/dist/{js/node → cjs}/types/index.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/index.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/output.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/source.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/tools.js +0 -0
- package/dist/{js/node → cjs}/types/utils.js +0 -0
- package/dist/{js/node → cjs}/utils/config.js +19 -57
- package/dist/{js/node → cjs}/utils/createServer.js +10 -46
- package/dist/{js/node → cjs}/utils/env.js +0 -0
- package/dist/{js/node → cjs}/utils/generateWatchFiles.js +16 -38
- package/dist/{js/node → cjs}/utils/getSelectedEntries.js +3 -23
- package/dist/cjs/utils/getServerInternalPlugins.js +41 -0
- package/dist/{js/node → cjs}/utils/language.js +0 -0
- package/dist/{js/node → cjs}/utils/printInstructions.js +3 -23
- package/dist/cjs/utils/restart.js +45 -0
- package/dist/{js/node → cjs}/utils/routes.js +3 -23
- package/dist/{js/node → cjs}/utils/types.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/constants.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/generateCode.js +14 -14
- package/dist/{js/treeshaking → esm}/analyze/getBundleEntry.js +4 -2
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getFileSystemEntry.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getHtmlTemplate.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getServerRoutes.js +8 -6
- package/dist/{js/treeshaking → esm}/analyze/index.js +8 -8
- package/dist/{js/treeshaking → esm}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/nestedRoutes.js +5 -5
- package/dist/{js/treeshaking → esm}/analyze/templates.js +8 -7
- package/dist/{js/treeshaking → esm}/analyze/utils.js +3 -3
- package/dist/{js/treeshaking → esm}/builder/builder-rspack/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/builderPlugins/compatModern.js +4 -4
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/index.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +5 -2
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/webpackPlugins/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/generator/createBuilderOptions.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/generator/createBuilderProviderConfig.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/generator/getBuilderTargets.js +5 -1
- package/dist/{js/treeshaking → esm}/builder/generator/index.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/builderPlugins/adapterModern.js +62 -13
- package/dist/{js/treeshaking → esm}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/shared/createCopyPattern.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/types.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/build.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/dev.js +2 -2
- package/dist/{js/treeshaking → esm}/commands/index.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/inspect.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/serve.js +2 -2
- package/dist/{js/treeshaking → esm}/config/default.js +0 -0
- package/dist/{js/treeshaking → esm}/config/index.js +0 -0
- package/dist/{js/treeshaking → esm}/config/initialize/index.js +0 -0
- package/dist/{js/treeshaking → esm}/config/initialize/inits.js +2 -2
- package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
- package/dist/{js/treeshaking → esm}/config/legacy/createOutputConfig.js +1 -1
- package/dist/{js/treeshaking → esm}/config/legacy/createSourceConfig.js +1 -1
- package/dist/{js/treeshaking → esm}/config/legacy/createToolsConfig.js +1 -1
- package/dist/{js/treeshaking → esm}/config/legacy/index.js +0 -0
- package/dist/{js/treeshaking → esm}/defineConfig.js +0 -0
- package/dist/{js/treeshaking → esm}/exports/server.js +0 -0
- package/dist/{js/treeshaking → esm}/hooks.js +0 -0
- package/dist/{js/treeshaking → esm}/index.js +0 -0
- package/dist/{js/treeshaking → esm}/initialize/index.js +2 -2
- package/dist/{js/treeshaking → esm}/locale/en.js +0 -0
- package/dist/{js/treeshaking → esm}/locale/index.js +0 -0
- package/dist/{js/treeshaking → esm}/locale/zh.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/Schema.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/index.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/legacy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/dev.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/experiments.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/html.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/output.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/performance.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/security.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/source.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/tools.js +0 -0
- package/dist/{js/treeshaking → esm}/types/hooks.js +0 -0
- package/dist/{js/treeshaking → esm}/types/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/output.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/source.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/tools.js +0 -0
- package/dist/{js/treeshaking → esm}/types/utils.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/config.js +2 -2
- package/dist/{js/treeshaking → esm}/utils/createServer.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/env.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/generateWatchFiles.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/getSelectedEntries.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/getServerInternalPlugins.js +2 -2
- package/dist/{js/treeshaking → esm}/utils/language.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/printInstructions.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/restart.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/routes.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/types.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/constants.js +0 -0
- package/dist/esm-node/analyze/generateCode.js +225 -0
- package/dist/{js/modern → esm-node}/analyze/getBundleEntry.js +6 -0
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutes.js +1 -20
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutesLegacy.js +1 -20
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getFileSystemEntry.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getHtmlTemplate.js +4 -24
- package/dist/{js/modern → esm-node}/analyze/getServerRoutes.js +24 -45
- package/dist/esm-node/analyze/index.js +281 -0
- package/dist/{js/modern → esm-node}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/nestedRoutes.js +16 -52
- package/dist/{js/modern → esm-node}/analyze/templates.js +16 -51
- package/dist/{js/modern → esm-node}/analyze/utils.js +9 -29
- package/dist/{js/modern → esm-node}/builder/builder-rspack/index.js +0 -0
- package/dist/{js/modern → esm-node}/builder/builder-webpack/builderPlugins/compatModern.js +0 -0
- package/dist/esm-node/builder/builder-webpack/index.js +51 -0
- package/dist/{js/modern → esm-node}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +7 -24
- package/dist/{js/modern → esm-node}/builder/builder-webpack/webpackPlugins/index.js +0 -0
- package/dist/{js/modern → esm-node}/builder/generator/createBuilderOptions.js +0 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +26 -0
- package/dist/{js/modern → esm-node}/builder/generator/getBuilderTargets.js +10 -1
- package/dist/esm-node/builder/generator/index.js +29 -0
- package/dist/esm-node/builder/index.js +17 -0
- package/dist/{js/modern → esm-node}/builder/shared/builderPlugins/adapterModern.js +35 -36
- package/dist/{js/modern → esm-node}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/createCopyPattern.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/index.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +52 -0
- package/dist/esm-node/commands/deploy.js +8 -0
- package/dist/esm-node/commands/dev.js +72 -0
- package/dist/{js/modern → esm-node}/commands/index.js +0 -0
- package/dist/esm-node/commands/inspect.js +18 -0
- package/dist/{js/modern → esm-node}/commands/serve.js +8 -28
- package/dist/{js/modern → esm-node}/config/default.js +15 -28
- package/dist/{js/modern → esm-node}/config/index.js +0 -0
- package/dist/{js/modern → esm-node}/config/initialize/index.js +0 -0
- package/dist/{js/modern → esm-node}/config/initialize/inits.js +4 -22
- package/dist/{js/modern → esm-node}/config/legacy/createHtmlConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/createOutputConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/createSourceConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/createToolsConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/index.js +0 -0
- package/dist/esm-node/defineConfig.js +9 -0
- package/dist/{js/modern → esm-node}/exports/server.js +0 -0
- package/dist/{js/modern → esm-node}/hooks.js +0 -0
- package/dist/esm-node/index.js +172 -0
- package/dist/esm-node/initialize/index.js +91 -0
- package/dist/{js/modern → esm-node}/locale/en.js +0 -0
- package/dist/{js/modern → esm-node}/locale/index.js +0 -0
- package/dist/{js/modern → esm-node}/locale/zh.js +0 -0
- package/dist/{js/modern → esm-node}/schema/Schema.js +0 -0
- package/dist/{js/modern → esm-node}/schema/index.js +0 -0
- package/dist/{js/modern → esm-node}/schema/legacy.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/deploy.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/dev.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/experiments.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/html.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/output.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/performance.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/security.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/source.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/tools.js +0 -0
- package/dist/{js/modern → esm-node}/types/hooks.js +0 -0
- package/dist/{js/modern → esm-node}/types/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/output.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/source.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/tools.js +0 -0
- package/dist/{js/modern → esm-node}/types/utils.js +0 -0
- package/dist/esm-node/utils/config.js +88 -0
- package/dist/esm-node/utils/createServer.js +37 -0
- package/dist/{js/modern → esm-node}/utils/env.js +0 -0
- package/dist/esm-node/utils/generateWatchFiles.js +33 -0
- package/dist/{js/modern → esm-node}/utils/getSelectedEntries.js +3 -23
- package/dist/esm-node/utils/getServerInternalPlugins.js +18 -0
- package/dist/{js/modern → esm-node}/utils/language.js +0 -0
- package/dist/esm-node/utils/printInstructions.js +11 -0
- package/dist/esm-node/utils/restart.js +22 -0
- package/dist/esm-node/utils/routes.js +10 -0
- package/dist/{js/modern → esm-node}/utils/types.js +0 -0
- package/dist/types/types/config/tools.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +5 -4
- package/dist/types/types/index.d.ts +3 -1
- package/package.json +30 -31
- package/dist/js/modern/analyze/generateCode.js +0 -247
- package/dist/js/modern/analyze/index.js +0 -329
- package/dist/js/modern/builder/builder-webpack/index.js +0 -93
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
- package/dist/js/modern/builder/generator/index.js +0 -53
- package/dist/js/modern/builder/index.js +0 -39
- package/dist/js/modern/commands/build.js +0 -91
- package/dist/js/modern/commands/deploy.js +0 -28
- package/dist/js/modern/commands/dev.js +0 -109
- package/dist/js/modern/commands/inspect.js +0 -38
- package/dist/js/modern/defineConfig.js +0 -27
- package/dist/js/modern/index.js +0 -221
- package/dist/js/modern/initialize/index.js +0 -132
- package/dist/js/modern/utils/config.js +0 -128
- package/dist/js/modern/utils/createServer.js +0 -75
- package/dist/js/modern/utils/generateWatchFiles.js +0 -55
- package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
- package/dist/js/modern/utils/printInstructions.js +0 -31
- package/dist/js/modern/utils/restart.js +0 -44
- package/dist/js/modern/utils/routes.js +0 -30
- package/dist/js/node/analyze/generateCode.js +0 -271
- package/dist/js/node/analyze/index.js +0 -336
- package/dist/js/node/builder/generator/index.js +0 -82
- package/dist/js/node/commands/deploy.js +0 -51
- package/dist/js/node/defineConfig.js +0 -49
- package/dist/js/node/index.js +0 -245
- package/dist/js/node/initialize/index.js +0 -141
- package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
- package/dist/js/node/utils/restart.js +0 -67
- package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fs, getEntryOptions, logger } from "@modern-js/utils";
|
|
3
|
+
import {
|
|
4
|
+
useResolvedConfigContext
|
|
5
|
+
} from "@modern-js/core";
|
|
6
|
+
import * as templates from "./templates";
|
|
7
|
+
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
8
|
+
import {
|
|
9
|
+
FILE_SYSTEM_ROUTES_FILE_NAME,
|
|
10
|
+
ENTRY_POINT_FILE_NAME,
|
|
11
|
+
ENTRY_BOOTSTRAP_FILE_NAME
|
|
12
|
+
} from "./constants";
|
|
13
|
+
import { getDefaultImports, getServerLoadersFile } from "./utils";
|
|
14
|
+
import { walk } from "./nestedRoutes";
|
|
15
|
+
const createImportSpecifier = (specifiers) => {
|
|
16
|
+
let defaults = "";
|
|
17
|
+
const named = [];
|
|
18
|
+
for (const { local, imported } of specifiers) {
|
|
19
|
+
if (local && imported) {
|
|
20
|
+
named.push(`${imported} as ${local}`);
|
|
21
|
+
} else if (local) {
|
|
22
|
+
defaults = local;
|
|
23
|
+
} else {
|
|
24
|
+
named.push(imported);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (defaults && named.length) {
|
|
28
|
+
return `${defaults}, { ${named.join(", ")} }`;
|
|
29
|
+
} else if (defaults) {
|
|
30
|
+
return defaults;
|
|
31
|
+
} else {
|
|
32
|
+
return `{ ${named.join(", ")} }`;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const createImportStatements = (statements) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const deDuplicated = [];
|
|
38
|
+
const seen = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const { value, specifiers, initialize } of statements) {
|
|
40
|
+
if (!seen.has(value)) {
|
|
41
|
+
deDuplicated.push({
|
|
42
|
+
value,
|
|
43
|
+
specifiers,
|
|
44
|
+
initialize
|
|
45
|
+
});
|
|
46
|
+
seen.set(value, specifiers);
|
|
47
|
+
} else {
|
|
48
|
+
seen.get(value).push(...specifiers);
|
|
49
|
+
const modifyIndex = deDuplicated.findIndex((v) => v.value === value);
|
|
50
|
+
const originInitialize = (_b = (_a = deDuplicated[modifyIndex]) == null ? void 0 : _a.initialize) != null ? _b : "";
|
|
51
|
+
deDuplicated[modifyIndex].initialize = originInitialize.concat(
|
|
52
|
+
`
|
|
53
|
+
${initialize || ""}`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return deDuplicated.map(
|
|
58
|
+
({ value, specifiers, initialize }) => `import ${createImportSpecifier(specifiers)} from '${value}';
|
|
59
|
+
${initialize || ""}`
|
|
60
|
+
).join("\n");
|
|
61
|
+
};
|
|
62
|
+
const generateCode = async (appContext, config, entrypoints, api) => {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
const {
|
|
65
|
+
internalDirectory,
|
|
66
|
+
srcDirectory,
|
|
67
|
+
internalDirAlias,
|
|
68
|
+
internalSrcAlias,
|
|
69
|
+
packageName
|
|
70
|
+
} = appContext;
|
|
71
|
+
const hookRunners = api.useHookRunners();
|
|
72
|
+
const isV5 = typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
|
|
73
|
+
const { mountId } = config.html;
|
|
74
|
+
const getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
|
|
75
|
+
await Promise.all(entrypoints.map(generateEntryCode));
|
|
76
|
+
async function generateEntryCode(entrypoint) {
|
|
77
|
+
const { entryName, isAutoMount, customBootstrap, fileSystemRoutes } = entrypoint;
|
|
78
|
+
if (isAutoMount) {
|
|
79
|
+
if (fileSystemRoutes) {
|
|
80
|
+
let initialRoutes = [];
|
|
81
|
+
let nestedRoute = null;
|
|
82
|
+
if (entrypoint.entry) {
|
|
83
|
+
initialRoutes = getRoutes({
|
|
84
|
+
entrypoint,
|
|
85
|
+
srcDirectory,
|
|
86
|
+
srcAlias: internalSrcAlias,
|
|
87
|
+
internalDirectory,
|
|
88
|
+
internalDirAlias
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (entrypoint.nestedRoutesEntry) {
|
|
92
|
+
if (!isV5) {
|
|
93
|
+
nestedRoute = await walk(
|
|
94
|
+
entrypoint.nestedRoutesEntry,
|
|
95
|
+
entrypoint.nestedRoutesEntry,
|
|
96
|
+
{
|
|
97
|
+
name: internalSrcAlias,
|
|
98
|
+
basename: srcDirectory
|
|
99
|
+
},
|
|
100
|
+
entrypoint.entryName
|
|
101
|
+
);
|
|
102
|
+
if (nestedRoute) {
|
|
103
|
+
initialRoutes.unshift(nestedRoute);
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
logger.error("Nested routes is not supported in legacy mode.");
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const { routes } = await hookRunners.modifyFileSystemRoutes({
|
|
111
|
+
entrypoint,
|
|
112
|
+
routes: initialRoutes
|
|
113
|
+
});
|
|
114
|
+
const config2 = useResolvedConfigContext();
|
|
115
|
+
const ssr = getEntryOptions(
|
|
116
|
+
entryName,
|
|
117
|
+
config2.server.ssr,
|
|
118
|
+
config2.server.ssrByEntries,
|
|
119
|
+
packageName
|
|
120
|
+
);
|
|
121
|
+
let mode;
|
|
122
|
+
if (ssr) {
|
|
123
|
+
mode = typeof ssr === "object" ? ssr.mode || "string" : "string";
|
|
124
|
+
} else {
|
|
125
|
+
mode = false;
|
|
126
|
+
}
|
|
127
|
+
if (mode === "stream") {
|
|
128
|
+
const hasPageRoute = routes.some(
|
|
129
|
+
(route) => "type" in route && route.type === "page"
|
|
130
|
+
);
|
|
131
|
+
if (hasPageRoute) {
|
|
132
|
+
logger.error(
|
|
133
|
+
"Streaming ssr is not supported when pages dir exists"
|
|
134
|
+
);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const { code: code2 } = await hookRunners.beforeGenerateRoutes({
|
|
139
|
+
entrypoint,
|
|
140
|
+
code: await templates.fileSystemRoutes({
|
|
141
|
+
routes,
|
|
142
|
+
ssrMode: mode,
|
|
143
|
+
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
144
|
+
entryName: entrypoint.entryName,
|
|
145
|
+
internalDirectory
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
if (entrypoint.nestedRoutesEntry && mode) {
|
|
149
|
+
const routesServerFile = getServerLoadersFile(
|
|
150
|
+
internalDirectory,
|
|
151
|
+
entryName
|
|
152
|
+
);
|
|
153
|
+
const code3 = templates.routesForServer({
|
|
154
|
+
routes
|
|
155
|
+
});
|
|
156
|
+
await fs.ensureFile(routesServerFile);
|
|
157
|
+
await fs.writeFile(routesServerFile, code3);
|
|
158
|
+
}
|
|
159
|
+
fs.outputFileSync(
|
|
160
|
+
path.resolve(
|
|
161
|
+
internalDirectory,
|
|
162
|
+
`./${entryName}/${FILE_SYSTEM_ROUTES_FILE_NAME}`
|
|
163
|
+
),
|
|
164
|
+
code2,
|
|
165
|
+
"utf8"
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
const { imports: importStatements } = await hookRunners.modifyEntryImports({
|
|
169
|
+
entrypoint,
|
|
170
|
+
imports: getDefaultImports({
|
|
171
|
+
entrypoint,
|
|
172
|
+
srcDirectory,
|
|
173
|
+
internalSrcAlias,
|
|
174
|
+
internalDirAlias,
|
|
175
|
+
internalDirectory
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
const { plugins } = await hookRunners.modifyEntryRuntimePlugins({
|
|
179
|
+
entrypoint,
|
|
180
|
+
plugins: []
|
|
181
|
+
});
|
|
182
|
+
const { code: renderFunction } = await hookRunners.modifyEntryRenderFunction({
|
|
183
|
+
entrypoint,
|
|
184
|
+
code: templates.renderFunction({
|
|
185
|
+
plugins,
|
|
186
|
+
customBootstrap,
|
|
187
|
+
fileSystemRoutes
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
const { exportStatement } = await hookRunners.modifyEntryExport({
|
|
191
|
+
entrypoint,
|
|
192
|
+
exportStatement: "export default AppWrapper;"
|
|
193
|
+
});
|
|
194
|
+
const code = templates.index({
|
|
195
|
+
mountId,
|
|
196
|
+
imports: createImportStatements(importStatements),
|
|
197
|
+
renderFunction,
|
|
198
|
+
exportStatement
|
|
199
|
+
});
|
|
200
|
+
const entryFile = path.resolve(
|
|
201
|
+
internalDirectory,
|
|
202
|
+
`./${entryName}/${ENTRY_POINT_FILE_NAME}`
|
|
203
|
+
);
|
|
204
|
+
entrypoint.entry = entryFile;
|
|
205
|
+
if (config.source.enableAsyncEntry) {
|
|
206
|
+
const { code: asyncEntryCode } = await hookRunners.modifyAsyncEntry({
|
|
207
|
+
entrypoint,
|
|
208
|
+
code: `import('./${ENTRY_BOOTSTRAP_FILE_NAME}');`
|
|
209
|
+
});
|
|
210
|
+
fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
|
|
211
|
+
const bootstrapFile = path.resolve(
|
|
212
|
+
internalDirectory,
|
|
213
|
+
`./${entryName}/${ENTRY_BOOTSTRAP_FILE_NAME}`
|
|
214
|
+
);
|
|
215
|
+
fs.outputFileSync(bootstrapFile, code, "utf8");
|
|
216
|
+
} else {
|
|
217
|
+
fs.outputFileSync(entryFile, code, "utf8");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
export {
|
|
223
|
+
createImportStatements,
|
|
224
|
+
generateCode
|
|
225
|
+
};
|
|
@@ -40,11 +40,17 @@ const getBundleEntry = (appContext, config) => {
|
|
|
40
40
|
const entrypoint = typeof value === "string" ? {
|
|
41
41
|
entryName: name,
|
|
42
42
|
entry: ensureAbsolutePath(appDirectory, value),
|
|
43
|
+
absoluteEntryDir: path.dirname(
|
|
44
|
+
ensureAbsolutePath(appDirectory, value)
|
|
45
|
+
),
|
|
43
46
|
isAutoMount: true,
|
|
44
47
|
fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value)).isDirectory() ? {} : void 0
|
|
45
48
|
} : {
|
|
46
49
|
entryName: name,
|
|
47
50
|
entry: ensureAbsolutePath(appDirectory, value.entry),
|
|
51
|
+
absoluteEntryDir: path.dirname(
|
|
52
|
+
ensureAbsolutePath(appDirectory, value.entry)
|
|
53
|
+
),
|
|
48
54
|
isAutoMount: !value.disableMount,
|
|
49
55
|
customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
|
|
50
56
|
fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import path from "path";
|
|
21
2
|
import { fs } from "@modern-js/utils";
|
|
22
3
|
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
@@ -160,7 +141,7 @@ export default ${lastComponent}`
|
|
|
160
141
|
};
|
|
161
142
|
};
|
|
162
143
|
const normalized = flat(nested).map(
|
|
163
|
-
(route) => route.parent ?
|
|
144
|
+
(route) => route.parent ? { ...route, ...generate(route), parent: void 0 } : { ...route, parent: void 0 }
|
|
164
145
|
);
|
|
165
146
|
return normalized;
|
|
166
147
|
};
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import path from "path";
|
|
21
2
|
import { fs } from "@modern-js/utils";
|
|
22
3
|
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
@@ -159,7 +140,7 @@ export default ${lastComponent}`
|
|
|
159
140
|
};
|
|
160
141
|
};
|
|
161
142
|
const normalized = flat(nested).map(
|
|
162
|
-
(route) => route.parent ?
|
|
143
|
+
(route) => route.parent ? { ...route, ...generate(route), parent: void 0 } : { ...route, parent: void 0 }
|
|
163
144
|
);
|
|
164
145
|
return normalized;
|
|
165
146
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
1
|
import path from "path";
|
|
22
2
|
import { fs, findExists, MAIN_ENTRY_NAME } from "@modern-js/utils";
|
|
23
3
|
import { HTML_PARTIALS_EXTENSIONS, HTML_PARTIALS_FOLDER } from "./constants";
|
|
@@ -46,10 +26,10 @@ const findPartials = (dir, entryName, position) => {
|
|
|
46
26
|
}
|
|
47
27
|
return null;
|
|
48
28
|
};
|
|
49
|
-
const getHtmlTemplate =
|
|
29
|
+
const getHtmlTemplate = async (entrypoints, api, {
|
|
50
30
|
appContext,
|
|
51
31
|
config
|
|
52
|
-
}) {
|
|
32
|
+
}) => {
|
|
53
33
|
const { appDirectory, internalDirectory } = appContext;
|
|
54
34
|
const {
|
|
55
35
|
source: { configDir }
|
|
@@ -72,7 +52,7 @@ const getHtmlTemplate = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function*
|
|
|
72
52
|
htmlTemplates[entryName] = customIndexTemplate.file;
|
|
73
53
|
} else {
|
|
74
54
|
const hookRunners = api.useHookRunners();
|
|
75
|
-
const { partials } =
|
|
55
|
+
const { partials } = await hookRunners.htmlPartials({
|
|
76
56
|
entrypoint,
|
|
77
57
|
partials: [
|
|
78
58
|
"top" /* TOP */,
|
|
@@ -109,7 +89,7 @@ const getHtmlTemplate = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function*
|
|
|
109
89
|
}
|
|
110
90
|
}
|
|
111
91
|
return htmlTemplates;
|
|
112
|
-
}
|
|
92
|
+
};
|
|
113
93
|
export {
|
|
114
94
|
getHtmlTemplate
|
|
115
95
|
};
|
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
1
|
import path from "path";
|
|
33
2
|
import fs from "fs";
|
|
34
3
|
import {
|
|
@@ -38,7 +7,8 @@ import {
|
|
|
38
7
|
getEntryOptions,
|
|
39
8
|
SERVER_BUNDLE_DIRECTORY,
|
|
40
9
|
MAIN_ENTRY_NAME,
|
|
41
|
-
removeTailSlash
|
|
10
|
+
removeTailSlash,
|
|
11
|
+
SERVER_WORKER_BUNDLE_DIRECTORY
|
|
42
12
|
} from "@modern-js/utils";
|
|
43
13
|
import { walkDirectory } from "./utils";
|
|
44
14
|
const applyBaseUrl = (baseUrl, routes) => {
|
|
@@ -51,9 +21,10 @@ const applyBaseUrl = (baseUrl, routes) => {
|
|
|
51
21
|
} else {
|
|
52
22
|
return routes.map((route) => {
|
|
53
23
|
const urlPath = urlJoin(baseUrl, route.urlPath);
|
|
54
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
...route,
|
|
55
26
|
urlPath: urlPath === "/" ? urlPath : removeTailSlash(urlPath)
|
|
56
|
-
}
|
|
27
|
+
};
|
|
57
28
|
});
|
|
58
29
|
}
|
|
59
30
|
}
|
|
@@ -68,28 +39,34 @@ const applyRouteOptions = (original, routeOptions) => {
|
|
|
68
39
|
if (Array.isArray(route)) {
|
|
69
40
|
routes = route.map((url) => {
|
|
70
41
|
if (isPlainObject(url)) {
|
|
71
|
-
const
|
|
72
|
-
return
|
|
42
|
+
const { path: urlPath, ...other } = url;
|
|
43
|
+
return {
|
|
44
|
+
...original,
|
|
45
|
+
...other,
|
|
73
46
|
urlPath
|
|
74
|
-
}
|
|
47
|
+
};
|
|
75
48
|
} else {
|
|
76
|
-
return
|
|
49
|
+
return {
|
|
50
|
+
...original,
|
|
77
51
|
urlPath: url
|
|
78
|
-
}
|
|
52
|
+
};
|
|
79
53
|
}
|
|
80
54
|
});
|
|
81
55
|
} else if (isPlainObject(route)) {
|
|
82
|
-
const
|
|
56
|
+
const { path: urlPath, ...other } = route;
|
|
83
57
|
routes = [
|
|
84
|
-
|
|
58
|
+
{
|
|
59
|
+
...original,
|
|
60
|
+
...other,
|
|
85
61
|
urlPath
|
|
86
|
-
}
|
|
62
|
+
}
|
|
87
63
|
];
|
|
88
64
|
} else {
|
|
89
65
|
routes = [
|
|
90
|
-
|
|
66
|
+
{
|
|
67
|
+
...original,
|
|
91
68
|
urlPath: route
|
|
92
|
-
}
|
|
69
|
+
}
|
|
93
70
|
];
|
|
94
71
|
}
|
|
95
72
|
} else {
|
|
@@ -101,7 +78,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
|
101
78
|
const {
|
|
102
79
|
html: { disableHtmlFolder },
|
|
103
80
|
output: { distPath: { html: htmlPath } = {} },
|
|
104
|
-
server: { baseUrl, routes, ssr, ssrByEntries }
|
|
81
|
+
server: { baseUrl, routes, ssr, ssrByEntries, worker }
|
|
105
82
|
} = config;
|
|
106
83
|
const { packageName } = appContext;
|
|
107
84
|
let htmlRoutes = entrypoints.reduce(
|
|
@@ -113,6 +90,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
|
113
90
|
packageName
|
|
114
91
|
);
|
|
115
92
|
const isSSR = Boolean(entryOptions);
|
|
93
|
+
const isWorker = Boolean(worker);
|
|
116
94
|
const { resHeaders } = (routes == null ? void 0 : routes[entryName]) || {};
|
|
117
95
|
let route = {
|
|
118
96
|
urlPath: `/${entryName === MAIN_ENTRY_NAME ? "" : entryName}`,
|
|
@@ -125,6 +103,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
|
125
103
|
isSPA: true,
|
|
126
104
|
isSSR,
|
|
127
105
|
responseHeaders: resHeaders,
|
|
106
|
+
worker: isWorker ? `${SERVER_WORKER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0,
|
|
128
107
|
bundle: isSSR ? `${SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0
|
|
129
108
|
};
|
|
130
109
|
if (routes == null ? void 0 : routes.hasOwnProperty(entryName)) {
|