@modern-js/utils 0.0.0-nightly-20231006160559 → 0.0.0-nightly-20231008160538
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli/alias.js +2 -20
- package/dist/cjs/cli/is/env.js +3 -6
- package/dist/cjs/cli/is/index.js +0 -2
- package/dist/cjs/cli/monorepo.js +0 -14
- package/dist/cjs/universal/pluginDagSort.js +1 -1
- package/dist/esm/cli/alias.js +1 -19
- package/dist/esm/cli/is/env.js +3 -7
- package/dist/esm/cli/is/index.js +0 -1
- package/dist/esm/cli/monorepo.js +0 -11
- package/dist/esm/universal/pluginDagSort.js +1 -1
- package/dist/esm-node/cli/alias.js +1 -18
- package/dist/esm-node/cli/is/env.js +2 -4
- package/dist/esm-node/cli/is/index.js +0 -1
- package/dist/esm-node/cli/monorepo.js +0 -13
- package/dist/esm-node/universal/pluginDagSort.js +1 -1
- 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/monorepo.d.ts +0 -1
- package/package.json +4 -4
- package/dist/cjs/cli/is/platform.js +0 -31
- package/dist/esm/cli/is/platform.js +0 -10
- package/dist/esm-node/cli/is/platform.js +0 -6
- package/dist/types/cli/is/platform.d.ts +0 -2
package/dist/cjs/cli/alias.js
CHANGED
@@ -30,30 +30,13 @@ var alias_exports = {};
|
|
30
30
|
__export(alias_exports, {
|
31
31
|
getAliasConfig: () => getAliasConfig,
|
32
32
|
getUserAlias: () => getUserAlias,
|
33
|
-
mergeAlias: () => mergeAlias
|
34
|
-
validAlias: () => validAlias
|
33
|
+
mergeAlias: () => mergeAlias
|
35
34
|
});
|
36
35
|
module.exports = __toCommonJS(alias_exports);
|
37
36
|
var import_fs = __toESM(require("fs"));
|
38
37
|
var import_path = __toESM(require("path"));
|
39
|
-
var import_compiled = require("../compiled");
|
40
38
|
var import_get = require("./get");
|
41
39
|
var import_applyOptionsChain = require("./applyOptionsChain");
|
42
|
-
const validAlias = (modernConfig, { tsconfigPath }) => {
|
43
|
-
const { source: { alias } } = modernConfig;
|
44
|
-
if (!alias) {
|
45
|
-
return null;
|
46
|
-
}
|
47
|
-
const isTsProject = import_fs.default.existsSync(tsconfigPath);
|
48
|
-
if (!isTsProject) {
|
49
|
-
return null;
|
50
|
-
}
|
51
|
-
const userAlias = getUserAlias(alias);
|
52
|
-
if (Object.keys(userAlias).length > 0) {
|
53
|
-
return import_compiled.chalk.red('Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript');
|
54
|
-
}
|
55
|
-
return null;
|
56
|
-
};
|
57
40
|
const mergeAlias = (alias) => (0, import_applyOptionsChain.applyOptionsChain)({}, alias);
|
58
41
|
const getAliasConfig = (aliasOption, option) => {
|
59
42
|
var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
|
@@ -89,6 +72,5 @@ const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
|
|
89
72
|
0 && (module.exports = {
|
90
73
|
getAliasConfig,
|
91
74
|
getUserAlias,
|
92
|
-
mergeAlias
|
93
|
-
validAlias
|
75
|
+
mergeAlias
|
94
76
|
});
|
package/dist/cjs/cli/is/env.js
CHANGED
@@ -19,10 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
19
19
|
var env_exports = {};
|
20
20
|
__export(env_exports, {
|
21
21
|
getNodeEnv: () => getNodeEnv,
|
22
|
+
isBrowser: () => isBrowser,
|
22
23
|
isDev: () => isDev,
|
23
|
-
isFastRefresh: () => isFastRefresh,
|
24
24
|
isProd: () => isProd,
|
25
|
-
isProdProfile: () => isProdProfile,
|
26
25
|
isTest: () => isTest
|
27
26
|
});
|
28
27
|
module.exports = __toCommonJS(env_exports);
|
@@ -30,14 +29,12 @@ const getNodeEnv = () => process.env.NODE_ENV || "development";
|
|
30
29
|
const isDev = () => getNodeEnv() === "development";
|
31
30
|
const isProd = () => getNodeEnv() === "production";
|
32
31
|
const isTest = () => getNodeEnv() === "test";
|
33
|
-
const
|
34
|
-
const isFastRefresh = () => isDev() && process.env.FAST_REFRESH !== "false";
|
32
|
+
const isBrowser = () => typeof window !== "undefined";
|
35
33
|
// Annotate the CommonJS export names for ESM import in node:
|
36
34
|
0 && (module.exports = {
|
37
35
|
getNodeEnv,
|
36
|
+
isBrowser,
|
38
37
|
isDev,
|
39
|
-
isFastRefresh,
|
40
38
|
isProd,
|
41
|
-
isProdProfile,
|
42
39
|
isTest
|
43
40
|
});
|
package/dist/cjs/cli/is/index.js
CHANGED
@@ -16,14 +16,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
16
16
|
var is_exports = {};
|
17
17
|
module.exports = __toCommonJS(is_exports);
|
18
18
|
__reExport(is_exports, require("./env"), module.exports);
|
19
|
-
__reExport(is_exports, require("./platform"), module.exports);
|
20
19
|
__reExport(is_exports, require("./type"), module.exports);
|
21
20
|
__reExport(is_exports, require("./config"), module.exports);
|
22
21
|
__reExport(is_exports, require("./project"), module.exports);
|
23
22
|
// Annotate the CommonJS export names for ESM import in node:
|
24
23
|
0 && (module.exports = {
|
25
24
|
...require("./env"),
|
26
|
-
...require("./platform"),
|
27
25
|
...require("./type"),
|
28
26
|
...require("./config"),
|
29
27
|
...require("./project")
|
package/dist/cjs/cli/monorepo.js
CHANGED
@@ -31,7 +31,6 @@ __export(monorepo_exports, {
|
|
31
31
|
findMonorepoRoot: () => findMonorepoRoot,
|
32
32
|
getMonorepoPackages: () => getMonorepoPackages,
|
33
33
|
isLerna: () => isLerna,
|
34
|
-
isModernjsMonorepo: () => isModernjsMonorepo,
|
35
34
|
isMonorepo: () => isMonorepo,
|
36
35
|
isPnpmWorkspaces: () => isPnpmWorkspaces,
|
37
36
|
isYarnWorkspaces: () => isYarnWorkspaces
|
@@ -58,18 +57,6 @@ const isYarnWorkspaces = (root) => {
|
|
58
57
|
};
|
59
58
|
const isPnpmWorkspaces = (root) => import_fs.default.existsSync(import_path.default.join(root, WORKSPACE_FILES.PNPM));
|
60
59
|
const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
61
|
-
const isModernjsMonorepo = (root) => {
|
62
|
-
const pkgJsonPath = import_path.default.join(root, "package.json");
|
63
|
-
if (!import_fs.default.existsSync(pkgJsonPath)) {
|
64
|
-
return false;
|
65
|
-
}
|
66
|
-
const json = JSON.parse(import_fs.default.readFileSync(pkgJsonPath, "utf8"));
|
67
|
-
const deps = {
|
68
|
-
...json.dependencies || {},
|
69
|
-
...json.devDependencies || {}
|
70
|
-
};
|
71
|
-
return Boolean(deps["@modern-js/monorepo-tools"]);
|
72
|
-
};
|
73
60
|
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
74
61
|
let inMonorepo = false;
|
75
62
|
for (let depth = 0; depth < maxDepth; depth++) {
|
@@ -112,7 +99,6 @@ const getMonorepoPackages = (root) => {
|
|
112
99
|
findMonorepoRoot,
|
113
100
|
getMonorepoPackages,
|
114
101
|
isLerna,
|
115
|
-
isModernjsMonorepo,
|
116
102
|
isMonorepo,
|
117
103
|
isPnpmWorkspaces,
|
118
104
|
isYarnWorkspaces
|
@@ -67,7 +67,7 @@ const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post")
|
|
67
67
|
restInRingPoints[l[0]] = true;
|
68
68
|
restInRingPoints[l[1]] = true;
|
69
69
|
});
|
70
|
-
throw new Error(`plugins
|
70
|
+
throw new Error(`plugins dependencies has loop: ${Object.keys(restInRingPoints).join(",")}`);
|
71
71
|
}
|
72
72
|
return sortedPoint;
|
73
73
|
};
|
package/dist/esm/cli/alias.js
CHANGED
@@ -1,25 +1,8 @@
|
|
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
|
-
var validAlias = function(modernConfig, param) {
|
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
6
|
var mergeAlias = function(alias) {
|
24
7
|
return applyOptionsChain({}, alias);
|
25
8
|
};
|
@@ -56,6 +39,5 @@ var getUserAlias = function() {
|
|
56
39
|
export {
|
57
40
|
getAliasConfig,
|
58
41
|
getUserAlias,
|
59
|
-
mergeAlias
|
60
|
-
validAlias
|
42
|
+
mergeAlias
|
61
43
|
};
|
package/dist/esm/cli/is/env.js
CHANGED
@@ -10,17 +10,13 @@ var isProd = function() {
|
|
10
10
|
var isTest = function() {
|
11
11
|
return getNodeEnv() === "test";
|
12
12
|
};
|
13
|
-
var
|
14
|
-
return
|
15
|
-
};
|
16
|
-
var isFastRefresh = function() {
|
17
|
-
return isDev() && process.env.FAST_REFRESH !== "false";
|
13
|
+
var isBrowser = function() {
|
14
|
+
return typeof window !== "undefined";
|
18
15
|
};
|
19
16
|
export {
|
20
17
|
getNodeEnv,
|
18
|
+
isBrowser,
|
21
19
|
isDev,
|
22
|
-
isFastRefresh,
|
23
20
|
isProd,
|
24
|
-
isProdProfile,
|
25
21
|
isTest
|
26
22
|
};
|
package/dist/esm/cli/is/index.js
CHANGED
package/dist/esm/cli/monorepo.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
2
1
|
import fs from "fs";
|
3
2
|
import path from "path";
|
4
3
|
import { glob, yaml } from "../compiled";
|
@@ -26,15 +25,6 @@ var isPnpmWorkspaces = function(root) {
|
|
26
25
|
var isMonorepo = function(root) {
|
27
26
|
return isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
28
27
|
};
|
29
|
-
var isModernjsMonorepo = function(root) {
|
30
|
-
var pkgJsonPath = path.join(root, "package.json");
|
31
|
-
if (!fs.existsSync(pkgJsonPath)) {
|
32
|
-
return false;
|
33
|
-
}
|
34
|
-
var json = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
35
|
-
var deps = _object_spread({}, json.dependencies || {}, json.devDependencies || {});
|
36
|
-
return Boolean(deps["@modern-js/monorepo-tools"]);
|
37
|
-
};
|
38
28
|
var findMonorepoRoot = function(appDirectory) {
|
39
29
|
var maxDepth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : PACKAGE_MAX_DEPTH;
|
40
30
|
var inMonorepo = false;
|
@@ -85,7 +75,6 @@ export {
|
|
85
75
|
findMonorepoRoot,
|
86
76
|
getMonorepoPackages,
|
87
77
|
isLerna,
|
88
|
-
isModernjsMonorepo,
|
89
78
|
isMonorepo,
|
90
79
|
isPnpmWorkspaces,
|
91
80
|
isYarnWorkspaces
|
@@ -67,7 +67,7 @@ var pluginDagSort = function(plugins) {
|
|
67
67
|
restInRingPoints[l[0]] = true;
|
68
68
|
restInRingPoints[l[1]] = true;
|
69
69
|
});
|
70
|
-
throw new Error("plugins
|
70
|
+
throw new Error("plugins dependencies has loop: ".concat(Object.keys(restInRingPoints).join(",")));
|
71
71
|
}
|
72
72
|
return sortedPoint;
|
73
73
|
};
|
@@ -1,23 +1,7 @@
|
|
1
1
|
import fs from "fs";
|
2
2
|
import path from "path";
|
3
|
-
import { chalk } from "../compiled";
|
4
3
|
import { readTsConfigByFile } from "./get";
|
5
4
|
import { applyOptionsChain } from "./applyOptionsChain";
|
6
|
-
const validAlias = (modernConfig, { tsconfigPath }) => {
|
7
|
-
const { source: { alias } } = modernConfig;
|
8
|
-
if (!alias) {
|
9
|
-
return null;
|
10
|
-
}
|
11
|
-
const isTsProject = fs.existsSync(tsconfigPath);
|
12
|
-
if (!isTsProject) {
|
13
|
-
return null;
|
14
|
-
}
|
15
|
-
const userAlias = getUserAlias(alias);
|
16
|
-
if (Object.keys(userAlias).length > 0) {
|
17
|
-
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');
|
18
|
-
}
|
19
|
-
return null;
|
20
|
-
};
|
21
5
|
const mergeAlias = (alias) => applyOptionsChain({}, alias);
|
22
6
|
const getAliasConfig = (aliasOption, option) => {
|
23
7
|
var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
|
@@ -52,6 +36,5 @@ const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
|
|
52
36
|
export {
|
53
37
|
getAliasConfig,
|
54
38
|
getUserAlias,
|
55
|
-
mergeAlias
|
56
|
-
validAlias
|
39
|
+
mergeAlias
|
57
40
|
};
|
@@ -2,13 +2,11 @@ const getNodeEnv = () => process.env.NODE_ENV || "development";
|
|
2
2
|
const isDev = () => getNodeEnv() === "development";
|
3
3
|
const isProd = () => getNodeEnv() === "production";
|
4
4
|
const isTest = () => getNodeEnv() === "test";
|
5
|
-
const
|
6
|
-
const isFastRefresh = () => isDev() && process.env.FAST_REFRESH !== "false";
|
5
|
+
const isBrowser = () => typeof window !== "undefined";
|
7
6
|
export {
|
8
7
|
getNodeEnv,
|
8
|
+
isBrowser,
|
9
9
|
isDev,
|
10
|
-
isFastRefresh,
|
11
10
|
isProd,
|
12
|
-
isProdProfile,
|
13
11
|
isTest
|
14
12
|
};
|
@@ -19,18 +19,6 @@ const isYarnWorkspaces = (root) => {
|
|
19
19
|
};
|
20
20
|
const isPnpmWorkspaces = (root) => fs.existsSync(path.join(root, WORKSPACE_FILES.PNPM));
|
21
21
|
const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
22
|
-
const isModernjsMonorepo = (root) => {
|
23
|
-
const pkgJsonPath = path.join(root, "package.json");
|
24
|
-
if (!fs.existsSync(pkgJsonPath)) {
|
25
|
-
return false;
|
26
|
-
}
|
27
|
-
const json = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
28
|
-
const deps = {
|
29
|
-
...json.dependencies || {},
|
30
|
-
...json.devDependencies || {}
|
31
|
-
};
|
32
|
-
return Boolean(deps["@modern-js/monorepo-tools"]);
|
33
|
-
};
|
34
22
|
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
35
23
|
let inMonorepo = false;
|
36
24
|
for (let depth = 0; depth < maxDepth; depth++) {
|
@@ -72,7 +60,6 @@ export {
|
|
72
60
|
findMonorepoRoot,
|
73
61
|
getMonorepoPackages,
|
74
62
|
isLerna,
|
75
|
-
isModernjsMonorepo,
|
76
63
|
isMonorepo,
|
77
64
|
isPnpmWorkspaces,
|
78
65
|
isYarnWorkspaces
|
@@ -44,7 +44,7 @@ const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post")
|
|
44
44
|
restInRingPoints[l[0]] = true;
|
45
45
|
restInRingPoints[l[1]] = true;
|
46
46
|
});
|
47
|
-
throw new Error(`plugins
|
47
|
+
throw new Error(`plugins dependencies has loop: ${Object.keys(restInRingPoints).join(",")}`);
|
48
48
|
}
|
49
49
|
return sortedPoint;
|
50
50
|
};
|
@@ -11,11 +11,6 @@ interface IAliasConfig {
|
|
11
11
|
isTsPath?: boolean;
|
12
12
|
isTsProject?: boolean;
|
13
13
|
}
|
14
|
-
export declare const validAlias: <T extends NormalizedConfig>(modernConfig: T, {
|
15
|
-
tsconfigPath
|
16
|
-
}: {
|
17
|
-
tsconfigPath: string;
|
18
|
-
}) => string | null;
|
19
14
|
export declare const mergeAlias: (alias: NormalizedConfig['source']['alias']) => Alias;
|
20
15
|
export declare const getAliasConfig: (aliasOption: NormalizedConfig['source']['alias'], option: {
|
21
16
|
appDirectory: string;
|
@@ -5,5 +5,4 @@ export declare const getNodeEnv: () => string;
|
|
5
5
|
export declare const isDev: () => boolean;
|
6
6
|
export declare const isProd: () => boolean;
|
7
7
|
export declare const isTest: () => boolean;
|
8
|
-
export declare const
|
9
|
-
export declare const isFastRefresh: () => boolean;
|
8
|
+
export declare const isBrowser: () => boolean;
|
@@ -3,7 +3,6 @@ export declare const isLerna: (root: string) => boolean;
|
|
3
3
|
export declare const isYarnWorkspaces: (root: string) => boolean;
|
4
4
|
export declare const isPnpmWorkspaces: (root: string) => boolean;
|
5
5
|
export declare const isMonorepo: (root: string) => boolean;
|
6
|
-
export declare const isModernjsMonorepo: (root: string) => boolean;
|
7
6
|
export declare const findMonorepoRoot: (appDirectory: string, maxDepth?: number) => string | undefined;
|
8
7
|
export declare const getMonorepoPackages: (root: string) => {
|
9
8
|
name: string;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "0.0.0-nightly-
|
18
|
+
"version": "0.0.0-nightly-20231008160538",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -169,9 +169,9 @@
|
|
169
169
|
"jest": "^29",
|
170
170
|
"typescript": "^5",
|
171
171
|
"webpack": "^5.88.1",
|
172
|
-
"@modern-js/types": "0.0.0-nightly-
|
173
|
-
"@scripts/build": "0.0.0-nightly-
|
174
|
-
"@scripts/jest-config": "0.0.0-nightly-
|
172
|
+
"@modern-js/types": "0.0.0-nightly-20231008160538",
|
173
|
+
"@scripts/build": "0.0.0-nightly-20231008160538",
|
174
|
+
"@scripts/jest-config": "0.0.0-nightly-20231008160538"
|
175
175
|
},
|
176
176
|
"sideEffects": false,
|
177
177
|
"scripts": {
|
@@ -1,31 +0,0 @@
|
|
1
|
-
"use strict";
|
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 });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var platform_exports = {};
|
20
|
-
__export(platform_exports, {
|
21
|
-
isBrowser: () => isBrowser,
|
22
|
-
isNodeJS: () => isNodeJS
|
23
|
-
});
|
24
|
-
module.exports = __toCommonJS(platform_exports);
|
25
|
-
const isNodeJS = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null && process.versions.electron == null;
|
26
|
-
const isBrowser = () => typeof window !== "undefined";
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
28
|
-
0 && (module.exports = {
|
29
|
-
isBrowser,
|
30
|
-
isNodeJS
|
31
|
-
});
|
@@ -1,10 +0,0 @@
|
|
1
|
-
var isNodeJS = function() {
|
2
|
-
return typeof process !== "undefined" && process.versions != null && process.versions.node != null && process.versions.electron == null;
|
3
|
-
};
|
4
|
-
var isBrowser = function() {
|
5
|
-
return typeof window !== "undefined";
|
6
|
-
};
|
7
|
-
export {
|
8
|
-
isBrowser,
|
9
|
-
isNodeJS
|
10
|
-
};
|