@modern-js/utils 2.64.1 → 2.64.2
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/is/config.js +6 -0
- package/dist/cjs/cli/is/project.js +7 -2
- package/dist/cjs/cli/version.js +7 -0
- package/dist/esm/cli/is/config.js +5 -0
- package/dist/esm/cli/is/project.js +6 -2
- package/dist/esm/cli/version.js +6 -0
- package/dist/esm-node/cli/is/config.js +5 -0
- package/dist/esm-node/cli/is/project.js +6 -2
- package/dist/esm-node/cli/version.js +6 -0
- package/dist/types/cli/is/config.d.ts +1 -0
- package/dist/types/cli/is/project.d.ts +1 -0
- package/dist/types/cli/version.d.ts +1 -0
- package/package.json +4 -4
@@ -23,6 +23,7 @@ __export(config_exports, {
|
|
23
23
|
isSSR: () => isSSR,
|
24
24
|
isServiceWorker: () => isServiceWorker,
|
25
25
|
isSingleEntry: () => isSingleEntry,
|
26
|
+
isUseRsc: () => isUseRsc,
|
26
27
|
isUseSSRBundle: () => isUseSSRBundle
|
27
28
|
});
|
28
29
|
module.exports = __toCommonJS(config_exports);
|
@@ -49,6 +50,10 @@ const isUseSSRBundle = (config) => {
|
|
49
50
|
}
|
50
51
|
return isSSR(config);
|
51
52
|
};
|
53
|
+
const isUseRsc = (config) => {
|
54
|
+
var _config_server;
|
55
|
+
return config === null || config === void 0 ? void 0 : (_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.rsc;
|
56
|
+
};
|
52
57
|
const isServiceWorker = (config) => {
|
53
58
|
var _deploy_worker;
|
54
59
|
const { output, deploy } = config;
|
@@ -75,5 +80,6 @@ const isSingleEntry = (entrypoints, mainEntryName = import_constants.MAIN_ENTRY_
|
|
75
80
|
isSSR,
|
76
81
|
isServiceWorker,
|
77
82
|
isSingleEntry,
|
83
|
+
isUseRsc,
|
78
84
|
isUseSSRBundle
|
79
85
|
});
|
@@ -35,6 +35,7 @@ __export(project_exports, {
|
|
35
35
|
isReact18: () => isReact18,
|
36
36
|
isSupportAutomaticJsx: () => isSupportAutomaticJsx,
|
37
37
|
isTypescript: () => isTypescript,
|
38
|
+
isVersionBeyond17: () => isVersionBeyond17,
|
38
39
|
isWebOnly: () => isWebOnly
|
39
40
|
});
|
40
41
|
module.exports = __toCommonJS(project_exports);
|
@@ -78,6 +79,9 @@ const isWebOnly = async () => {
|
|
78
79
|
const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
|
79
80
|
return Boolean(options["web-only"]);
|
80
81
|
};
|
82
|
+
const isVersionBeyond17 = (version) => {
|
83
|
+
return import_compiled.semver.gte(import_compiled.semver.minVersion(version), "17.0.0");
|
84
|
+
};
|
81
85
|
const isBeyondReact17 = (cwd) => {
|
82
86
|
const pkgPath = import_pkg_up.default.sync({
|
83
87
|
cwd
|
@@ -93,7 +97,7 @@ const isBeyondReact17 = (cwd) => {
|
|
93
97
|
if (typeof deps.react !== "string") {
|
94
98
|
return false;
|
95
99
|
}
|
96
|
-
return
|
100
|
+
return isVersionBeyond17(deps.react);
|
97
101
|
};
|
98
102
|
const isSupportAutomaticJsx = (cwd) => {
|
99
103
|
const pkgPath = import_pkg_up.default.sync({
|
@@ -125,7 +129,7 @@ const isReact18 = (cwd = process.cwd()) => {
|
|
125
129
|
if (typeof deps.react !== "string") {
|
126
130
|
return false;
|
127
131
|
}
|
128
|
-
return import_compiled.semver.
|
132
|
+
return import_compiled.semver.gte(import_compiled.semver.minVersion(deps.react), "18.0.0");
|
129
133
|
};
|
130
134
|
const isTypescript = (root) => import_compiled.fs.existsSync(import_path.default.resolve(root, "./tsconfig.json"));
|
131
135
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -137,5 +141,6 @@ const isTypescript = (root) => import_compiled.fs.existsSync(import_path.default
|
|
137
141
|
isReact18,
|
138
142
|
isSupportAutomaticJsx,
|
139
143
|
isTypescript,
|
144
|
+
isVersionBeyond17,
|
140
145
|
isWebOnly
|
141
146
|
});
|
package/dist/cjs/cli/version.js
CHANGED
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
19
|
var version_exports = {};
|
20
20
|
__export(version_exports, {
|
21
|
+
isVersionAtLeast18: () => isVersionAtLeast18,
|
21
22
|
isVersionAtLeast1819: () => isVersionAtLeast1819
|
22
23
|
});
|
23
24
|
module.exports = __toCommonJS(version_exports);
|
@@ -26,7 +27,13 @@ function isVersionAtLeast1819() {
|
|
26
27
|
const versionArr = nodeVersion.split(".").map(Number);
|
27
28
|
return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
|
28
29
|
}
|
30
|
+
function isVersionAtLeast18() {
|
31
|
+
const nodeVersion = process.versions.node;
|
32
|
+
const versionArr = nodeVersion.split(".").map(Number);
|
33
|
+
return versionArr[0] >= 18;
|
34
|
+
}
|
29
35
|
// Annotate the CommonJS export names for ESM import in node:
|
30
36
|
0 && (module.exports = {
|
37
|
+
isVersionAtLeast18,
|
31
38
|
isVersionAtLeast1819
|
32
39
|
});
|
@@ -38,6 +38,10 @@ var isUseSSRBundle = function(config) {
|
|
38
38
|
}
|
39
39
|
return isSSR(config);
|
40
40
|
};
|
41
|
+
var isUseRsc = function(config) {
|
42
|
+
var _config_server;
|
43
|
+
return config === null || config === void 0 ? void 0 : (_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.rsc;
|
44
|
+
};
|
41
45
|
var isServiceWorker = function(config) {
|
42
46
|
var _deploy_worker;
|
43
47
|
var output = config.output, deploy = config.deploy;
|
@@ -66,5 +70,6 @@ export {
|
|
66
70
|
isSSR,
|
67
71
|
isServiceWorker,
|
68
72
|
isSingleEntry,
|
73
|
+
isUseRsc,
|
69
74
|
isUseSSRBundle
|
70
75
|
};
|
@@ -79,6 +79,9 @@ var isWebOnly = function() {
|
|
79
79
|
return _ref.apply(this, arguments);
|
80
80
|
};
|
81
81
|
}();
|
82
|
+
var isVersionBeyond17 = function(version) {
|
83
|
+
return semver.gte(semver.minVersion(version), "17.0.0");
|
84
|
+
};
|
82
85
|
var isBeyondReact17 = function(cwd) {
|
83
86
|
var pkgPath = pkgUp.sync({
|
84
87
|
cwd
|
@@ -91,7 +94,7 @@ var isBeyondReact17 = function(cwd) {
|
|
91
94
|
if (typeof deps.react !== "string") {
|
92
95
|
return false;
|
93
96
|
}
|
94
|
-
return
|
97
|
+
return isVersionBeyond17(deps.react);
|
95
98
|
};
|
96
99
|
var isSupportAutomaticJsx = function(cwd) {
|
97
100
|
var pkgPath = pkgUp.sync({
|
@@ -118,7 +121,7 @@ var isReact18 = function() {
|
|
118
121
|
if (typeof deps.react !== "string") {
|
119
122
|
return false;
|
120
123
|
}
|
121
|
-
return semver.
|
124
|
+
return semver.gte(semver.minVersion(deps.react), "18.0.0");
|
122
125
|
};
|
123
126
|
var isTypescript = function(root) {
|
124
127
|
return fs.existsSync(path.resolve(root, "./tsconfig.json"));
|
@@ -131,5 +134,6 @@ export {
|
|
131
134
|
isReact18,
|
132
135
|
isSupportAutomaticJsx,
|
133
136
|
isTypescript,
|
137
|
+
isVersionBeyond17,
|
134
138
|
isWebOnly
|
135
139
|
};
|
package/dist/esm/cli/version.js
CHANGED
@@ -3,6 +3,12 @@ function isVersionAtLeast1819() {
|
|
3
3
|
var versionArr = nodeVersion.split(".").map(Number);
|
4
4
|
return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
|
5
5
|
}
|
6
|
+
function isVersionAtLeast18() {
|
7
|
+
var nodeVersion = process.versions.node;
|
8
|
+
var versionArr = nodeVersion.split(".").map(Number);
|
9
|
+
return versionArr[0] >= 18;
|
10
|
+
}
|
6
11
|
export {
|
12
|
+
isVersionAtLeast18,
|
7
13
|
isVersionAtLeast1819
|
8
14
|
};
|
@@ -21,6 +21,10 @@ const isUseSSRBundle = (config) => {
|
|
21
21
|
}
|
22
22
|
return isSSR(config);
|
23
23
|
};
|
24
|
+
const isUseRsc = (config) => {
|
25
|
+
var _config_server;
|
26
|
+
return config === null || config === void 0 ? void 0 : (_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.rsc;
|
27
|
+
};
|
24
28
|
const isServiceWorker = (config) => {
|
25
29
|
var _deploy_worker;
|
26
30
|
const { output, deploy } = config;
|
@@ -46,5 +50,6 @@ export {
|
|
46
50
|
isSSR,
|
47
51
|
isServiceWorker,
|
48
52
|
isSingleEntry,
|
53
|
+
isUseRsc,
|
49
54
|
isUseSSRBundle
|
50
55
|
};
|
@@ -38,6 +38,9 @@ const isWebOnly = async () => {
|
|
38
38
|
const options = minimist(getArgv());
|
39
39
|
return Boolean(options["web-only"]);
|
40
40
|
};
|
41
|
+
const isVersionBeyond17 = (version) => {
|
42
|
+
return semver.gte(semver.minVersion(version), "17.0.0");
|
43
|
+
};
|
41
44
|
const isBeyondReact17 = (cwd) => {
|
42
45
|
const pkgPath = pkgUp.sync({
|
43
46
|
cwd
|
@@ -53,7 +56,7 @@ const isBeyondReact17 = (cwd) => {
|
|
53
56
|
if (typeof deps.react !== "string") {
|
54
57
|
return false;
|
55
58
|
}
|
56
|
-
return
|
59
|
+
return isVersionBeyond17(deps.react);
|
57
60
|
};
|
58
61
|
const isSupportAutomaticJsx = (cwd) => {
|
59
62
|
const pkgPath = pkgUp.sync({
|
@@ -85,7 +88,7 @@ const isReact18 = (cwd = process.cwd()) => {
|
|
85
88
|
if (typeof deps.react !== "string") {
|
86
89
|
return false;
|
87
90
|
}
|
88
|
-
return semver.
|
91
|
+
return semver.gte(semver.minVersion(deps.react), "18.0.0");
|
89
92
|
};
|
90
93
|
const isTypescript = (root) => fs.existsSync(path.resolve(root, "./tsconfig.json"));
|
91
94
|
export {
|
@@ -96,5 +99,6 @@ export {
|
|
96
99
|
isReact18,
|
97
100
|
isSupportAutomaticJsx,
|
98
101
|
isTypescript,
|
102
|
+
isVersionBeyond17,
|
99
103
|
isWebOnly
|
100
104
|
};
|
@@ -3,6 +3,12 @@ function isVersionAtLeast1819() {
|
|
3
3
|
const versionArr = nodeVersion.split(".").map(Number);
|
4
4
|
return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
|
5
5
|
}
|
6
|
+
function isVersionAtLeast18() {
|
7
|
+
const nodeVersion = process.versions.node;
|
8
|
+
const versionArr = nodeVersion.split(".").map(Number);
|
9
|
+
return versionArr[0] >= 18;
|
10
|
+
}
|
6
11
|
export {
|
12
|
+
isVersionAtLeast18,
|
7
13
|
isVersionAtLeast1819
|
8
14
|
};
|
@@ -22,6 +22,7 @@ export declare const isPackageInstalled: (name: string, resolvePaths: string | s
|
|
22
22
|
*/
|
23
23
|
export declare const isApiOnly: (appDirectory: string, entryDir?: string, apiDir?: string) => Promise<boolean>;
|
24
24
|
export declare const isWebOnly: () => Promise<boolean>;
|
25
|
+
export declare const isVersionBeyond17: (version: string) => boolean;
|
25
26
|
/**
|
26
27
|
* @deprecated Use {@link isSupportAutomaticJsx} to check if the project supports automatic JSX instead.
|
27
28
|
*/
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.64.
|
18
|
+
"version": "2.64.2",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -162,9 +162,9 @@
|
|
162
162
|
"jest": "^29",
|
163
163
|
"typescript": "^5",
|
164
164
|
"webpack": "^5.97.1",
|
165
|
-
"@
|
166
|
-
"@scripts/
|
167
|
-
"@
|
165
|
+
"@modern-js/types": "2.64.2",
|
166
|
+
"@scripts/build": "2.64.2",
|
167
|
+
"@scripts/jest-config": "2.64.2"
|
168
168
|
},
|
169
169
|
"sideEffects": false,
|
170
170
|
"scripts": {
|