@modern-js/app-tools 2.15.0 → 2.17.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 +68 -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
|
@@ -1,69 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 getRoutes_exports = {};
|
|
29
|
-
__export(getRoutes_exports, {
|
|
30
|
-
getClientRoutes: () => getClientRoutes
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getClientRoutes", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => getClientRoutes
|
|
31
8
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _makeLegalIdentifier = require("../makeLegalIdentifier");
|
|
12
|
+
const _constants = require("../constants");
|
|
13
|
+
const _utils1 = require("../utils");
|
|
14
|
+
const _utils2 = require("./utils");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
39
20
|
const compName = (srcDirectory, filePath) => {
|
|
40
|
-
const legalCompName = (0,
|
|
41
|
-
import_path.default.relative(srcDirectory, filePath)
|
|
42
|
-
);
|
|
21
|
+
const legalCompName = (0, _makeLegalIdentifier.makeLegalIdentifier)(_path.default.relative(srcDirectory, filePath));
|
|
43
22
|
return `Comp_${legalCompName}`;
|
|
44
23
|
};
|
|
45
24
|
const layoutNameAbbr = (filePath) => {
|
|
46
25
|
const prefix = "L_";
|
|
47
|
-
const dirName =
|
|
48
|
-
return `${prefix}${(0,
|
|
26
|
+
const dirName = _path.default.dirname(filePath).split("/").pop() || "";
|
|
27
|
+
return `${prefix}${(0, _makeLegalIdentifier.makeLegalIdentifier)(dirName)}`;
|
|
49
28
|
};
|
|
50
29
|
const parents = [];
|
|
51
|
-
const recursiveReadDir = ({
|
|
52
|
-
dir,
|
|
53
|
-
routes,
|
|
54
|
-
basePath = "/",
|
|
55
|
-
srcDirectory,
|
|
56
|
-
srcAlias
|
|
57
|
-
}) => {
|
|
30
|
+
const recursiveReadDir = ({ dir, routes, basePath = "/", srcDirectory, srcAlias }) => {
|
|
58
31
|
let hasDynamicRoute = false;
|
|
59
32
|
let resetParent = false;
|
|
60
33
|
let parent = parents[parents.length - 1];
|
|
61
|
-
const layout = (0,
|
|
34
|
+
const layout = (0, _utils2.findLayout)(dir);
|
|
62
35
|
if (layout) {
|
|
63
36
|
if (basePath === "/") {
|
|
64
37
|
throw new Error(`should use _app instead of _layout in ${dir}`);
|
|
65
38
|
} else {
|
|
66
|
-
const alias = (0,
|
|
39
|
+
const alias = (0, _utils1.replaceWithAlias)(srcDirectory, layout, srcAlias);
|
|
67
40
|
const componentName = compName(srcDirectory, layout);
|
|
68
41
|
const route = {
|
|
69
42
|
path: `${basePath.substring(0, basePath.length - 1)}`,
|
|
@@ -80,18 +53,16 @@ const recursiveReadDir = ({
|
|
|
80
53
|
routes = route.children;
|
|
81
54
|
}
|
|
82
55
|
}
|
|
83
|
-
for (const relative of
|
|
84
|
-
const filePath =
|
|
85
|
-
if (!(0,
|
|
86
|
-
const filename =
|
|
87
|
-
const alias = (0,
|
|
56
|
+
for (const relative of _utils.fs.readdirSync(dir)) {
|
|
57
|
+
const filePath = _path.default.join(dir, relative);
|
|
58
|
+
if (!(0, _utils2.shouldSkip)(filePath)) {
|
|
59
|
+
const filename = _path.default.basename(filePath, _path.default.extname(filePath));
|
|
60
|
+
const alias = (0, _utils1.replaceWithAlias)(srcDirectory, filePath, srcAlias);
|
|
88
61
|
const componentName = compName(srcDirectory, filePath);
|
|
89
|
-
const dynamicRouteMatched =
|
|
62
|
+
const dynamicRouteMatched = _constants.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP.exec(filename);
|
|
90
63
|
if (dynamicRouteMatched) {
|
|
91
64
|
if (hasDynamicRoute) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`Can't set two dynamic route in one directory: ${dir}`
|
|
94
|
-
);
|
|
65
|
+
throw new Error(`Can't set two dynamic route in one directory: ${dir}`);
|
|
95
66
|
} else {
|
|
96
67
|
hasDynamicRoute = true;
|
|
97
68
|
}
|
|
@@ -103,7 +74,7 @@ const recursiveReadDir = ({
|
|
|
103
74
|
parent,
|
|
104
75
|
type: "page"
|
|
105
76
|
};
|
|
106
|
-
if (
|
|
77
|
+
if (_utils.fs.statSync(filePath).isDirectory()) {
|
|
107
78
|
recursiveReadDir({
|
|
108
79
|
dir: filePath,
|
|
109
80
|
routes,
|
|
@@ -113,10 +84,10 @@ const recursiveReadDir = ({
|
|
|
113
84
|
});
|
|
114
85
|
continue;
|
|
115
86
|
}
|
|
116
|
-
if (filename ===
|
|
87
|
+
if (filename === _constants.FILE_SYSTEM_ROUTES_LAYOUT) {
|
|
117
88
|
continue;
|
|
118
89
|
}
|
|
119
|
-
if (filename ===
|
|
90
|
+
if (filename === _constants.FILE_SYSTEM_ROUTES_INDEX) {
|
|
120
91
|
route.path = basePath === "/" ? basePath : `${basePath.substring(0, basePath.length - 1)}`;
|
|
121
92
|
}
|
|
122
93
|
if (filename === "404" && basePath === "/") {
|
|
@@ -130,12 +101,9 @@ const recursiveReadDir = ({
|
|
|
130
101
|
}
|
|
131
102
|
};
|
|
132
103
|
const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory, internalDirAlias) => {
|
|
133
|
-
const flat = (routes) => routes.reduce(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
),
|
|
137
|
-
[]
|
|
138
|
-
);
|
|
104
|
+
const flat = (routes) => routes.reduce((memo, route) => memo.concat(Array.isArray(route.children) ? flat(route.children) : [
|
|
105
|
+
route
|
|
106
|
+
]), []);
|
|
139
107
|
const generate = (route) => {
|
|
140
108
|
const codes = [];
|
|
141
109
|
let lastComponent = route.component;
|
|
@@ -148,50 +116,38 @@ const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory,
|
|
|
148
116
|
const layoutComponentAbbr = layoutNameAbbr(route._component);
|
|
149
117
|
imports.push(`import ${layoutComponent} from '${route._component}';`);
|
|
150
118
|
const currentComponent = `${layoutComponentAbbr}_${lastComponent}`;
|
|
151
|
-
codes.push(
|
|
152
|
-
`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`
|
|
153
|
-
);
|
|
119
|
+
codes.push(`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`);
|
|
154
120
|
lastComponent = currentComponent;
|
|
155
121
|
}
|
|
156
|
-
const file =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
${codes.join(
|
|
161
|
-
"\n"
|
|
162
|
-
)}
|
|
163
|
-
export default ${lastComponent}`
|
|
164
|
-
);
|
|
122
|
+
const file = _path.default.resolve(internalComponentsDir, `${lastComponent}.jsx`);
|
|
123
|
+
_utils.fs.outputFileSync(file, `${imports.join("\n")}
|
|
124
|
+
${codes.join("\n")}
|
|
125
|
+
export default ${lastComponent}`);
|
|
165
126
|
return {
|
|
166
127
|
component: lastComponent,
|
|
167
|
-
_component: (0,
|
|
128
|
+
_component: (0, _utils1.replaceWithAlias)(internalDirectory, file, internalDirAlias)
|
|
168
129
|
};
|
|
169
130
|
};
|
|
170
|
-
const normalized = flat(nested).map(
|
|
171
|
-
|
|
172
|
-
|
|
131
|
+
const normalized = flat(nested).map((route) => route.parent ? {
|
|
132
|
+
...route,
|
|
133
|
+
...generate(route),
|
|
134
|
+
parent: void 0
|
|
135
|
+
} : {
|
|
136
|
+
...route,
|
|
137
|
+
parent: void 0
|
|
138
|
+
});
|
|
173
139
|
return normalized;
|
|
174
140
|
};
|
|
175
|
-
const getClientRoutes = ({
|
|
176
|
-
entrypoint,
|
|
177
|
-
srcDirectory,
|
|
178
|
-
srcAlias,
|
|
179
|
-
internalDirectory,
|
|
180
|
-
internalDirAlias
|
|
181
|
-
}) => {
|
|
141
|
+
const getClientRoutes = ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias }) => {
|
|
182
142
|
const { entryName, pageRoutesEntry } = entrypoint;
|
|
183
143
|
if (!pageRoutesEntry) {
|
|
184
144
|
return [];
|
|
185
145
|
}
|
|
186
|
-
if (!
|
|
187
|
-
throw new Error(
|
|
188
|
-
`generate file system routes error, ${pageRoutesEntry} directory not found.`
|
|
189
|
-
);
|
|
146
|
+
if (!_utils.fs.existsSync(pageRoutesEntry)) {
|
|
147
|
+
throw new Error(`generate file system routes error, ${pageRoutesEntry} directory not found.`);
|
|
190
148
|
}
|
|
191
|
-
if (!(
|
|
192
|
-
throw new Error(
|
|
193
|
-
`generate file system routes error, ${pageRoutesEntry} should be directory.`
|
|
194
|
-
);
|
|
149
|
+
if (!(_utils.fs.existsSync(pageRoutesEntry) && _utils.fs.statSync(pageRoutesEntry).isDirectory())) {
|
|
150
|
+
throw new Error(`generate file system routes error, ${pageRoutesEntry} should be directory.`);
|
|
195
151
|
}
|
|
196
152
|
let routes = [];
|
|
197
153
|
recursiveReadDir({
|
|
@@ -201,29 +157,17 @@ const getClientRoutes = ({
|
|
|
201
157
|
srcDirectory,
|
|
202
158
|
srcAlias
|
|
203
159
|
});
|
|
204
|
-
const internalComponentsDir =
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
);
|
|
208
|
-
import_utils.fs.emptyDirSync(internalComponentsDir);
|
|
209
|
-
routes = normalizeNestedRoutes(
|
|
210
|
-
routes,
|
|
211
|
-
internalComponentsDir,
|
|
212
|
-
internalDirectory,
|
|
213
|
-
internalDirAlias
|
|
214
|
-
);
|
|
160
|
+
const internalComponentsDir = _path.default.resolve(internalDirectory, `${entryName}/${_constants.FILE_SYSTEM_ROUTES_COMPONENTS_DIR}`);
|
|
161
|
+
_utils.fs.emptyDirSync(internalComponentsDir);
|
|
162
|
+
routes = normalizeNestedRoutes(routes, internalComponentsDir, internalDirectory, internalDirAlias);
|
|
215
163
|
parents.length = 0;
|
|
216
164
|
routes.sort((a, b) => {
|
|
217
|
-
const delta = (0,
|
|
165
|
+
const delta = (0, _utils2.getRouteWeight)(a.path) - (0, _utils2.getRouteWeight)(b.path);
|
|
218
166
|
if (delta === 0) {
|
|
219
167
|
return a.path.length - b.path.length;
|
|
220
168
|
}
|
|
221
169
|
return delta;
|
|
222
170
|
});
|
|
223
|
-
(0,
|
|
171
|
+
(0, _utils2.debug)(`fileSystem routes: %o`, routes);
|
|
224
172
|
return routes;
|
|
225
173
|
};
|
|
226
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
227
|
-
0 && (module.exports = {
|
|
228
|
-
getClientRoutes
|
|
229
|
-
});
|
|
@@ -1,69 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 getRoutesLegacy_exports = {};
|
|
29
|
-
__export(getRoutesLegacy_exports, {
|
|
30
|
-
getClientRoutes: () => getClientRoutes
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getClientRoutes", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => getClientRoutes
|
|
31
8
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _makeLegalIdentifier = require("../makeLegalIdentifier");
|
|
12
|
+
const _constants = require("../constants");
|
|
13
|
+
const _utils1 = require("../utils");
|
|
14
|
+
const _utils2 = require("./utils");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
39
20
|
const compName = (srcDirectory, filePath) => {
|
|
40
|
-
const legalCompName = (0,
|
|
41
|
-
import_path.default.relative(srcDirectory, filePath)
|
|
42
|
-
);
|
|
21
|
+
const legalCompName = (0, _makeLegalIdentifier.makeLegalIdentifier)(_path.default.relative(srcDirectory, filePath));
|
|
43
22
|
return `Comp_${legalCompName}`;
|
|
44
23
|
};
|
|
45
24
|
const layoutNameAbbr = (filePath) => {
|
|
46
25
|
const prefix = "L_";
|
|
47
|
-
const dirName =
|
|
48
|
-
return `${prefix}${(0,
|
|
26
|
+
const dirName = _path.default.dirname(filePath).split("/").pop() || "";
|
|
27
|
+
return `${prefix}${(0, _makeLegalIdentifier.makeLegalIdentifier)(dirName)}`;
|
|
49
28
|
};
|
|
50
29
|
const parents = [];
|
|
51
|
-
const recursiveReadDirLegacy = ({
|
|
52
|
-
dir,
|
|
53
|
-
routes,
|
|
54
|
-
basePath = "/",
|
|
55
|
-
srcDirectory,
|
|
56
|
-
srcAlias
|
|
57
|
-
}) => {
|
|
30
|
+
const recursiveReadDirLegacy = ({ dir, routes, basePath = "/", srcDirectory, srcAlias }) => {
|
|
58
31
|
let hasDynamicRoute = false;
|
|
59
32
|
let resetParent = false;
|
|
60
33
|
let parent = parents[parents.length - 1];
|
|
61
|
-
const layout = (0,
|
|
34
|
+
const layout = (0, _utils2.findLayout)(dir);
|
|
62
35
|
if (layout) {
|
|
63
36
|
if (basePath === "/") {
|
|
64
37
|
throw new Error(`should use _app instead of _layout in ${dir}`);
|
|
65
38
|
} else {
|
|
66
|
-
const alias = (0,
|
|
39
|
+
const alias = (0, _utils1.replaceWithAlias)(srcDirectory, layout, srcAlias);
|
|
67
40
|
const componentName = compName(srcDirectory, layout);
|
|
68
41
|
const route = {
|
|
69
42
|
path: `${basePath.substring(0, basePath.length - 1)}`,
|
|
@@ -80,18 +53,16 @@ const recursiveReadDirLegacy = ({
|
|
|
80
53
|
routes = route.routes;
|
|
81
54
|
}
|
|
82
55
|
}
|
|
83
|
-
for (const relative of
|
|
84
|
-
const filePath =
|
|
85
|
-
if (!(0,
|
|
86
|
-
const filename =
|
|
87
|
-
const alias = (0,
|
|
56
|
+
for (const relative of _utils.fs.readdirSync(dir)) {
|
|
57
|
+
const filePath = _path.default.join(dir, relative);
|
|
58
|
+
if (!(0, _utils2.shouldSkip)(filePath)) {
|
|
59
|
+
const filename = _path.default.basename(filePath, _path.default.extname(filePath));
|
|
60
|
+
const alias = (0, _utils1.replaceWithAlias)(srcDirectory, filePath, srcAlias);
|
|
88
61
|
const componentName = compName(srcDirectory, filePath);
|
|
89
|
-
const dynamicRouteMatched =
|
|
62
|
+
const dynamicRouteMatched = _constants.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP.exec(filename);
|
|
90
63
|
if (dynamicRouteMatched) {
|
|
91
64
|
if (hasDynamicRoute) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`Can't set two dynamic route in one directory: ${dir}`
|
|
94
|
-
);
|
|
65
|
+
throw new Error(`Can't set two dynamic route in one directory: ${dir}`);
|
|
95
66
|
} else {
|
|
96
67
|
hasDynamicRoute = true;
|
|
97
68
|
}
|
|
@@ -103,7 +74,7 @@ const recursiveReadDirLegacy = ({
|
|
|
103
74
|
exact: true,
|
|
104
75
|
parent
|
|
105
76
|
};
|
|
106
|
-
if (
|
|
77
|
+
if (_utils.fs.statSync(filePath).isDirectory()) {
|
|
107
78
|
recursiveReadDirLegacy({
|
|
108
79
|
dir: filePath,
|
|
109
80
|
routes,
|
|
@@ -113,10 +84,10 @@ const recursiveReadDirLegacy = ({
|
|
|
113
84
|
});
|
|
114
85
|
continue;
|
|
115
86
|
}
|
|
116
|
-
if (filename ===
|
|
87
|
+
if (filename === _constants.FILE_SYSTEM_ROUTES_LAYOUT) {
|
|
117
88
|
continue;
|
|
118
89
|
}
|
|
119
|
-
if (filename ===
|
|
90
|
+
if (filename === _constants.FILE_SYSTEM_ROUTES_INDEX) {
|
|
120
91
|
route.path = basePath === "/" ? basePath : `${basePath.substring(0, basePath.length - 1)}`;
|
|
121
92
|
}
|
|
122
93
|
if (filename === "404" && basePath === "/") {
|
|
@@ -131,10 +102,9 @@ const recursiveReadDirLegacy = ({
|
|
|
131
102
|
}
|
|
132
103
|
};
|
|
133
104
|
const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory, internalDirAlias) => {
|
|
134
|
-
const flat = (routes) => routes.reduce(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
);
|
|
105
|
+
const flat = (routes) => routes.reduce((memo, route) => memo.concat(Array.isArray(route.routes) ? flat(route.routes) : [
|
|
106
|
+
route
|
|
107
|
+
]), []);
|
|
138
108
|
const generate = (route) => {
|
|
139
109
|
const codes = [];
|
|
140
110
|
let lastComponent = route.component;
|
|
@@ -147,47 +117,35 @@ const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory,
|
|
|
147
117
|
const layoutComponentAbbr = layoutNameAbbr(route._component);
|
|
148
118
|
imports.push(`import ${layoutComponent} from '${route._component}';`);
|
|
149
119
|
const currentComponent = `${layoutComponentAbbr}_${lastComponent}`;
|
|
150
|
-
codes.push(
|
|
151
|
-
`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`
|
|
152
|
-
);
|
|
120
|
+
codes.push(`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`);
|
|
153
121
|
lastComponent = currentComponent;
|
|
154
122
|
}
|
|
155
|
-
const file =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
${codes.join(
|
|
160
|
-
"\n"
|
|
161
|
-
)}
|
|
162
|
-
export default ${lastComponent}`
|
|
163
|
-
);
|
|
123
|
+
const file = _path.default.resolve(internalComponentsDir, `${lastComponent}.jsx`);
|
|
124
|
+
_utils.fs.outputFileSync(file, `${imports.join("\n")}
|
|
125
|
+
${codes.join("\n")}
|
|
126
|
+
export default ${lastComponent}`);
|
|
164
127
|
return {
|
|
165
128
|
component: lastComponent,
|
|
166
|
-
_component: (0,
|
|
129
|
+
_component: (0, _utils1.replaceWithAlias)(internalDirectory, file, internalDirAlias)
|
|
167
130
|
};
|
|
168
131
|
};
|
|
169
|
-
const normalized = flat(nested).map(
|
|
170
|
-
|
|
171
|
-
|
|
132
|
+
const normalized = flat(nested).map((route) => route.parent ? {
|
|
133
|
+
...route,
|
|
134
|
+
...generate(route),
|
|
135
|
+
parent: void 0
|
|
136
|
+
} : {
|
|
137
|
+
...route,
|
|
138
|
+
parent: void 0
|
|
139
|
+
});
|
|
172
140
|
return normalized;
|
|
173
141
|
};
|
|
174
|
-
const getClientRoutes = ({
|
|
175
|
-
entrypoint,
|
|
176
|
-
srcDirectory,
|
|
177
|
-
srcAlias,
|
|
178
|
-
internalDirectory,
|
|
179
|
-
internalDirAlias
|
|
180
|
-
}) => {
|
|
142
|
+
const getClientRoutes = ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias }) => {
|
|
181
143
|
const { entry, entryName } = entrypoint;
|
|
182
|
-
if (!
|
|
183
|
-
throw new Error(
|
|
184
|
-
`generate file system routes error, ${entry} directory not found.`
|
|
185
|
-
);
|
|
144
|
+
if (!_utils.fs.existsSync(entry)) {
|
|
145
|
+
throw new Error(`generate file system routes error, ${entry} directory not found.`);
|
|
186
146
|
}
|
|
187
|
-
if (!(
|
|
188
|
-
throw new Error(
|
|
189
|
-
`generate file system routes error, ${entry} should be directory.`
|
|
190
|
-
);
|
|
147
|
+
if (!(_utils.fs.existsSync(entry) && _utils.fs.statSync(entry).isDirectory())) {
|
|
148
|
+
throw new Error(`generate file system routes error, ${entry} should be directory.`);
|
|
191
149
|
}
|
|
192
150
|
let routes = [];
|
|
193
151
|
recursiveReadDirLegacy({
|
|
@@ -197,29 +155,17 @@ const getClientRoutes = ({
|
|
|
197
155
|
srcDirectory,
|
|
198
156
|
srcAlias
|
|
199
157
|
});
|
|
200
|
-
const internalComponentsDir =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
);
|
|
204
|
-
import_utils.fs.emptyDirSync(internalComponentsDir);
|
|
205
|
-
routes = normalizeNestedRoutes(
|
|
206
|
-
routes,
|
|
207
|
-
internalComponentsDir,
|
|
208
|
-
internalDirectory,
|
|
209
|
-
internalDirAlias
|
|
210
|
-
);
|
|
158
|
+
const internalComponentsDir = _path.default.resolve(internalDirectory, `${entryName}/${_constants.FILE_SYSTEM_ROUTES_COMPONENTS_DIR}`);
|
|
159
|
+
_utils.fs.emptyDirSync(internalComponentsDir);
|
|
160
|
+
routes = normalizeNestedRoutes(routes, internalComponentsDir, internalDirectory, internalDirAlias);
|
|
211
161
|
parents.length = 0;
|
|
212
162
|
routes.sort((a, b) => {
|
|
213
|
-
const delta = (0,
|
|
163
|
+
const delta = (0, _utils2.getRouteWeight)(a.path) - (0, _utils2.getRouteWeight)(b.path);
|
|
214
164
|
if (delta === 0) {
|
|
215
165
|
return a.path.length - b.path.length;
|
|
216
166
|
}
|
|
217
167
|
return delta;
|
|
218
168
|
});
|
|
219
|
-
(0,
|
|
169
|
+
(0, _utils2.debug)(`fileSystem routes: %o`, routes);
|
|
220
170
|
return routes;
|
|
221
171
|
};
|
|
222
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
223
|
-
0 && (module.exports = {
|
|
224
|
-
getClientRoutes
|
|
225
|
-
});
|
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var getClientRoutes_exports = {};
|
|
19
|
-
__export(getClientRoutes_exports, {
|
|
20
|
-
getClientRoutes: () => import_getRoutes.getClientRoutes,
|
|
21
|
-
getClientRoutesLegacy: () => import_getRoutesLegacy.getClientRoutes
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
22
4
|
});
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
getClientRoutes: () => _getRoutes.getClientRoutes,
|
|
14
|
+
getClientRoutesLegacy: () => _getRoutesLegacy.getClientRoutes
|
|
30
15
|
});
|
|
16
|
+
const _getRoutes = require("./getRoutes");
|
|
17
|
+
const _getRoutesLegacy = require("./getRoutesLegacy");
|
|
@@ -1,62 +1,38 @@
|
|
|
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 utils_exports = {};
|
|
29
|
-
__export(utils_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
30
13
|
debug: () => debug,
|
|
31
14
|
findLayout: () => findLayout,
|
|
32
15
|
getRouteWeight: () => getRouteWeight,
|
|
33
16
|
shouldSkip: () => shouldSkip
|
|
34
17
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
18
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
19
|
+
const _utils = require("@modern-js/utils");
|
|
20
|
+
const _constants = require("../constants");
|
|
21
|
+
function _interop_require_default(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const debug = (0, _utils.createDebugger)("get-client-routes");
|
|
27
|
+
const findLayout = (dir) => (0, _utils.findExists)(_constants.JS_EXTENSIONS.map((ext) => _path.default.resolve(dir, `${_constants.FILE_SYSTEM_ROUTES_LAYOUT}${ext}`)));
|
|
45
28
|
const getRouteWeight = (route) => route === "*" ? 999 : route.split(":").length - 1;
|
|
46
29
|
const shouldSkip = (file) => {
|
|
47
|
-
if (
|
|
30
|
+
if (_utils.fs.statSync(file).isDirectory()) {
|
|
48
31
|
return false;
|
|
49
32
|
}
|
|
50
|
-
const ext =
|
|
51
|
-
if (
|
|
33
|
+
const ext = _path.default.extname(file);
|
|
34
|
+
if (_constants.FILE_SYSTEM_ROUTES_IGNORED_REGEX.test(file) || !_constants.JS_EXTENSIONS.includes(ext) || _constants.FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT === _path.default.basename(file, ext)) {
|
|
52
35
|
return true;
|
|
53
36
|
}
|
|
54
37
|
return false;
|
|
55
38
|
};
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
debug,
|
|
59
|
-
findLayout,
|
|
60
|
-
getRouteWeight,
|
|
61
|
-
shouldSkip
|
|
62
|
-
});
|