@modern-js/utils 2.35.1 → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/alias.js +45 -46
- package/dist/cjs/cli/applyOptionsChain.js +30 -13
- package/dist/cjs/cli/babel.js +36 -26
- package/dist/cjs/cli/commands.js +29 -21
- package/dist/cjs/cli/common.js +29 -20
- package/dist/cjs/cli/config.js +24 -7
- package/dist/cjs/cli/constants/chainId.js +24 -7
- package/dist/cjs/cli/constants/index.js +86 -104
- package/dist/cjs/cli/ensure.js +37 -18
- package/dist/cjs/cli/fs.js +29 -19
- package/dist/cjs/cli/get/config.js +26 -9
- package/dist/cjs/cli/get/data.js +67 -54
- package/dist/cjs/cli/get/index.js +46 -25
- package/dist/cjs/cli/index.js +58 -23
- package/dist/cjs/cli/is/config.js +37 -31
- package/dist/cjs/cli/is/env.js +32 -29
- package/dist/cjs/cli/is/index.js +26 -8
- package/dist/cjs/cli/is/project.js +67 -53
- package/dist/cjs/cli/is/type.js +39 -36
- package/dist/cjs/cli/logger.js +25 -130
- package/dist/cjs/cli/monorepo.js +58 -58
- package/dist/cjs/cli/package.js +34 -26
- package/dist/cjs/cli/path.js +64 -54
- package/dist/cjs/cli/port.js +39 -13
- package/dist/cjs/cli/prettyInstructions.js +48 -29
- package/dist/cjs/cli/require.js +35 -29
- package/dist/cjs/cli/runtimeExports.js +42 -16
- package/dist/cjs/cli/watch.js +41 -22
- package/dist/cjs/compiled.js +127 -138
- package/dist/cjs/import.js +25 -15
- package/dist/cjs/index.js +24 -6
- package/dist/cjs/universal/constants.js +29 -21
- package/dist/cjs/universal/formatWebpack.js +25 -15
- package/dist/cjs/universal/pluginDagSort.js +25 -8
- package/dist/esm/cli/alias.js +10 -22
- package/dist/esm/cli/applyOptionsChain.js +4 -1
- package/dist/esm/cli/babel.js +6 -2
- package/dist/esm/cli/commands.js +10 -4
- package/dist/esm/cli/common.js +8 -3
- package/dist/esm/cli/config.js +4 -1
- package/dist/esm/cli/constants/chainId.js +4 -1
- package/dist/esm/cli/constants/index.js +64 -31
- package/dist/esm/cli/ensure.js +6 -2
- package/dist/esm/cli/fs.js +6 -2
- package/dist/esm/cli/get/config.js +4 -1
- package/dist/esm/cli/get/data.js +18 -8
- package/dist/esm/cli/get/index.js +6 -2
- package/dist/esm/cli/is/config.js +14 -6
- package/dist/esm/cli/is/env.js +12 -8
- package/dist/esm/cli/is/index.js +0 -1
- package/dist/esm/cli/is/project.js +17 -8
- package/dist/esm/cli/is/type.js +20 -9
- package/dist/esm/cli/logger.js +4 -128
- package/dist/esm/cli/monorepo.js +14 -16
- package/dist/esm/cli/package.js +10 -4
- package/dist/esm/cli/path.js +24 -11
- package/dist/esm/cli/port.js +5 -2
- package/dist/esm/cli/prettyInstructions.js +6 -2
- package/dist/esm/cli/require.js +14 -6
- package/dist/esm/cli/runtimeExports.js +6 -3
- package/dist/esm/cli/watch.js +10 -6
- package/dist/esm/compiled.js +65 -31
- package/dist/esm/import.js +6 -3
- package/dist/esm/universal/constants.js +10 -4
- package/dist/esm/universal/formatWebpack.js +5 -2
- package/dist/esm/universal/pluginDagSort.js +5 -2
- package/dist/esm-node/cli/alias.js +8 -19
- package/dist/esm-node/cli/applyOptionsChain.js +4 -1
- package/dist/esm-node/cli/babel.js +6 -2
- package/dist/esm-node/cli/commands.js +10 -4
- package/dist/esm-node/cli/common.js +8 -3
- package/dist/esm-node/cli/config.js +4 -1
- package/dist/esm-node/cli/constants/chainId.js +4 -1
- package/dist/esm-node/cli/constants/index.js +64 -31
- package/dist/esm-node/cli/ensure.js +6 -2
- package/dist/esm-node/cli/fs.js +6 -2
- package/dist/esm-node/cli/get/config.js +4 -1
- package/dist/esm-node/cli/get/data.js +18 -8
- package/dist/esm-node/cli/get/index.js +6 -2
- package/dist/esm-node/cli/is/config.js +14 -6
- package/dist/esm-node/cli/is/env.js +12 -6
- package/dist/esm-node/cli/is/index.js +0 -1
- package/dist/esm-node/cli/is/project.js +16 -7
- package/dist/esm-node/cli/is/type.js +20 -9
- package/dist/esm-node/cli/logger.js +4 -113
- package/dist/esm-node/cli/monorepo.js +14 -18
- package/dist/esm-node/cli/package.js +10 -4
- package/dist/esm-node/cli/path.js +24 -11
- package/dist/esm-node/cli/port.js +4 -1
- package/dist/esm-node/cli/prettyInstructions.js +6 -2
- package/dist/esm-node/cli/require.js +14 -6
- package/dist/esm-node/cli/runtimeExports.js +4 -1
- package/dist/esm-node/cli/watch.js +6 -2
- package/dist/esm-node/compiled.js +65 -31
- package/dist/esm-node/import.js +5 -2
- package/dist/esm-node/universal/constants.js +10 -4
- package/dist/esm-node/universal/formatWebpack.js +5 -2
- package/dist/esm-node/universal/pluginDagSort.js +5 -2
- package/dist/types/cli/alias.d.ts +0 -5
- package/dist/types/cli/is/env.d.ts +1 -2
- package/dist/types/cli/is/index.d.ts +0 -1
- package/dist/types/cli/logger.d.ts +1 -69
- package/dist/types/cli/monorepo.d.ts +0 -1
- package/package.json +6 -13
- package/dist/cjs/cli/is/platform.js +0 -21
- package/dist/compiled/gradient-string/index.d.ts +0 -1
- package/dist/compiled/gradient-string/index.js +0 -1
- package/dist/compiled/gradient-string/license +0 -21
- package/dist/compiled/gradient-string/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/index.js +0 -7
- package/dist/compiled/webpack-dev-middleware/license +0 -20
- package/dist/compiled/webpack-dev-middleware/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/types/index.d.ts +0 -262
- package/dist/esm/cli/is/platform.js +0 -6
- package/dist/esm-node/cli/is/platform.js +0 -2
- package/dist/types/cli/is/platform.d.ts +0 -2
package/dist/cjs/import.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return lazy;
|
|
15
|
-
},
|
|
16
|
-
Import: function() {
|
|
17
|
-
return Import;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var import_exports = {};
|
|
20
|
+
__export(import_exports, {
|
|
21
|
+
Import: () => Import,
|
|
22
|
+
lazyImport: () => lazy
|
|
19
23
|
});
|
|
24
|
+
module.exports = __toCommonJS(import_exports);
|
|
20
25
|
const lazy = (moduleName, requireFn) => {
|
|
21
26
|
const importLazyLocal = require("../compiled/import-lazy")(requireFn);
|
|
22
27
|
return importLazyLocal(moduleName);
|
|
@@ -24,3 +29,8 @@ const lazy = (moduleName, requireFn) => {
|
|
|
24
29
|
const Import = {
|
|
25
30
|
lazy
|
|
26
31
|
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
Import,
|
|
35
|
+
lazyImport
|
|
36
|
+
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./compiled"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./cli"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./import"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./compiled"),
|
|
24
|
+
...require("./cli"),
|
|
25
|
+
...require("./import")
|
|
4
26
|
});
|
|
5
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
-
_export_star._(require("./compiled"), exports);
|
|
7
|
-
_export_star._(require("./cli"), exports);
|
|
8
|
-
_export_star._(require("./import"), exports);
|
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return ROUTE_MANIFEST;
|
|
15
|
-
},
|
|
16
|
-
HMR_SOCK_PATH: function() {
|
|
17
|
-
return HMR_SOCK_PATH;
|
|
18
|
-
},
|
|
19
|
-
HTML_CHUNKSMAP_SEPARATOR: function() {
|
|
20
|
-
return HTML_CHUNKSMAP_SEPARATOR;
|
|
21
|
-
},
|
|
22
|
-
LOADER_REPORTER_NAME: function() {
|
|
23
|
-
return LOADER_REPORTER_NAME;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
|
22
|
+
HTML_CHUNKSMAP_SEPARATOR: () => HTML_CHUNKSMAP_SEPARATOR,
|
|
23
|
+
LOADER_REPORTER_NAME: () => LOADER_REPORTER_NAME,
|
|
24
|
+
ROUTE_MANIFEST: () => ROUTE_MANIFEST
|
|
25
25
|
});
|
|
26
|
+
module.exports = __toCommonJS(constants_exports);
|
|
26
27
|
const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
|
27
28
|
const HMR_SOCK_PATH = "/webpack-hmr";
|
|
28
29
|
const HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
|
|
29
30
|
const LOADER_REPORTER_NAME = `server-loader`;
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
HMR_SOCK_PATH,
|
|
34
|
+
HTML_CHUNKSMAP_SEPARATOR,
|
|
35
|
+
LOADER_REPORTER_NAME,
|
|
36
|
+
ROUTE_MANIFEST
|
|
37
|
+
});
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return addErrorTips;
|
|
15
|
-
},
|
|
16
|
-
formatWebpackMessages: function() {
|
|
17
|
-
return formatWebpackMessages;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var formatWebpack_exports = {};
|
|
20
|
+
__export(formatWebpack_exports, {
|
|
21
|
+
addErrorTips: () => addErrorTips,
|
|
22
|
+
formatWebpackMessages: () => formatWebpackMessages
|
|
19
23
|
});
|
|
24
|
+
module.exports = __toCommonJS(formatWebpack_exports);
|
|
20
25
|
const friendlySyntaxErrorLabel = "SyntaxError:";
|
|
21
26
|
function isLikelyASyntaxError(message) {
|
|
22
27
|
return message.includes(friendlySyntaxErrorLabel);
|
|
@@ -115,3 +120,8 @@ function formatWebpackMessages(json, color = defaultColor) {
|
|
|
115
120
|
result.errors = addErrorTips(result.errors, color);
|
|
116
121
|
return result;
|
|
117
122
|
}
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
addErrorTips,
|
|
126
|
+
formatWebpackMessages
|
|
127
|
+
});
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pluginDagSort_exports = {};
|
|
20
|
+
__export(pluginDagSort_exports, {
|
|
21
|
+
pluginDagSort: () => pluginDagSort
|
|
10
22
|
});
|
|
23
|
+
module.exports = __toCommonJS(pluginDagSort_exports);
|
|
11
24
|
const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post") => {
|
|
12
25
|
let allLines = [];
|
|
13
26
|
function getPluginByAny(q) {
|
|
@@ -54,7 +67,11 @@ const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post")
|
|
|
54
67
|
restInRingPoints[l[0]] = true;
|
|
55
68
|
restInRingPoints[l[1]] = true;
|
|
56
69
|
});
|
|
57
|
-
throw new Error(`plugins
|
|
70
|
+
throw new Error(`plugins dependencies has loop: ${Object.keys(restInRingPoints).join(",")}`);
|
|
58
71
|
}
|
|
59
72
|
return sortedPoint;
|
|
60
73
|
};
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
pluginDagSort
|
|
77
|
+
});
|
package/dist/esm/cli/alias.js
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { chalk } from "../compiled";
|
|
5
4
|
import { readTsConfigByFile } from "./get";
|
|
6
5
|
import { applyOptionsChain } from "./applyOptionsChain";
|
|
7
|
-
|
|
8
|
-
var tsconfigPath = param.tsconfigPath;
|
|
9
|
-
var alias = modernConfig.source.alias;
|
|
10
|
-
if (!alias) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
var isTsProject = fs.existsSync(tsconfigPath);
|
|
14
|
-
if (!isTsProject) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
var userAlias = getUserAlias(alias);
|
|
18
|
-
if (Object.keys(userAlias).length > 0) {
|
|
19
|
-
return chalk.red('Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript');
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
};
|
|
23
|
-
export var mergeAlias = function(alias) {
|
|
6
|
+
var mergeAlias = function(alias) {
|
|
24
7
|
return applyOptionsChain({}, alias);
|
|
25
8
|
};
|
|
26
|
-
|
|
9
|
+
var getAliasConfig = function(aliasOption, option) {
|
|
27
10
|
var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
|
|
28
11
|
var isTsProject = fs.existsSync(option.tsconfigPath);
|
|
29
12
|
var alias = mergeAlias(aliasOption);
|
|
@@ -32,7 +15,7 @@ export var getAliasConfig = function(aliasOption, option) {
|
|
|
32
15
|
absoluteBaseUrl: option.appDirectory,
|
|
33
16
|
paths: alias,
|
|
34
17
|
isTsPath: false,
|
|
35
|
-
isTsProject
|
|
18
|
+
isTsProject
|
|
36
19
|
};
|
|
37
20
|
}
|
|
38
21
|
var tsconfig = readTsConfigByFile(option.tsconfigPath);
|
|
@@ -41,10 +24,10 @@ export var getAliasConfig = function(aliasOption, option) {
|
|
|
41
24
|
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
|
42
25
|
paths: _object_spread({}, alias, tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths),
|
|
43
26
|
isTsPath: true,
|
|
44
|
-
isTsProject
|
|
27
|
+
isTsProject
|
|
45
28
|
};
|
|
46
29
|
};
|
|
47
|
-
|
|
30
|
+
var getUserAlias = function() {
|
|
48
31
|
var alias = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
49
32
|
return Object.keys(alias).reduce(function(o, k) {
|
|
50
33
|
if (Array.isArray(alias[k])) {
|
|
@@ -53,3 +36,8 @@ export var getUserAlias = function() {
|
|
|
53
36
|
return o;
|
|
54
37
|
}, {});
|
|
55
38
|
};
|
|
39
|
+
export {
|
|
40
|
+
getAliasConfig,
|
|
41
|
+
getUserAlias,
|
|
42
|
+
mergeAlias
|
|
43
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFunction, isPlainObject } from "./is";
|
|
2
2
|
import { logger } from "./logger";
|
|
3
|
-
|
|
3
|
+
function applyOptionsChain(defaults, options, utils) {
|
|
4
4
|
var mergeFn = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : Object.assign;
|
|
5
5
|
if (!options) {
|
|
6
6
|
return defaults;
|
|
@@ -24,3 +24,6 @@ export function applyOptionsChain(defaults, options, utils) {
|
|
|
24
24
|
}
|
|
25
25
|
return defaults;
|
|
26
26
|
}
|
|
27
|
+
export {
|
|
28
|
+
applyOptionsChain
|
|
29
|
+
};
|
package/dist/esm/cli/babel.js
CHANGED
|
@@ -80,7 +80,7 @@ var modifyPresetOptions = function(presetName, options) {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
|
-
|
|
83
|
+
var getBabelUtils = function(config) {
|
|
84
84
|
var noop = function() {
|
|
85
85
|
};
|
|
86
86
|
return {
|
|
@@ -109,10 +109,14 @@ export var getBabelUtils = function(config) {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
};
|
|
112
|
-
|
|
112
|
+
var applyUserBabelConfig = function(defaultOptions, userBabelConfig, extraBabelUtils) {
|
|
113
113
|
if (userBabelConfig) {
|
|
114
114
|
var babelUtils = _object_spread({}, getBabelUtils(defaultOptions), extraBabelUtils);
|
|
115
115
|
return applyOptionsChain(defaultOptions, userBabelConfig || {}, babelUtils);
|
|
116
116
|
}
|
|
117
117
|
return defaultOptions;
|
|
118
118
|
};
|
|
119
|
+
export {
|
|
120
|
+
applyUserBabelConfig,
|
|
121
|
+
getBabelUtils
|
|
122
|
+
};
|
package/dist/esm/cli/commands.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
var getFullArgv = function() {
|
|
2
2
|
var _process_env_MODERN_ARGV;
|
|
3
3
|
return ((_process_env_MODERN_ARGV = process.env.MODERN_ARGV) === null || _process_env_MODERN_ARGV === void 0 ? void 0 : _process_env_MODERN_ARGV.split(" ")) || process.argv;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
var getArgv = function() {
|
|
6
6
|
return getFullArgv().slice(2);
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
var getCommand = function() {
|
|
9
9
|
var args = getArgv();
|
|
10
10
|
var command = args[0];
|
|
11
11
|
return command;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
var isDevCommand = function() {
|
|
14
14
|
var command = getCommand();
|
|
15
15
|
return command === "dev" || command === "start";
|
|
16
16
|
};
|
|
17
|
+
export {
|
|
18
|
+
getArgv,
|
|
19
|
+
getCommand,
|
|
20
|
+
getFullArgv,
|
|
21
|
+
isDevCommand
|
|
22
|
+
};
|
package/dist/esm/cli/common.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { debug } from "../../compiled/debug";
|
|
2
|
-
|
|
2
|
+
var createDebugger = function(scope) {
|
|
3
3
|
return debug("modern-js:".concat(scope));
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
var clearConsole = function() {
|
|
6
6
|
if (process.stdout.isTTY && !process.env.DEBUG) {
|
|
7
7
|
process.stdout.write("\x1B[H\x1B[2J");
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
var wait = function() {
|
|
11
11
|
var time = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
12
12
|
return new Promise(function(resolve) {
|
|
13
13
|
setTimeout(resolve, time);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
+
export {
|
|
17
|
+
clearConsole,
|
|
18
|
+
createDebugger,
|
|
19
|
+
wait
|
|
20
|
+
};
|
package/dist/esm/cli/config.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
var ROUTE_SPEC_FILE = "route.json";
|
|
3
|
+
var NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
|
|
4
|
+
var MAIN_ENTRY_NAME = "main";
|
|
5
|
+
var SERVER_BUNDLE_DIRECTORY = "bundles";
|
|
6
|
+
var SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
|
|
7
|
+
var ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
|
|
8
|
+
var SERVER_RENDER_FUNCTION_NAME = "serverRender";
|
|
9
|
+
var LOADABLE_STATS_FILE = "loadable-stats.json";
|
|
10
|
+
var API_DIR = "api";
|
|
11
|
+
var SERVER_DIR = "server";
|
|
12
|
+
var SHARED_DIR = "shared";
|
|
13
|
+
var CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
|
|
14
|
+
var CONFIG_FILE_EXTENSIONS = [
|
|
15
15
|
".js",
|
|
16
16
|
".ts",
|
|
17
17
|
".mjs"
|
|
18
18
|
];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
var OUTPUT_CONFIG_FILE = "modern.config.json";
|
|
20
|
+
var DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
|
|
21
|
+
var ROUTE_MANIFEST_FILE = "routes-manifest.json";
|
|
22
|
+
var LOADER_ROUTES_DIR = "loader-routes";
|
|
23
|
+
var DEFAULT_DEV_HOST = "0.0.0.0";
|
|
24
|
+
var INTERNAL_APP_TOOLS_PLUGINS = {
|
|
25
25
|
"@modern-js/app-tools": "@modern-js/app-tools/cli",
|
|
26
26
|
"@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
|
|
27
27
|
"@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
|
|
@@ -37,10 +37,10 @@ export var INTERNAL_APP_TOOLS_PLUGINS = {
|
|
|
37
37
|
// legacy router (inner react-router-dom v5)
|
|
38
38
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
|
39
39
|
};
|
|
40
|
-
|
|
40
|
+
var INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = {
|
|
41
41
|
"@modern-js/runtime": "@modern-js/runtime/cli"
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
var INTERNAL_MODULE_TOOLS_PLUGINS = {
|
|
44
44
|
"@modern-js/module-tools": "@modern-js/module-tools",
|
|
45
45
|
"@modern-js/runtime": "@modern-js/runtime/cli",
|
|
46
46
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
|
|
@@ -49,16 +49,16 @@ export var INTERNAL_MODULE_TOOLS_PLUGINS = {
|
|
|
49
49
|
// legacy router (inner react-router-dom v5)
|
|
50
50
|
"@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
var INTERNAL_MONOREPO_TOOLS_PLUGINS = {
|
|
53
53
|
"@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
|
|
54
54
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
|
|
55
55
|
};
|
|
56
|
-
|
|
56
|
+
var INTERNAL_DOC_TOOLS_PLUGINS = {
|
|
57
57
|
"@modern-js/doc-tools": "@modern-js/doc-tools",
|
|
58
58
|
"@modern-js/runtime": "@modern-js/runtime/cli",
|
|
59
59
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
|
|
60
60
|
};
|
|
61
|
-
|
|
61
|
+
var INTERNAL_CLI_PLUGINS = {
|
|
62
62
|
"@modern-js/app-tools": "@modern-js/app-tools/cli",
|
|
63
63
|
"@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
|
|
64
64
|
"@modern-js/module-tools": "@modern-js/module-tools",
|
|
@@ -79,14 +79,14 @@ export var INTERNAL_CLI_PLUGINS = {
|
|
|
79
79
|
// legacy router (inner react-router-dom v5)
|
|
80
80
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
var SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
|
|
83
|
+
var SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
|
|
84
|
+
var SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
|
|
85
|
+
var SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
|
|
86
|
+
var SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
|
|
87
87
|
var _obj;
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
var INTERNAL_SERVER_PLUGINS = (_obj = {}, _define_property(_obj, SERVER_PLUGIN_BFF, "@modern-js/plugin-bff/server"), _define_property(_obj, SERVER_PLUGIN_EXPRESS, "@modern-js/plugin-express/server"), _define_property(_obj, SERVER_PLUGIN_KOA, "@modern-js/plugin-koa/server"), _define_property(_obj, SERVER_PLUGIN_SERVER, "@modern-js/plugin-server/server"), _define_property(_obj, SERVER_PLUGIN_POLYFILL, "@modern-js/plugin-polyfill/server"), _obj);
|
|
89
|
+
var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
90
90
|
allowNamespaces: true,
|
|
91
91
|
allExtensions: true,
|
|
92
92
|
allowDeclareFields: true,
|
|
@@ -96,3 +96,36 @@ export var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
|
96
96
|
isTSX: true
|
|
97
97
|
};
|
|
98
98
|
export * from "./chainId";
|
|
99
|
+
export {
|
|
100
|
+
API_DIR,
|
|
101
|
+
CONFIG_CACHE_DIR,
|
|
102
|
+
CONFIG_FILE_EXTENSIONS,
|
|
103
|
+
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
|
|
104
|
+
DEFAULT_DEV_HOST,
|
|
105
|
+
DEFAULT_SERVER_CONFIG,
|
|
106
|
+
ENTRY_NAME_PATTERN,
|
|
107
|
+
INTERNAL_APP_TOOLS_PLUGINS,
|
|
108
|
+
INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
|
109
|
+
INTERNAL_CLI_PLUGINS,
|
|
110
|
+
INTERNAL_DOC_TOOLS_PLUGINS,
|
|
111
|
+
INTERNAL_MODULE_TOOLS_PLUGINS,
|
|
112
|
+
INTERNAL_MONOREPO_TOOLS_PLUGINS,
|
|
113
|
+
INTERNAL_SERVER_PLUGINS,
|
|
114
|
+
LOADABLE_STATS_FILE,
|
|
115
|
+
LOADER_ROUTES_DIR,
|
|
116
|
+
MAIN_ENTRY_NAME,
|
|
117
|
+
NESTED_ROUTE_SPEC_FILE,
|
|
118
|
+
OUTPUT_CONFIG_FILE,
|
|
119
|
+
ROUTE_MANIFEST_FILE,
|
|
120
|
+
ROUTE_SPEC_FILE,
|
|
121
|
+
SERVER_BUNDLE_DIRECTORY,
|
|
122
|
+
SERVER_DIR,
|
|
123
|
+
SERVER_PLUGIN_BFF,
|
|
124
|
+
SERVER_PLUGIN_EXPRESS,
|
|
125
|
+
SERVER_PLUGIN_KOA,
|
|
126
|
+
SERVER_PLUGIN_POLYFILL,
|
|
127
|
+
SERVER_PLUGIN_SERVER,
|
|
128
|
+
SERVER_RENDER_FUNCTION_NAME,
|
|
129
|
+
SERVER_WORKER_BUNDLE_DIRECTORY,
|
|
130
|
+
SHARED_DIR
|
|
131
|
+
};
|
package/dist/esm/cli/ensure.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
|
|
2
|
+
var ensureAbsolutePath = function(base, filePath) {
|
|
3
3
|
return path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath);
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
var ensureArray = function(params) {
|
|
6
6
|
if (Array.isArray(params)) {
|
|
7
7
|
return params;
|
|
8
8
|
}
|
|
@@ -10,3 +10,7 @@ export var ensureArray = function(params) {
|
|
|
10
10
|
params
|
|
11
11
|
];
|
|
12
12
|
};
|
|
13
|
+
export {
|
|
14
|
+
ensureAbsolutePath,
|
|
15
|
+
ensureArray
|
|
16
|
+
};
|
package/dist/esm/cli/fs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { fs } from "../compiled";
|
|
4
|
-
|
|
4
|
+
var findExists = function(files) {
|
|
5
5
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
6
6
|
try {
|
|
7
7
|
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
@@ -26,7 +26,7 @@ export var findExists = function(files) {
|
|
|
26
26
|
}
|
|
27
27
|
return false;
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
var emptyDir = function() {
|
|
30
30
|
var _ref = _async_to_generator(function(dir) {
|
|
31
31
|
return _ts_generator(this, function(_state) {
|
|
32
32
|
switch (_state.label) {
|
|
@@ -59,3 +59,7 @@ export var emptyDir = function() {
|
|
|
59
59
|
return _ref.apply(this, arguments);
|
|
60
60
|
};
|
|
61
61
|
}();
|
|
62
|
+
export {
|
|
63
|
+
emptyDir,
|
|
64
|
+
findExists
|
|
65
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import { isPlainObject } from "../is";
|
|
3
|
-
|
|
3
|
+
var getEntryOptions = function(name, isMainEntry, baseOptions, optionsByEntries, packageName) {
|
|
4
4
|
if (optionsByEntries) {
|
|
5
5
|
var optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
|
|
6
6
|
if (optionsByEntry === void 0 && isMainEntry && packageName) {
|
|
@@ -14,3 +14,6 @@ export var getEntryOptions = function(name, isMainEntry, baseOptions, optionsByE
|
|
|
14
14
|
var getOptionsByEntryName = function(name, optionsByEntries) {
|
|
15
15
|
return optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : void 0;
|
|
16
16
|
};
|
|
17
|
+
export {
|
|
18
|
+
getEntryOptions
|
|
19
|
+
};
|