@modern-js/app-tools 2.15.0 → 2.16.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 +45 -0
- package/dist/cjs/analyze/constants.js +37 -61
- package/dist/cjs/analyze/generateCode.js +102 -127
- package/dist/cjs/analyze/getBundleEntry.js +33 -66
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +61 -117
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +61 -115
- package/dist/cjs/analyze/getClientRoutes/index.js +15 -28
- package/dist/cjs/analyze/getClientRoutes/utils.js +24 -48
- package/dist/cjs/analyze/getFileSystemEntry.js +39 -79
- package/dist/cjs/analyze/getHtmlTemplate.js +88 -98
- package/dist/cjs/analyze/getServerRoutes.js +67 -110
- package/dist/cjs/analyze/index.js +265 -257
- package/dist/cjs/analyze/isDefaultExportFunction.js +66 -44
- package/dist/cjs/analyze/makeLegalIdentifier.js +7 -25
- package/dist/cjs/analyze/nestedRoutes.js +99 -104
- package/dist/cjs/analyze/templates.js +49 -110
- package/dist/cjs/analyze/utils.js +98 -102
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +58 -100
- package/dist/cjs/builder/builder-rspack/index.js +14 -30
- package/dist/cjs/builder/builder-webpack/adapterModern.js +33 -50
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +16 -32
- package/dist/cjs/builder/builder-webpack/index.js +65 -46
- package/dist/cjs/builder/generator/createBuilderOptions.js +10 -26
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +11 -27
- package/dist/cjs/builder/generator/getBuilderTargets.js +13 -29
- package/dist/cjs/builder/generator/index.js +61 -55
- package/dist/cjs/builder/index.js +53 -43
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +13 -36
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +90 -90
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +108 -111
- package/dist/cjs/builder/shared/builderPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -30
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +32 -38
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +86 -116
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/createCopyInfo.js +16 -42
- package/dist/cjs/builder/shared/index.js +20 -19
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +8 -24
- package/dist/cjs/builder/shared/types.js +4 -15
- package/dist/cjs/commands/build.js +23 -40
- package/dist/cjs/commands/deploy.js +7 -25
- package/dist/cjs/commands/dev.js +38 -57
- package/dist/cjs/commands/index.js +20 -19
- package/dist/cjs/commands/inspect.js +10 -30
- package/dist/cjs/commands/serve.js +28 -66
- package/dist/cjs/config/default.js +34 -34
- package/dist/cjs/config/index.js +20 -19
- package/dist/cjs/config/initialize/index.js +11 -29
- package/dist/cjs/config/initialize/inits.js +103 -82
- package/dist/cjs/config/legacy/createHtmlConfig.js +8 -40
- package/dist/cjs/config/legacy/createOutputConfig.js +8 -51
- package/dist/cjs/config/legacy/createSourceConfig.js +8 -38
- package/dist/cjs/config/legacy/createToolsConfig.js +8 -43
- package/dist/cjs/config/legacy/index.js +22 -46
- package/dist/cjs/defineConfig.js +16 -31
- package/dist/cjs/exports/server.js +7 -25
- package/dist/cjs/hooks.js +33 -51
- package/dist/cjs/index.js +185 -166
- package/dist/cjs/initialize/index.js +84 -100
- package/dist/cjs/locale/en.js +13 -27
- package/dist/cjs/locale/index.js +18 -28
- package/dist/cjs/locale/zh.js +13 -27
- package/dist/cjs/schema/Schema.js +27 -31
- package/dist/cjs/schema/index.js +141 -71
- package/dist/cjs/schema/legacy.js +273 -96
- package/dist/cjs/types/config/deploy.js +4 -15
- package/dist/cjs/types/config/dev.js +4 -15
- package/dist/cjs/types/config/experiments.js +4 -15
- package/dist/cjs/types/config/html.js +4 -15
- package/dist/cjs/types/config/index.js +18 -17
- package/dist/cjs/types/config/output.js +4 -15
- package/dist/cjs/types/config/performance.js +4 -15
- package/dist/cjs/types/config/security.js +4 -15
- package/dist/cjs/types/config/source.js +4 -15
- package/dist/cjs/types/config/tools.js +4 -15
- package/dist/cjs/types/hooks.js +4 -15
- package/dist/cjs/types/index.js +20 -19
- package/dist/cjs/types/legacyConfig/deploy.js +4 -15
- package/dist/cjs/types/legacyConfig/dev.js +4 -15
- package/dist/cjs/types/legacyConfig/index.js +4 -15
- package/dist/cjs/types/legacyConfig/output.js +4 -15
- package/dist/cjs/types/legacyConfig/source.js +4 -15
- package/dist/cjs/types/legacyConfig/tools.js +4 -15
- package/dist/cjs/types/utils.js +4 -15
- package/dist/cjs/utils/config.js +74 -79
- package/dist/cjs/utils/createServer.js +16 -42
- package/dist/cjs/utils/env.js +7 -25
- package/dist/cjs/utils/generateWatchFiles.js +31 -52
- package/dist/cjs/utils/getSelectedEntries.js +13 -35
- package/dist/cjs/utils/getServerInternalPlugins.js +8 -29
- package/dist/cjs/utils/printInstructions.js +10 -28
- package/dist/cjs/utils/restart.js +13 -31
- package/dist/cjs/utils/routes.js +18 -39
- package/dist/cjs/utils/types.js +4 -15
- package/dist/esm/analyze/constants.js +40 -41
- package/dist/esm/analyze/generateCode.js +477 -455
- package/dist/esm/analyze/getBundleEntry.js +53 -54
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +201 -202
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +199 -200
- package/dist/esm/analyze/getClientRoutes/index.js +2 -3
- package/dist/esm/analyze/getClientRoutes/utils.js +15 -15
- package/dist/esm/analyze/getFileSystemEntry.js +86 -87
- package/dist/esm/analyze/getHtmlTemplate.js +289 -278
- package/dist/esm/analyze/getServerRoutes.js +203 -190
- package/dist/esm/analyze/index.js +679 -651
- package/dist/esm/analyze/isDefaultExportFunction.js +38 -39
- package/dist/esm/analyze/makeLegalIdentifier.js +8 -9
- package/dist/esm/analyze/nestedRoutes.js +400 -392
- package/dist/esm/analyze/templates.js +536 -509
- package/dist/esm/analyze/utils.js +357 -336
- package/dist/esm/builder/builder-rspack/adapterCopy.js +347 -330
- package/dist/esm/builder/builder-rspack/index.js +8 -9
- package/dist/esm/builder/builder-webpack/adapterModern.js +51 -43
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +31 -32
- package/dist/esm/builder/builder-webpack/index.js +266 -249
- package/dist/esm/builder/generator/createBuilderOptions.js +37 -38
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +62 -63
- package/dist/esm/builder/generator/getBuilderTargets.js +13 -14
- package/dist/esm/builder/generator/index.js +203 -196
- package/dist/esm/builder/index.js +183 -176
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +90 -91
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +300 -291
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +337 -329
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +108 -97
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +66 -64
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +364 -337
- package/dist/esm/builder/shared/createCopyInfo.js +9 -10
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +2 -3
- package/dist/esm/builder/shared/types.js +1 -1
- package/dist/esm/commands/build.js +279 -272
- package/dist/esm/commands/deploy.js +150 -144
- package/dist/esm/commands/dev.js +296 -289
- package/dist/esm/commands/inspect.js +144 -138
- package/dist/esm/commands/serve.js +241 -235
- package/dist/esm/config/default.js +202 -203
- package/dist/esm/config/initialize/index.js +7 -8
- package/dist/esm/config/initialize/inits.js +189 -181
- package/dist/esm/config/legacy/createHtmlConfig.js +17 -18
- package/dist/esm/config/legacy/createOutputConfig.js +41 -42
- package/dist/esm/config/legacy/createSourceConfig.js +38 -39
- package/dist/esm/config/legacy/createToolsConfig.js +24 -25
- package/dist/esm/config/legacy/index.js +31 -32
- package/dist/esm/defineConfig.js +52 -53
- package/dist/esm/exports/server.js +1 -2
- package/dist/esm/hooks.js +26 -27
- package/dist/esm/index.js +685 -671
- package/dist/esm/initialize/index.js +276 -269
- package/dist/esm/locale/en.js +36 -37
- package/dist/esm/locale/index.js +2 -2
- package/dist/esm/locale/zh.js +36 -37
- package/dist/esm/schema/Schema.js +255 -244
- package/dist/esm/schema/index.js +165 -165
- package/dist/esm/schema/legacy.js +316 -317
- package/dist/esm/types/config/deploy.js +1 -1
- package/dist/esm/types/config/dev.js +1 -1
- package/dist/esm/types/config/experiments.js +1 -1
- package/dist/esm/types/config/html.js +1 -1
- package/dist/esm/types/config/output.js +1 -1
- package/dist/esm/types/config/performance.js +1 -1
- package/dist/esm/types/config/security.js +1 -1
- package/dist/esm/types/config/source.js +1 -1
- package/dist/esm/types/config/tools.js +1 -1
- package/dist/esm/types/hooks.js +1 -1
- package/dist/esm/types/legacyConfig/deploy.js +1 -1
- package/dist/esm/types/legacyConfig/dev.js +1 -1
- package/dist/esm/types/legacyConfig/index.js +1 -1
- package/dist/esm/types/legacyConfig/output.js +1 -1
- package/dist/esm/types/legacyConfig/source.js +1 -1
- package/dist/esm/types/legacyConfig/tools.js +1 -1
- package/dist/esm/types/utils.js +1 -1
- package/dist/esm/utils/config.js +285 -278
- package/dist/esm/utils/createServer.js +242 -234
- package/dist/esm/utils/env.js +11 -12
- package/dist/esm/utils/generateWatchFiles.js +205 -190
- package/dist/esm/utils/getSelectedEntries.js +180 -173
- package/dist/esm/utils/getServerInternalPlugins.js +197 -191
- package/dist/esm/utils/printInstructions.js +147 -141
- package/dist/esm/utils/restart.js +179 -173
- package/dist/esm/utils/routes.js +146 -139
- package/dist/esm/utils/types.js +1 -1
- package/dist/esm-node/analyze/constants.js +31 -46
- package/dist/esm-node/analyze/generateCode.js +28 -94
- package/dist/esm-node/analyze/getBundleEntry.js +8 -27
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +24 -65
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +24 -63
- package/dist/esm-node/analyze/getClientRoutes/index.js +2 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +5 -19
- package/dist/esm-node/analyze/getFileSystemEntry.js +10 -37
- package/dist/esm-node/analyze/getHtmlTemplate.js +29 -59
- package/dist/esm-node/analyze/getServerRoutes.js +43 -75
- package/dist/esm-node/analyze/index.js +208 -230
- package/dist/esm-node/analyze/isDefaultExportFunction.js +7 -5
- package/dist/esm-node/analyze/makeLegalIdentifier.js +1 -4
- package/dist/esm-node/analyze/nestedRoutes.js +23 -43
- package/dist/esm-node/analyze/templates.js +22 -69
- package/dist/esm-node/analyze/utils.js +66 -60
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +40 -62
- package/dist/esm-node/builder/builder-rspack/index.js +4 -5
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +24 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +3 -10
- package/dist/esm-node/builder/builder-webpack/index.js +13 -11
- package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -5
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +5 -6
- package/dist/esm-node/builder/generator/getBuilderTargets.js +5 -11
- package/dist/esm-node/builder/generator/index.js +7 -16
- package/dist/esm-node/builder/index.js +2 -7
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -6
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +34 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +54 -74
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +23 -8
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +25 -16
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +66 -76
- package/dist/esm-node/builder/shared/createCopyInfo.js +2 -8
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +1 -4
- package/dist/esm-node/builder/shared/types.js +1 -0
- package/dist/esm-node/commands/build.js +7 -9
- package/dist/esm-node/commands/deploy.js +1 -4
- package/dist/esm-node/commands/dev.js +19 -27
- package/dist/esm-node/commands/inspect.js +3 -8
- package/dist/esm-node/commands/serve.js +7 -25
- package/dist/esm-node/config/default.js +20 -11
- package/dist/esm-node/config/initialize/index.js +1 -4
- package/dist/esm-node/config/initialize/inits.js +48 -54
- package/dist/esm-node/config/legacy/createHtmlConfig.js +2 -19
- package/dist/esm-node/config/legacy/createOutputConfig.js +2 -30
- package/dist/esm-node/config/legacy/createSourceConfig.js +2 -17
- package/dist/esm-node/config/legacy/createToolsConfig.js +2 -22
- package/dist/esm-node/config/legacy/index.js +3 -18
- package/dist/esm-node/defineConfig.js +7 -13
- package/dist/esm-node/exports/server.js +1 -4
- package/dist/esm-node/hooks.js +2 -9
- package/dist/esm-node/index.js +95 -120
- package/dist/esm-node/initialize/index.js +74 -87
- package/dist/esm-node/locale/en.js +7 -6
- package/dist/esm-node/locale/index.js +5 -5
- package/dist/esm-node/locale/zh.js +7 -6
- package/dist/esm-node/schema/Schema.js +19 -8
- package/dist/esm-node/schema/index.js +121 -36
- package/dist/esm-node/schema/legacy.js +262 -72
- package/dist/esm-node/types/config/deploy.js +1 -0
- package/dist/esm-node/types/config/dev.js +1 -0
- package/dist/esm-node/types/config/experiments.js +1 -0
- package/dist/esm-node/types/config/html.js +1 -0
- package/dist/esm-node/types/config/output.js +1 -0
- package/dist/esm-node/types/config/performance.js +1 -0
- package/dist/esm-node/types/config/security.js +1 -0
- package/dist/esm-node/types/config/source.js +1 -0
- package/dist/esm-node/types/config/tools.js +1 -0
- package/dist/esm-node/types/hooks.js +1 -0
- package/dist/esm-node/types/legacyConfig/deploy.js +1 -0
- package/dist/esm-node/types/legacyConfig/dev.js +1 -0
- package/dist/esm-node/types/legacyConfig/index.js +1 -0
- package/dist/esm-node/types/legacyConfig/output.js +1 -0
- package/dist/esm-node/types/legacyConfig/source.js +1 -0
- package/dist/esm-node/types/legacyConfig/tools.js +1 -0
- package/dist/esm-node/types/utils.js +1 -0
- package/dist/esm-node/utils/config.js +16 -47
- package/dist/esm-node/utils/createServer.js +5 -12
- package/dist/esm-node/utils/env.js +1 -4
- package/dist/esm-node/utils/generateWatchFiles.js +13 -20
- package/dist/esm-node/utils/getSelectedEntries.js +2 -9
- package/dist/esm-node/utils/getServerInternalPlugins.js +2 -8
- package/dist/esm-node/utils/printInstructions.js +1 -4
- package/dist/esm-node/utils/restart.js +2 -11
- package/dist/esm-node/utils/routes.js +4 -4
- package/dist/esm-node/utils/types.js +1 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +29 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @modern-js/app-tools
|
|
2
2
|
|
|
3
|
+
## 2.16.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4e876ab: chore: package.json include the monorepo-relative directory
|
|
8
|
+
|
|
9
|
+
chore: 在 package.json 中声明 monorepo 的子路径
|
|
10
|
+
|
|
11
|
+
- 355d36e: feat: adjust create tools and new command option order
|
|
12
|
+
|
|
13
|
+
feat: 调整 create 工具及 new 命令 option 操作顺序
|
|
14
|
+
|
|
15
|
+
- 03997c2: chore(app-tools): export AppToolsOptions type
|
|
16
|
+
|
|
17
|
+
chore(app-tools): 导出 AppToolsOptions 类型
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [fe92de6]
|
|
20
|
+
- Updated dependencies [091986a]
|
|
21
|
+
- Updated dependencies [5954330]
|
|
22
|
+
- Updated dependencies [50bc0db]
|
|
23
|
+
- Updated dependencies [fd4a8a6]
|
|
24
|
+
- Updated dependencies [7596520]
|
|
25
|
+
- Updated dependencies [4e876ab]
|
|
26
|
+
- Updated dependencies [6d5219e]
|
|
27
|
+
- Updated dependencies [e4e0e01]
|
|
28
|
+
- Updated dependencies [fb19f48]
|
|
29
|
+
- @modern-js/builder-shared@2.16.0
|
|
30
|
+
- @modern-js/builder-webpack-provider@2.16.0
|
|
31
|
+
- @modern-js/utils@2.16.0
|
|
32
|
+
- @modern-js/builder-rspack-provider@2.16.0
|
|
33
|
+
- @modern-js/plugin@2.16.0
|
|
34
|
+
- @modern-js/builder-plugin-node-polyfill@2.16.0
|
|
35
|
+
- @modern-js/node-bundle-require@2.16.0
|
|
36
|
+
- @modern-js/builder-plugin-esbuild@2.16.0
|
|
37
|
+
- @modern-js/plugin-data-loader@2.16.0
|
|
38
|
+
- @modern-js/new-action@2.16.0
|
|
39
|
+
- @modern-js/prod-server@2.16.0
|
|
40
|
+
- @modern-js/builder@2.16.0
|
|
41
|
+
- @modern-js/plugin-i18n@2.16.0
|
|
42
|
+
- @modern-js/plugin-lint@2.16.0
|
|
43
|
+
- @modern-js/upgrade@2.16.0
|
|
44
|
+
- @modern-js/server@2.16.0
|
|
45
|
+
- @modern-js/types@2.16.0
|
|
46
|
+
- @modern-js/core@2.16.0
|
|
47
|
+
|
|
3
48
|
## 2.15.0
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
6
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var constants_exports = {};
|
|
19
|
-
__export(constants_exports, {
|
|
20
|
-
APP_CONFIG_NAME: () => APP_CONFIG_NAME,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
JS_EXTENSIONS: () => JS_EXTENSIONS,
|
|
14
|
+
INDEX_FILE_NAME: () => INDEX_FILE_NAME,
|
|
21
15
|
APP_FILE_NAME: () => APP_FILE_NAME,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
PAGES_DIR_NAME: () => PAGES_DIR_NAME,
|
|
17
|
+
NESTED_ROUTES_DIR: () => NESTED_ROUTES_DIR,
|
|
18
|
+
FILE_SYSTEM_ROUTES_FILE_NAME: () => FILE_SYSTEM_ROUTES_FILE_NAME,
|
|
19
|
+
LOADER_EXPORT_NAME: () => LOADER_EXPORT_NAME,
|
|
20
|
+
TEMP_LOADERS_DIR: () => TEMP_LOADERS_DIR,
|
|
25
21
|
ENTRY_POINT_FILE_NAME: () => ENTRY_POINT_FILE_NAME,
|
|
26
|
-
|
|
22
|
+
ENTRY_BOOTSTRAP_FILE_NAME: () => ENTRY_BOOTSTRAP_FILE_NAME,
|
|
27
23
|
FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP: () => FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
|
|
28
|
-
|
|
24
|
+
FILE_SYSTEM_ROUTES_LAYOUT: () => FILE_SYSTEM_ROUTES_LAYOUT,
|
|
29
25
|
FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT: () => FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
|
|
30
|
-
FILE_SYSTEM_ROUTES_IGNORED_REGEX: () => FILE_SYSTEM_ROUTES_IGNORED_REGEX,
|
|
31
26
|
FILE_SYSTEM_ROUTES_INDEX: () => FILE_SYSTEM_ROUTES_INDEX,
|
|
32
|
-
|
|
33
|
-
HTML_PARTIALS_EXTENSIONS: () => HTML_PARTIALS_EXTENSIONS,
|
|
27
|
+
FILE_SYSTEM_ROUTES_IGNORED_REGEX: () => FILE_SYSTEM_ROUTES_IGNORED_REGEX,
|
|
34
28
|
HTML_PARTIALS_FOLDER: () => HTML_PARTIALS_FOLDER,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
LOADER_EXPORT_NAME: () => LOADER_EXPORT_NAME,
|
|
29
|
+
HTML_PARTIALS_EXTENSIONS: () => HTML_PARTIALS_EXTENSIONS,
|
|
30
|
+
FILE_SYSTEM_ROUTES_COMPONENTS_DIR: () => FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
|
|
38
31
|
NESTED_ROUTE: () => NESTED_ROUTE,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
APP_CONFIG_NAME: () => APP_CONFIG_NAME,
|
|
33
|
+
APP_INIT_EXPORTED: () => APP_INIT_EXPORTED,
|
|
34
|
+
APP_INIT_IMPORTED: () => APP_INIT_IMPORTED
|
|
42
35
|
});
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
const JS_EXTENSIONS = [
|
|
37
|
+
".js",
|
|
38
|
+
".ts",
|
|
39
|
+
".jsx",
|
|
40
|
+
".tsx"
|
|
41
|
+
];
|
|
45
42
|
const INDEX_FILE_NAME = "index";
|
|
46
43
|
const APP_FILE_NAME = "App";
|
|
47
44
|
const PAGES_DIR_NAME = "pages";
|
|
@@ -57,7 +54,11 @@ const FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = "_app";
|
|
|
57
54
|
const FILE_SYSTEM_ROUTES_INDEX = "index";
|
|
58
55
|
const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/;
|
|
59
56
|
const HTML_PARTIALS_FOLDER = "html";
|
|
60
|
-
const HTML_PARTIALS_EXTENSIONS = [
|
|
57
|
+
const HTML_PARTIALS_EXTENSIONS = [
|
|
58
|
+
".htm",
|
|
59
|
+
".html",
|
|
60
|
+
".ejs"
|
|
61
|
+
];
|
|
61
62
|
const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
|
|
62
63
|
const NESTED_ROUTE = {
|
|
63
64
|
LAYOUT_FILE: "layout",
|
|
@@ -75,28 +76,3 @@ const NESTED_ROUTE = {
|
|
|
75
76
|
const APP_CONFIG_NAME = "config";
|
|
76
77
|
const APP_INIT_EXPORTED = "init";
|
|
77
78
|
const APP_INIT_IMPORTED = "appInit";
|
|
78
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
-
0 && (module.exports = {
|
|
80
|
-
APP_CONFIG_NAME,
|
|
81
|
-
APP_FILE_NAME,
|
|
82
|
-
APP_INIT_EXPORTED,
|
|
83
|
-
APP_INIT_IMPORTED,
|
|
84
|
-
ENTRY_BOOTSTRAP_FILE_NAME,
|
|
85
|
-
ENTRY_POINT_FILE_NAME,
|
|
86
|
-
FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
|
|
87
|
-
FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
|
|
88
|
-
FILE_SYSTEM_ROUTES_FILE_NAME,
|
|
89
|
-
FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
|
|
90
|
-
FILE_SYSTEM_ROUTES_IGNORED_REGEX,
|
|
91
|
-
FILE_SYSTEM_ROUTES_INDEX,
|
|
92
|
-
FILE_SYSTEM_ROUTES_LAYOUT,
|
|
93
|
-
HTML_PARTIALS_EXTENSIONS,
|
|
94
|
-
HTML_PARTIALS_FOLDER,
|
|
95
|
-
INDEX_FILE_NAME,
|
|
96
|
-
JS_EXTENSIONS,
|
|
97
|
-
LOADER_EXPORT_NAME,
|
|
98
|
-
NESTED_ROUTE,
|
|
99
|
-
NESTED_ROUTES_DIR,
|
|
100
|
-
PAGES_DIR_NAME,
|
|
101
|
-
TEMP_LOADERS_DIR
|
|
102
|
-
});
|
|
@@ -1,43 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var generateCode_exports = {};
|
|
29
|
-
__export(generateCode_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
30
13
|
createImportStatements: () => createImportStatements,
|
|
31
14
|
generateCode: () => generateCode
|
|
32
15
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
17
|
+
const _utils = require("@modern-js/utils");
|
|
18
|
+
const _templates = /* @__PURE__ */ _interop_require_wildcard(require("./templates"));
|
|
19
|
+
const _getClientRoutes = require("./getClientRoutes");
|
|
20
|
+
const _constants = require("./constants");
|
|
21
|
+
const _utils1 = require("./utils");
|
|
22
|
+
const _nestedRoutes = require("./nestedRoutes");
|
|
23
|
+
function _interop_require_default(obj) {
|
|
24
|
+
return obj && obj.__esModule ? obj : {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
29
|
+
if (typeof WeakMap !== "function")
|
|
30
|
+
return null;
|
|
31
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
33
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
34
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
35
|
+
})(nodeInterop);
|
|
36
|
+
}
|
|
37
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
38
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
42
|
+
return {
|
|
43
|
+
default: obj
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
47
|
+
if (cache && cache.has(obj)) {
|
|
48
|
+
return cache.get(obj);
|
|
49
|
+
}
|
|
50
|
+
var newObj = {};
|
|
51
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
52
|
+
for (var key in obj) {
|
|
53
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
54
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
55
|
+
if (desc && (desc.get || desc.set)) {
|
|
56
|
+
Object.defineProperty(newObj, key, desc);
|
|
57
|
+
} else {
|
|
58
|
+
newObj[key] = obj[key];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
newObj.default = obj;
|
|
63
|
+
if (cache) {
|
|
64
|
+
cache.set(obj, newObj);
|
|
65
|
+
}
|
|
66
|
+
return newObj;
|
|
67
|
+
}
|
|
41
68
|
const createImportSpecifier = (specifiers) => {
|
|
42
69
|
let defaults = "";
|
|
43
70
|
const named = [];
|
|
@@ -59,7 +86,6 @@ const createImportSpecifier = (specifiers) => {
|
|
|
59
86
|
}
|
|
60
87
|
};
|
|
61
88
|
const createImportStatements = (statements) => {
|
|
62
|
-
var _a, _b;
|
|
63
89
|
const deDuplicated = [];
|
|
64
90
|
const seen = /* @__PURE__ */ new Map();
|
|
65
91
|
for (const { value, specifiers, initialize } of statements) {
|
|
@@ -71,38 +97,30 @@ const createImportStatements = (statements) => {
|
|
|
71
97
|
});
|
|
72
98
|
seen.set(value, specifiers);
|
|
73
99
|
} else {
|
|
100
|
+
var _deDuplicated_modifyIndex;
|
|
74
101
|
seen.get(value).push(...specifiers);
|
|
75
102
|
const modifyIndex = deDuplicated.findIndex((v) => v.value === value);
|
|
76
|
-
|
|
77
|
-
deDuplicated[modifyIndex].initialize
|
|
78
|
-
|
|
79
|
-
${initialize || ""}`
|
|
80
|
-
);
|
|
103
|
+
var _deDuplicated_modifyIndex_initialize;
|
|
104
|
+
const originInitialize = (_deDuplicated_modifyIndex_initialize = (_deDuplicated_modifyIndex = deDuplicated[modifyIndex]) === null || _deDuplicated_modifyIndex === void 0 ? void 0 : _deDuplicated_modifyIndex.initialize) !== null && _deDuplicated_modifyIndex_initialize !== void 0 ? _deDuplicated_modifyIndex_initialize : "";
|
|
105
|
+
deDuplicated[modifyIndex].initialize = originInitialize.concat(`
|
|
106
|
+
${initialize || ""}`);
|
|
81
107
|
}
|
|
82
108
|
}
|
|
83
|
-
return deDuplicated.map(
|
|
84
|
-
|
|
85
|
-
${initialize || ""}`
|
|
86
|
-
).join("\n");
|
|
109
|
+
return deDuplicated.map(({ value, specifiers, initialize }) => `import ${createImportSpecifier(specifiers)} from '${value}';
|
|
110
|
+
${initialize || ""}`).join("\n");
|
|
87
111
|
};
|
|
88
112
|
const generateCode = async (appContext, config, entrypoints, api) => {
|
|
89
|
-
const {
|
|
90
|
-
internalDirectory,
|
|
91
|
-
srcDirectory,
|
|
92
|
-
internalDirAlias,
|
|
93
|
-
internalSrcAlias,
|
|
94
|
-
packageName
|
|
95
|
-
} = appContext;
|
|
113
|
+
const { internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName } = appContext;
|
|
96
114
|
const hookRunners = api.useHookRunners();
|
|
97
|
-
const isV5 = (0,
|
|
115
|
+
const isV5 = (0, _utils.isRouterV5)(config);
|
|
98
116
|
const { mountId } = config.html;
|
|
99
|
-
const getRoutes = isV5 ?
|
|
117
|
+
const getRoutes = isV5 ? _getClientRoutes.getClientRoutesLegacy : _getClientRoutes.getClientRoutes;
|
|
100
118
|
await Promise.all(entrypoints.map(generateEntryCode));
|
|
101
119
|
async function generateEntryCode(entrypoint) {
|
|
102
|
-
var _a;
|
|
103
120
|
const { entryName, isAutoMount, customBootstrap, fileSystemRoutes } = entrypoint;
|
|
104
121
|
if (isAutoMount) {
|
|
105
122
|
if (fileSystemRoutes) {
|
|
123
|
+
var _config_output;
|
|
106
124
|
let initialRoutes = [];
|
|
107
125
|
let nestedRoute = null;
|
|
108
126
|
if (entrypoint.entry) {
|
|
@@ -115,15 +133,10 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
115
133
|
});
|
|
116
134
|
}
|
|
117
135
|
if (!isV5 && entrypoint.nestedRoutesEntry) {
|
|
118
|
-
nestedRoute = await (0,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
name: internalSrcAlias,
|
|
123
|
-
basename: srcDirectory
|
|
124
|
-
},
|
|
125
|
-
entrypoint.entryName
|
|
126
|
-
);
|
|
136
|
+
nestedRoute = await (0, _nestedRoutes.walk)(entrypoint.nestedRoutesEntry, entrypoint.nestedRoutesEntry, {
|
|
137
|
+
name: internalSrcAlias,
|
|
138
|
+
basename: srcDirectory
|
|
139
|
+
}, entrypoint.entryName);
|
|
127
140
|
if (nestedRoute) {
|
|
128
141
|
initialRoutes.unshift(nestedRoute);
|
|
129
142
|
}
|
|
@@ -133,75 +146,48 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
133
146
|
routes: initialRoutes
|
|
134
147
|
});
|
|
135
148
|
const config2 = api.useResolvedConfigContext();
|
|
136
|
-
const ssr = (0,
|
|
137
|
-
|
|
138
|
-
config2.server.ssr,
|
|
139
|
-
config2.server.ssrByEntries,
|
|
140
|
-
packageName
|
|
141
|
-
);
|
|
142
|
-
const useSSG = (0, import_utils.isSSGEntry)(config2, entryName, entrypoints);
|
|
149
|
+
const ssr = (0, _utils.getEntryOptions)(entryName, config2.server.ssr, config2.server.ssrByEntries, packageName);
|
|
150
|
+
const useSSG = (0, _utils.isSSGEntry)(config2, entryName, entrypoints);
|
|
143
151
|
let mode;
|
|
144
152
|
if (ssr) {
|
|
145
153
|
mode = typeof ssr === "object" ? ssr.mode || "string" : "string";
|
|
146
154
|
}
|
|
147
155
|
if (mode === "stream") {
|
|
148
|
-
const hasPageRoute = routes.some(
|
|
149
|
-
(route) => "type" in route && route.type === "page"
|
|
150
|
-
);
|
|
156
|
+
const hasPageRoute = routes.some((route) => "type" in route && route.type === "page");
|
|
151
157
|
if (hasPageRoute) {
|
|
152
|
-
|
|
153
|
-
"Streaming ssr is not supported when pages dir exists"
|
|
154
|
-
);
|
|
158
|
+
_utils.logger.error("Streaming ssr is not supported when pages dir exists");
|
|
155
159
|
process.exit(1);
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
162
|
const { code: code2 } = await hookRunners.beforeGenerateRoutes({
|
|
159
163
|
entrypoint,
|
|
160
|
-
code: await
|
|
164
|
+
code: await _templates.fileSystemRoutes({
|
|
161
165
|
routes,
|
|
162
166
|
ssrMode: useSSG ? "string" : mode,
|
|
163
167
|
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
164
168
|
entryName: entrypoint.entryName,
|
|
165
169
|
internalDirectory,
|
|
166
|
-
splitRouteChunks:
|
|
170
|
+
splitRouteChunks: config2 === null || config2 === void 0 ? void 0 : (_config_output = config2.output) === null || _config_output === void 0 ? void 0 : _config_output.splitRouteChunks
|
|
167
171
|
})
|
|
168
172
|
});
|
|
169
|
-
if (entrypoint.nestedRoutesEntry && (0,
|
|
170
|
-
const routesServerFile = (0,
|
|
171
|
-
|
|
172
|
-
entryName
|
|
173
|
-
);
|
|
174
|
-
const code3 = templates.routesForServer({
|
|
173
|
+
if (entrypoint.nestedRoutesEntry && (0, _utils.isUseSSRBundle)(config2)) {
|
|
174
|
+
const routesServerFile = (0, _utils1.getServerLoadersFile)(internalDirectory, entryName);
|
|
175
|
+
const code3 = _templates.routesForServer({
|
|
175
176
|
routes
|
|
176
177
|
});
|
|
177
|
-
await
|
|
178
|
-
await
|
|
178
|
+
await _utils.fs.ensureFile(routesServerFile);
|
|
179
|
+
await _utils.fs.writeFile(routesServerFile, code3);
|
|
179
180
|
}
|
|
180
|
-
const serverLoaderCombined =
|
|
181
|
-
entrypoints,
|
|
182
|
-
entrypoint,
|
|
183
|
-
config2,
|
|
184
|
-
appContext
|
|
185
|
-
);
|
|
181
|
+
const serverLoaderCombined = _templates.ssrLoaderCombinedModule(entrypoints, entrypoint, config2, appContext);
|
|
186
182
|
if (serverLoaderCombined) {
|
|
187
|
-
const serverLoaderFile = (0,
|
|
188
|
-
|
|
189
|
-
entryName
|
|
190
|
-
);
|
|
191
|
-
await import_utils.fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
183
|
+
const serverLoaderFile = (0, _utils1.getServerCombinedModueFile)(internalDirectory, entryName);
|
|
184
|
+
await _utils.fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
192
185
|
}
|
|
193
|
-
|
|
194
|
-
import_path.default.resolve(
|
|
195
|
-
internalDirectory,
|
|
196
|
-
`./${entryName}/${import_constants.FILE_SYSTEM_ROUTES_FILE_NAME}`
|
|
197
|
-
),
|
|
198
|
-
code2,
|
|
199
|
-
"utf8"
|
|
200
|
-
);
|
|
186
|
+
_utils.fs.outputFileSync(_path.default.resolve(internalDirectory, `./${entryName}/${_constants.FILE_SYSTEM_ROUTES_FILE_NAME}`), code2, "utf8");
|
|
201
187
|
}
|
|
202
188
|
const { imports: importStatements } = await hookRunners.modifyEntryImports({
|
|
203
189
|
entrypoint,
|
|
204
|
-
imports: (0,
|
|
190
|
+
imports: (0, _utils1.getDefaultImports)({
|
|
205
191
|
entrypoint,
|
|
206
192
|
srcDirectory,
|
|
207
193
|
internalSrcAlias,
|
|
@@ -215,7 +201,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
215
201
|
});
|
|
216
202
|
const { code: renderFunction } = await hookRunners.modifyEntryRenderFunction({
|
|
217
203
|
entrypoint,
|
|
218
|
-
code:
|
|
204
|
+
code: _templates.renderFunction({
|
|
219
205
|
plugins,
|
|
220
206
|
customBootstrap,
|
|
221
207
|
fileSystemRoutes
|
|
@@ -225,36 +211,25 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
225
211
|
entrypoint,
|
|
226
212
|
exportStatement: "export default AppWrapper;"
|
|
227
213
|
});
|
|
228
|
-
const code =
|
|
214
|
+
const code = _templates.index({
|
|
229
215
|
mountId,
|
|
230
216
|
imports: createImportStatements(importStatements),
|
|
231
217
|
renderFunction,
|
|
232
218
|
exportStatement
|
|
233
219
|
});
|
|
234
|
-
const entryFile =
|
|
235
|
-
internalDirectory,
|
|
236
|
-
`./${entryName}/${import_constants.ENTRY_POINT_FILE_NAME}`
|
|
237
|
-
);
|
|
220
|
+
const entryFile = _path.default.resolve(internalDirectory, `./${entryName}/${_constants.ENTRY_POINT_FILE_NAME}`);
|
|
238
221
|
entrypoint.entry = entryFile;
|
|
239
222
|
if (config.source.enableAsyncEntry) {
|
|
240
223
|
const { code: asyncEntryCode } = await hookRunners.modifyAsyncEntry({
|
|
241
224
|
entrypoint,
|
|
242
|
-
code: `import('./${
|
|
225
|
+
code: `import('./${_constants.ENTRY_BOOTSTRAP_FILE_NAME}');`
|
|
243
226
|
});
|
|
244
|
-
|
|
245
|
-
const bootstrapFile =
|
|
246
|
-
|
|
247
|
-
`./${entryName}/${import_constants.ENTRY_BOOTSTRAP_FILE_NAME}`
|
|
248
|
-
);
|
|
249
|
-
import_utils.fs.outputFileSync(bootstrapFile, code, "utf8");
|
|
227
|
+
_utils.fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
|
|
228
|
+
const bootstrapFile = _path.default.resolve(internalDirectory, `./${entryName}/${_constants.ENTRY_BOOTSTRAP_FILE_NAME}`);
|
|
229
|
+
_utils.fs.outputFileSync(bootstrapFile, code, "utf8");
|
|
250
230
|
} else {
|
|
251
|
-
|
|
231
|
+
_utils.fs.outputFileSync(entryFile, code, "utf8");
|
|
252
232
|
}
|
|
253
233
|
}
|
|
254
234
|
}
|
|
255
235
|
};
|
|
256
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
257
|
-
0 && (module.exports = {
|
|
258
|
-
createImportStatements,
|
|
259
|
-
generateCode
|
|
260
|
-
});
|
|
@@ -1,42 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var getBundleEntry_exports = {};
|
|
29
|
-
__export(getBundleEntry_exports, {
|
|
30
|
-
getBundleEntry: () => getBundleEntry
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
5
|
+
Object.defineProperty(exports, "getBundleEntry", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => getBundleEntry
|
|
8
|
+
});
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _getFileSystemEntry = require("./getFileSystemEntry");
|
|
12
|
+
const _constants = require("./constants");
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
37
18
|
const ensureExtensions = (file) => {
|
|
38
|
-
if (!
|
|
39
|
-
return (0,
|
|
19
|
+
if (!_path.default.extname(file)) {
|
|
20
|
+
return (0, _utils.findExists)(_constants.JS_EXTENSIONS.map((ext) => `${file}${ext}`)) || file;
|
|
40
21
|
}
|
|
41
22
|
return file;
|
|
42
23
|
};
|
|
@@ -46,43 +27,35 @@ const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint)
|
|
|
46
27
|
return true;
|
|
47
28
|
}
|
|
48
29
|
if (entrypoint.entry.startsWith(checked.entry) || checked.entry.startsWith(entrypoint.entry)) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
`Entry configuration conflicts
|
|
30
|
+
throw new Error(`Entry configuration conflicts
|
|
51
31
|
Your configuration: ${checked.entry}.
|
|
52
32
|
Default entrypoint: ${entrypoint.entry}
|
|
53
|
-
Please reset source.entries or set source.disableDefaultEntries to disable the default entry rules.`
|
|
54
|
-
);
|
|
33
|
+
Please reset source.entries or set source.disableDefaultEntries to disable the default entry rules.`);
|
|
55
34
|
}
|
|
56
35
|
return false;
|
|
57
36
|
});
|
|
58
37
|
const getBundleEntry = (appContext, config) => {
|
|
59
38
|
const { appDirectory, packageName } = appContext;
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
} = config;
|
|
63
|
-
const defaults = disableDefaultEntries ? [] : (0, import_getFileSystemEntry.getFileSystemEntry)(appContext, config);
|
|
39
|
+
const { source: { disableDefaultEntries, entries, entriesDir } } = config;
|
|
40
|
+
const defaults = disableDefaultEntries ? [] : (0, _getFileSystemEntry.getFileSystemEntry)(appContext, config);
|
|
64
41
|
if (entries) {
|
|
65
42
|
Object.keys(entries).forEach((name) => {
|
|
66
43
|
const value = entries[name];
|
|
67
44
|
const entrypoint = typeof value === "string" ? {
|
|
68
45
|
entryName: name,
|
|
69
|
-
entry: (0,
|
|
70
|
-
absoluteEntryDir:
|
|
71
|
-
(0, import_utils.ensureAbsolutePath)(appDirectory, value)
|
|
72
|
-
),
|
|
46
|
+
entry: (0, _utils.ensureAbsolutePath)(appDirectory, value),
|
|
47
|
+
absoluteEntryDir: _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value)),
|
|
73
48
|
isAutoMount: true,
|
|
74
|
-
fileSystemRoutes:
|
|
49
|
+
fileSystemRoutes: _utils.fs.statSync((0, _utils.ensureAbsolutePath)(appDirectory, value)).isDirectory() ? {} : void 0
|
|
75
50
|
} : {
|
|
76
51
|
entryName: name,
|
|
77
|
-
entry: (0,
|
|
78
|
-
absoluteEntryDir:
|
|
79
|
-
(0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)
|
|
80
|
-
),
|
|
52
|
+
entry: (0, _utils.ensureAbsolutePath)(appDirectory, value.entry),
|
|
53
|
+
absoluteEntryDir: _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)),
|
|
81
54
|
isAutoMount: !value.disableMount,
|
|
82
|
-
customBootstrap: value.customBootstrap && (0,
|
|
83
|
-
fileSystemRoutes:
|
|
55
|
+
customBootstrap: value.customBootstrap && (0, _utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
|
|
56
|
+
fileSystemRoutes: _utils.fs.statSync((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
|
|
84
57
|
};
|
|
85
|
-
if (entrypoint.fileSystemRoutes && (0,
|
|
58
|
+
if (entrypoint.fileSystemRoutes && (0, _utils.isRouterV5)(config)) {
|
|
86
59
|
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
87
60
|
}
|
|
88
61
|
if (!ifAlreadyExists(defaults, entrypoint)) {
|
|
@@ -91,15 +64,9 @@ const getBundleEntry = (appContext, config) => {
|
|
|
91
64
|
});
|
|
92
65
|
}
|
|
93
66
|
if (!disableDefaultEntries) {
|
|
94
|
-
const entriesDirAbs = (0,
|
|
95
|
-
const found = defaults.find(
|
|
96
|
-
|
|
97
|
-
);
|
|
98
|
-
found && (found.entryName = import_utils.MAIN_ENTRY_NAME);
|
|
67
|
+
const entriesDirAbs = (0, _utils.ensureAbsolutePath)(appDirectory, entriesDir || "");
|
|
68
|
+
const found = defaults.find(({ entryName, entry, nestedRoutesEntry = "" }) => entryName === packageName || _path.default.dirname(entry) === entriesDirAbs || _path.default.dirname(nestedRoutesEntry) === entriesDirAbs);
|
|
69
|
+
found && (found.entryName = _utils.MAIN_ENTRY_NAME);
|
|
99
70
|
}
|
|
100
71
|
return defaults;
|
|
101
72
|
};
|
|
102
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
-
0 && (module.exports = {
|
|
104
|
-
getBundleEntry
|
|
105
|
-
});
|