@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,45 +1,66 @@
|
|
|
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 isDefaultExportFunction_exports = {};
|
|
29
|
-
__export(isDefaultExportFunction_exports, {
|
|
30
|
-
isDefaultExportFunction: () => isDefaultExportFunction
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
5
|
+
Object.defineProperty(exports, "isDefaultExportFunction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => isDefaultExportFunction
|
|
8
|
+
});
|
|
9
|
+
const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
|
|
10
|
+
const _parser = require("@babel/parser");
|
|
11
|
+
const _traverse = /* @__PURE__ */ _interop_require_default(require("@babel/traverse"));
|
|
12
|
+
const _types = /* @__PURE__ */ _interop_require_wildcard(require("@babel/types"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
19
|
+
if (typeof WeakMap !== "function")
|
|
20
|
+
return null;
|
|
21
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
23
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
24
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
25
|
+
})(nodeInterop);
|
|
26
|
+
}
|
|
27
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
28
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
32
|
+
return {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
37
|
+
if (cache && cache.has(obj)) {
|
|
38
|
+
return cache.get(obj);
|
|
39
|
+
}
|
|
40
|
+
var newObj = {};
|
|
41
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
|
+
for (var key in obj) {
|
|
43
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
45
|
+
if (desc && (desc.get || desc.set)) {
|
|
46
|
+
Object.defineProperty(newObj, key, desc);
|
|
47
|
+
} else {
|
|
48
|
+
newObj[key] = obj[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
newObj.default = obj;
|
|
53
|
+
if (cache) {
|
|
54
|
+
cache.set(obj, newObj);
|
|
55
|
+
}
|
|
56
|
+
return newObj;
|
|
57
|
+
}
|
|
58
|
+
const isFunction = (node) => _types.isFunctionDeclaration(node) || _types.isFunctionExpression(node) || _types.isArrowFunctionExpression(node);
|
|
38
59
|
const isDefaultExportFunction = (file) => {
|
|
39
|
-
if (!file || !
|
|
60
|
+
if (!file || !_fs.default.existsSync(file)) {
|
|
40
61
|
return false;
|
|
41
62
|
}
|
|
42
|
-
const ast = (0,
|
|
63
|
+
const ast = (0, _parser.parse)(_fs.default.readFileSync(file, "utf8"), {
|
|
43
64
|
sourceType: "unambiguous",
|
|
44
65
|
plugins: [
|
|
45
66
|
"jsx",
|
|
@@ -51,7 +72,12 @@ const isDefaultExportFunction = (file) => {
|
|
|
51
72
|
"decorators-legacy",
|
|
52
73
|
"functionBind",
|
|
53
74
|
"classPrivateMethods",
|
|
54
|
-
[
|
|
75
|
+
[
|
|
76
|
+
"pipelineOperator",
|
|
77
|
+
{
|
|
78
|
+
proposal: "minimal"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
55
81
|
"optionalChaining",
|
|
56
82
|
"optionalCatchBinding",
|
|
57
83
|
"objectRestSpread",
|
|
@@ -59,7 +85,7 @@ const isDefaultExportFunction = (file) => {
|
|
|
59
85
|
]
|
|
60
86
|
});
|
|
61
87
|
let isExportFunction = false;
|
|
62
|
-
(0,
|
|
88
|
+
(0, _traverse.default)(ast, {
|
|
63
89
|
ExportDefaultDeclaration: (path) => {
|
|
64
90
|
const { declaration } = path.node;
|
|
65
91
|
if (isFunction(declaration)) {
|
|
@@ -69,7 +95,3 @@ const isDefaultExportFunction = (file) => {
|
|
|
69
95
|
});
|
|
70
96
|
return isExportFunction;
|
|
71
97
|
};
|
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
-
0 && (module.exports = {
|
|
74
|
-
isDefaultExportFunction
|
|
75
|
-
});
|
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 makeLegalIdentifier_exports = {};
|
|
19
|
-
__export(makeLegalIdentifier_exports, {
|
|
20
|
-
makeLegalIdentifier: () => makeLegalIdentifier
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "makeLegalIdentifier", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => makeLegalIdentifier
|
|
21
8
|
});
|
|
22
|
-
module.exports = __toCommonJS(makeLegalIdentifier_exports);
|
|
23
9
|
const reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
|
|
24
10
|
const builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
|
|
25
11
|
const forbidList = new Set(`${reservedWords} ${builtins}`.split(" "));
|
|
@@ -30,7 +16,3 @@ function makeLegalIdentifier(str) {
|
|
|
30
16
|
}
|
|
31
17
|
return identifier || "_";
|
|
32
18
|
}
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
makeLegalIdentifier
|
|
36
|
-
});
|
|
@@ -1,57 +1,68 @@
|
|
|
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 nestedRoutes_exports = {};
|
|
29
|
-
__export(nestedRoutes_exports, {
|
|
30
|
-
walk: () => walk
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "walk", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => walk
|
|
31
8
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _constants = require("./constants");
|
|
12
|
+
const _utils1 = require("./utils");
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
14
|
+
if (typeof WeakMap !== "function")
|
|
15
|
+
return null;
|
|
16
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
19
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
20
|
+
})(nodeInterop);
|
|
21
|
+
}
|
|
22
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
27
|
+
return {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
32
|
+
if (cache && cache.has(obj)) {
|
|
33
|
+
return cache.get(obj);
|
|
34
|
+
}
|
|
35
|
+
var newObj = {};
|
|
36
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
|
+
for (var key in obj) {
|
|
38
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
39
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
40
|
+
if (desc && (desc.get || desc.set)) {
|
|
41
|
+
Object.defineProperty(newObj, key, desc);
|
|
42
|
+
} else {
|
|
43
|
+
newObj[key] = obj[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
newObj.default = obj;
|
|
48
|
+
if (cache) {
|
|
49
|
+
cache.set(obj, newObj);
|
|
50
|
+
}
|
|
51
|
+
return newObj;
|
|
52
|
+
}
|
|
53
|
+
const conventionNames = Object.values(_constants.NESTED_ROUTE);
|
|
38
54
|
const replaceDynamicPath = (routePath) => {
|
|
39
55
|
return routePath.replace(/\[(.*?)\]/g, ":$1");
|
|
40
56
|
};
|
|
41
57
|
const createIndexRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
42
|
-
return createRoute(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
rootDir,
|
|
49
|
-
filename,
|
|
50
|
-
entryName
|
|
51
|
-
);
|
|
58
|
+
return createRoute({
|
|
59
|
+
...routeInfo,
|
|
60
|
+
index: true,
|
|
61
|
+
children: void 0
|
|
62
|
+
}, rootDir, filename, entryName);
|
|
52
63
|
};
|
|
53
64
|
const createRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
54
|
-
const id = (0,
|
|
65
|
+
const id = (0, _utils.getRouteId)(filename, rootDir, entryName);
|
|
55
66
|
return {
|
|
56
67
|
...routeInfo,
|
|
57
68
|
id,
|
|
@@ -59,16 +70,16 @@ const createRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
|
59
70
|
};
|
|
60
71
|
};
|
|
61
72
|
const walk = async (dirname, rootDir, alias, entryName) => {
|
|
62
|
-
var
|
|
63
|
-
if (!await
|
|
73
|
+
var _route_children;
|
|
74
|
+
if (!await _utils.fs.pathExists(dirname)) {
|
|
64
75
|
return null;
|
|
65
76
|
}
|
|
66
|
-
const isDirectory = (await
|
|
77
|
+
const isDirectory = (await _utils.fs.stat(dirname)).isDirectory();
|
|
67
78
|
if (!isDirectory) {
|
|
68
79
|
return null;
|
|
69
80
|
}
|
|
70
|
-
const relativeDir =
|
|
71
|
-
const pathSegments = relativeDir.split(
|
|
81
|
+
const relativeDir = _path.relative(rootDir, dirname);
|
|
82
|
+
const pathSegments = relativeDir.split(_path.sep);
|
|
72
83
|
const lastSegment = pathSegments[pathSegments.length - 1];
|
|
73
84
|
const isRoot = lastSegment === "";
|
|
74
85
|
const isPathlessLayout = lastSegment.startsWith("__");
|
|
@@ -79,7 +90,7 @@ const walk = async (dirname, rootDir, alias, entryName) => {
|
|
|
79
90
|
}
|
|
80
91
|
routePath = replaceDynamicPath(routePath);
|
|
81
92
|
const route = {
|
|
82
|
-
path: routePath
|
|
93
|
+
path: routePath === null || routePath === void 0 ? void 0 : routePath.replace(/\$$/, "?"),
|
|
83
94
|
children: [],
|
|
84
95
|
isRoot
|
|
85
96
|
};
|
|
@@ -88,108 +99,92 @@ const walk = async (dirname, rootDir, alias, entryName) => {
|
|
|
88
99
|
let splatLoaderFile = "";
|
|
89
100
|
let splatRoute = null;
|
|
90
101
|
let pageConfigFile = "";
|
|
91
|
-
const items = await
|
|
102
|
+
const items = await _utils.fs.readdir(dirname);
|
|
92
103
|
for (const item of items) {
|
|
93
|
-
const itemPath =
|
|
94
|
-
const extname =
|
|
104
|
+
const itemPath = _path.join(dirname, item);
|
|
105
|
+
const extname = _path.extname(item);
|
|
95
106
|
const itemWithoutExt = item.slice(0, -extname.length);
|
|
96
|
-
const isDirectory2 = (await
|
|
107
|
+
const isDirectory2 = (await _utils.fs.stat(itemPath)).isDirectory();
|
|
97
108
|
if (isDirectory2) {
|
|
98
109
|
const childRoute = await walk(itemPath, rootDir, alias, entryName);
|
|
99
110
|
if (childRoute) {
|
|
100
|
-
|
|
111
|
+
var _route_children1;
|
|
112
|
+
(_route_children1 = route.children) === null || _route_children1 === void 0 ? void 0 : _route_children1.push(childRoute);
|
|
101
113
|
}
|
|
102
114
|
}
|
|
103
|
-
if (extname && (!
|
|
115
|
+
if (extname && (!_constants.JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt))) {
|
|
104
116
|
continue;
|
|
105
117
|
}
|
|
106
|
-
if (itemWithoutExt ===
|
|
118
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.LAYOUT_LOADER_FILE) {
|
|
107
119
|
if (!route.loader) {
|
|
108
120
|
route.loader = itemPath;
|
|
109
121
|
}
|
|
110
122
|
}
|
|
111
|
-
if (itemWithoutExt ===
|
|
123
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.LAYOUT_CONFIG_FILE) {
|
|
112
124
|
if (!route.config) {
|
|
113
125
|
route.config = itemPath;
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
|
-
if (itemWithoutExt ===
|
|
117
|
-
route._component = (0,
|
|
128
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.LAYOUT_FILE) {
|
|
129
|
+
route._component = (0, _utils1.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
118
130
|
}
|
|
119
|
-
if (itemWithoutExt ===
|
|
131
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.PAGE_LOADER_FILE) {
|
|
120
132
|
pageLoaderFile = itemPath;
|
|
121
133
|
}
|
|
122
|
-
if (itemWithoutExt ===
|
|
134
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.PAGE_CONFIG_FILE) {
|
|
123
135
|
pageConfigFile = itemPath;
|
|
124
136
|
}
|
|
125
|
-
if (itemWithoutExt ===
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
rootDir,
|
|
131
|
-
itemPath,
|
|
132
|
-
entryName
|
|
133
|
-
);
|
|
137
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.PAGE_FILE) {
|
|
138
|
+
var _route_children2;
|
|
139
|
+
pageRoute = createIndexRoute({
|
|
140
|
+
_component: (0, _utils1.replaceWithAlias)(alias.basename, itemPath, alias.name)
|
|
141
|
+
}, rootDir, itemPath, entryName);
|
|
134
142
|
if (pageLoaderFile) {
|
|
135
143
|
pageRoute.loader = pageLoaderFile;
|
|
136
144
|
}
|
|
137
145
|
if (pageConfigFile) {
|
|
138
146
|
pageRoute.config = pageConfigFile;
|
|
139
147
|
}
|
|
140
|
-
(
|
|
148
|
+
(_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(pageRoute);
|
|
141
149
|
}
|
|
142
|
-
if (itemWithoutExt ===
|
|
150
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_LOADER_FILE) {
|
|
143
151
|
splatLoaderFile = itemPath;
|
|
144
152
|
}
|
|
145
|
-
if (itemWithoutExt ===
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
rootDir,
|
|
152
|
-
itemPath,
|
|
153
|
-
entryName
|
|
154
|
-
);
|
|
153
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_FILE) {
|
|
154
|
+
var _route_children3;
|
|
155
|
+
splatRoute = createRoute({
|
|
156
|
+
_component: (0, _utils1.replaceWithAlias)(alias.basename, itemPath, alias.name),
|
|
157
|
+
path: "*"
|
|
158
|
+
}, rootDir, itemPath, entryName);
|
|
155
159
|
if (splatLoaderFile) {
|
|
156
160
|
splatRoute.loader = splatLoaderFile;
|
|
157
161
|
}
|
|
158
|
-
(
|
|
162
|
+
(_route_children3 = route.children) === null || _route_children3 === void 0 ? void 0 : _route_children3.push(splatRoute);
|
|
159
163
|
}
|
|
160
|
-
if (itemWithoutExt ===
|
|
161
|
-
route.loading = (0,
|
|
164
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.LOADING_FILE) {
|
|
165
|
+
route.loading = (0, _utils1.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
162
166
|
}
|
|
163
|
-
if (itemWithoutExt ===
|
|
164
|
-
route.error = (0,
|
|
167
|
+
if (itemWithoutExt === _constants.NESTED_ROUTE.ERROR_FILE) {
|
|
168
|
+
route.error = (0, _utils1.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
|
-
let finalRoute = createRoute(
|
|
168
|
-
route,
|
|
169
|
-
rootDir,
|
|
170
|
-
path.join(dirname, `${import_constants.NESTED_ROUTE.LAYOUT_FILE}.ts`),
|
|
171
|
-
entryName
|
|
172
|
-
);
|
|
171
|
+
let finalRoute = createRoute(route, rootDir, _path.join(dirname, `${_constants.NESTED_ROUTE.LAYOUT_FILE}.ts`), entryName);
|
|
173
172
|
if (isPathlessLayout) {
|
|
174
173
|
delete finalRoute.path;
|
|
175
174
|
}
|
|
176
|
-
route.children = (
|
|
175
|
+
route.children = (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.filter((childRoute) => childRoute);
|
|
177
176
|
if (route.children && route.children.length === 0 && !route.index) {
|
|
178
177
|
return null;
|
|
179
178
|
}
|
|
180
179
|
if (finalRoute.children && finalRoute.children.length === 1 && !finalRoute._component) {
|
|
181
180
|
const childRoute = finalRoute.children[0];
|
|
182
181
|
if (childRoute.path === "*") {
|
|
183
|
-
const
|
|
182
|
+
const path = `${finalRoute.path || ""}/${childRoute.path || ""}`;
|
|
184
183
|
finalRoute = {
|
|
185
184
|
...childRoute,
|
|
186
|
-
path
|
|
185
|
+
path
|
|
187
186
|
};
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
189
|
return finalRoute;
|
|
191
190
|
};
|
|
192
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
193
|
-
0 && (module.exports = {
|
|
194
|
-
walk
|
|
195
|
-
});
|