@modern-js/utils 2.64.1 → 2.64.3

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.
@@ -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 import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=17.0.0");
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.satisfies(import_compiled.semver.minVersion(deps.react), ">=18.0.0");
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
  });
@@ -18,7 +18,9 @@ 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
- isVersionAtLeast1819: () => isVersionAtLeast1819
21
+ isVersionAtLeast18: () => isVersionAtLeast18,
22
+ isVersionAtLeast1819: () => isVersionAtLeast1819,
23
+ isVersionAtLeast22: () => isVersionAtLeast22
22
24
  });
23
25
  module.exports = __toCommonJS(version_exports);
24
26
  function isVersionAtLeast1819() {
@@ -26,7 +28,19 @@ function isVersionAtLeast1819() {
26
28
  const versionArr = nodeVersion.split(".").map(Number);
27
29
  return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
28
30
  }
31
+ function isVersionAtLeast18() {
32
+ const nodeVersion = process.versions.node;
33
+ const versionArr = nodeVersion.split(".").map(Number);
34
+ return versionArr[0] >= 18;
35
+ }
36
+ function isVersionAtLeast22() {
37
+ const nodeVersion = process.versions.node;
38
+ const versionArr = nodeVersion.split(".").map(Number);
39
+ return versionArr[0] >= 22;
40
+ }
29
41
  // Annotate the CommonJS export names for ESM import in node:
30
42
  0 && (module.exports = {
31
- isVersionAtLeast1819
43
+ isVersionAtLeast18,
44
+ isVersionAtLeast1819,
45
+ isVersionAtLeast22
32
46
  });
@@ -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 semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
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.satisfies(semver.minVersion(deps.react), ">=18.0.0");
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
  };
@@ -3,6 +3,18 @@ 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
+ }
11
+ function isVersionAtLeast22() {
12
+ var nodeVersion = process.versions.node;
13
+ var versionArr = nodeVersion.split(".").map(Number);
14
+ return versionArr[0] >= 22;
15
+ }
6
16
  export {
7
- isVersionAtLeast1819
17
+ isVersionAtLeast18,
18
+ isVersionAtLeast1819,
19
+ isVersionAtLeast22
8
20
  };
@@ -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 semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
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.satisfies(semver.minVersion(deps.react), ">=18.0.0");
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,18 @@ 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
+ }
11
+ function isVersionAtLeast22() {
12
+ const nodeVersion = process.versions.node;
13
+ const versionArr = nodeVersion.split(".").map(Number);
14
+ return versionArr[0] >= 22;
15
+ }
6
16
  export {
7
- isVersionAtLeast1819
17
+ isVersionAtLeast18,
18
+ isVersionAtLeast1819,
19
+ isVersionAtLeast22
8
20
  };
@@ -9,6 +9,7 @@ interface EntryPoint {
9
9
  */
10
10
  export declare const isSSR: (config: any) => boolean;
11
11
  export declare const isUseSSRBundle: (config: any) => boolean;
12
+ export declare const isUseRsc: (config: any) => boolean;
12
13
  /**
13
14
  * Is Worker project
14
15
  *
@@ -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
  */
@@ -1 +1,3 @@
1
1
  export declare function isVersionAtLeast1819(): boolean;
2
+ export declare function isVersionAtLeast18(): boolean;
3
+ export declare function isVersionAtLeast22(): boolean;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.64.1",
18
+ "version": "2.64.3",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -161,10 +161,10 @@
161
161
  "@types/node": "^14",
162
162
  "jest": "^29",
163
163
  "typescript": "^5",
164
- "webpack": "^5.97.1",
165
- "@scripts/build": "2.64.1",
166
- "@scripts/jest-config": "2.64.1",
167
- "@modern-js/types": "2.64.1"
164
+ "webpack": "^5.98.0",
165
+ "@modern-js/types": "2.64.3",
166
+ "@scripts/build": "2.64.3",
167
+ "@scripts/jest-config": "2.64.3"
168
168
  },
169
169
  "sideEffects": false,
170
170
  "scripts": {