@rspack/cli 2.2.9 → 2.3.0-beta.1
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/index.d.ts +3 -4
- package/dist/index.js +26 -28
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -82,10 +82,9 @@ declare class CAC extends EventTarget {
|
|
|
82
82
|
/**
|
|
83
83
|
* Parse argv
|
|
84
84
|
*/
|
|
85
|
-
parse(argv?: string[], {
|
|
86
|
-
run
|
|
87
|
-
|
|
88
|
-
/** Whether to run the action for matched command */run?: boolean | undefined;
|
|
85
|
+
parse(argv?: string[], { run }?: {
|
|
86
|
+
/** Whether to run the action for matched command */
|
|
87
|
+
run?: boolean | undefined;
|
|
89
88
|
}): ParsedArgv;
|
|
90
89
|
private mri;
|
|
91
90
|
runMatchedCommand(): any;
|
package/dist/index.js
CHANGED
|
@@ -113,7 +113,7 @@ function findAllBrackets(v) {
|
|
|
113
113
|
}
|
|
114
114
|
function getMriOptions(options) {
|
|
115
115
|
const result = {
|
|
116
|
-
alias:
|
|
116
|
+
alias: Object.create(null),
|
|
117
117
|
boolean: []
|
|
118
118
|
};
|
|
119
119
|
for (const [index, option] of options.entries()){
|
|
@@ -125,7 +125,7 @@ function getMriOptions(options) {
|
|
|
125
125
|
return result;
|
|
126
126
|
}
|
|
127
127
|
function findLongest(arr) {
|
|
128
|
-
return arr.sort((a, b)=>
|
|
128
|
+
return arr.sort((a, b)=>b.length - a.length)[0];
|
|
129
129
|
}
|
|
130
130
|
function padRight(str, length) {
|
|
131
131
|
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
@@ -133,7 +133,13 @@ function padRight(str, length) {
|
|
|
133
133
|
function camelcase(input) {
|
|
134
134
|
return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
|
|
135
135
|
}
|
|
136
|
+
const UNSAFE_KEYS = /* @__PURE__ */ new Set([
|
|
137
|
+
"__proto__",
|
|
138
|
+
"constructor",
|
|
139
|
+
"prototype"
|
|
140
|
+
]);
|
|
136
141
|
function setDotProp(obj, keys, val) {
|
|
142
|
+
if (keys.some((key)=>UNSAFE_KEYS.has(key))) return;
|
|
137
143
|
let current = obj;
|
|
138
144
|
for(let i = 0; i < keys.length; i++){
|
|
139
145
|
const key = keys[i];
|
|
@@ -149,14 +155,11 @@ function setDotProp(obj, keys, val) {
|
|
|
149
155
|
}
|
|
150
156
|
}
|
|
151
157
|
function setByType(obj, transforms) {
|
|
152
|
-
for (const key of Object.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
].flat();
|
|
158
|
-
if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
|
|
159
|
-
}
|
|
158
|
+
for (const [key, transform] of Object.entries(transforms))if (transform.shouldTransform && key in obj) {
|
|
159
|
+
obj[key] = [
|
|
160
|
+
obj[key]
|
|
161
|
+
].flat();
|
|
162
|
+
if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
function getFileName(input) {
|
|
@@ -195,7 +198,7 @@ var Option = class {
|
|
|
195
198
|
name = name.replace(/^no-/, "");
|
|
196
199
|
}
|
|
197
200
|
return camelcaseOptionName(name);
|
|
198
|
-
}).sort((a, b)=>a.length
|
|
201
|
+
}).sort((a, b)=>a.length - b.length);
|
|
199
202
|
this.name = this.names.at(-1);
|
|
200
203
|
if (this.negated && null == this.config.default) this.config.default = true;
|
|
201
204
|
if (rawName.includes("<")) this.required = true;
|
|
@@ -203,14 +206,15 @@ var Option = class {
|
|
|
203
206
|
else this.isBoolean = true;
|
|
204
207
|
}
|
|
205
208
|
};
|
|
206
|
-
let runtimeProcessArgs;
|
|
207
209
|
let runtimeInfo;
|
|
208
210
|
if ("u" > typeof process) {
|
|
209
211
|
let runtimeName;
|
|
210
212
|
runtimeName = "u" > typeof Deno && "string" == typeof Deno.version?.deno ? "deno" : "u" > typeof Bun && "string" == typeof Bun.version ? "bun" : "node";
|
|
211
213
|
runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
|
|
212
|
-
runtimeProcessArgs = process.argv;
|
|
213
214
|
} else runtimeInfo = "u" < typeof navigator ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
|
|
215
|
+
function getRuntimeProcessArgs() {
|
|
216
|
+
return "u" < typeof process ? void 0 : process.argv;
|
|
217
|
+
}
|
|
214
218
|
var Command = class {
|
|
215
219
|
rawName;
|
|
216
220
|
description;
|
|
@@ -281,7 +285,7 @@ var Command = class {
|
|
|
281
285
|
return this instanceof GlobalCommand;
|
|
282
286
|
}
|
|
283
287
|
hasOption(name) {
|
|
284
|
-
name = name.split(".")[0];
|
|
288
|
+
name = name.split(".", 1)[0];
|
|
285
289
|
return this.options.find((option)=>option.names.includes(name));
|
|
286
290
|
}
|
|
287
291
|
outputHelp() {
|
|
@@ -350,7 +354,7 @@ var Command = class {
|
|
|
350
354
|
...this.options
|
|
351
355
|
];
|
|
352
356
|
for (const option of options){
|
|
353
|
-
const value = parsedOptions[option.name.split(".")[0]];
|
|
357
|
+
const value = parsedOptions[option.name.split(".", 1)[0]];
|
|
354
358
|
if (option.required) {
|
|
355
359
|
const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
356
360
|
if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
@@ -437,6 +441,7 @@ var CAC = class extends EventTarget {
|
|
|
437
441
|
}
|
|
438
442
|
parse(argv, { run = true } = {}) {
|
|
439
443
|
if (!argv) {
|
|
444
|
+
const runtimeProcessArgs = getRuntimeProcessArgs();
|
|
440
445
|
if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
|
|
441
446
|
argv = runtimeProcessArgs;
|
|
442
447
|
}
|
|
@@ -525,8 +530,8 @@ var CAC = class extends EventTarget {
|
|
|
525
530
|
transforms[cliOption.name].transformFunction = cliOption.config.type[0];
|
|
526
531
|
}
|
|
527
532
|
}
|
|
528
|
-
for (const key of Object.
|
|
529
|
-
setDotProp(options, key.split("."),
|
|
533
|
+
for (const [key, value] of Object.entries(parsed))if ("_" !== key) {
|
|
534
|
+
setDotProp(options, key.split("."), value);
|
|
530
535
|
setByType(options, transforms);
|
|
531
536
|
}
|
|
532
537
|
return {
|
|
@@ -869,7 +874,7 @@ const cachedImport = (importer)=>{
|
|
|
869
874
|
throw error;
|
|
870
875
|
});
|
|
871
876
|
};
|
|
872
|
-
|
|
877
|
+
let getJiti = cachedImport(()=>import("../compiled/jiti/index.js"));
|
|
873
878
|
const loadWithJiti = async (configPath, exportName, fresh)=>{
|
|
874
879
|
let createJiti;
|
|
875
880
|
try {
|
|
@@ -1143,7 +1148,7 @@ class RspackCLI {
|
|
|
1143
1148
|
this.colors = this.createColors();
|
|
1144
1149
|
this.program = program;
|
|
1145
1150
|
program.help();
|
|
1146
|
-
program.version("2.
|
|
1151
|
+
program.version("2.3.0-beta.1");
|
|
1147
1152
|
}
|
|
1148
1153
|
wrapAction(fn) {
|
|
1149
1154
|
return (...args)=>{
|
|
@@ -1241,19 +1246,12 @@ class RspackCLI {
|
|
|
1241
1246
|
if (!installed) (item.plugins ??= []).push(new rspack.ProgressPlugin());
|
|
1242
1247
|
}
|
|
1243
1248
|
const cacheOptions = item.cache;
|
|
1244
|
-
if ('object' == typeof cacheOptions &&
|
|
1249
|
+
if ('object' == typeof cacheOptions && 'persistent' === cacheOptions.type) {
|
|
1245
1250
|
const configPaths = pathMap.get(item);
|
|
1246
|
-
if (configPaths)
|
|
1251
|
+
if (configPaths) cacheOptions.buildDependencies = [
|
|
1247
1252
|
...configPaths,
|
|
1248
1253
|
...cacheOptions.buildDependencies || []
|
|
1249
1254
|
];
|
|
1250
|
-
else cacheOptions.buildDependencies = {
|
|
1251
|
-
...cacheOptions.buildDependencies,
|
|
1252
|
-
config: [
|
|
1253
|
-
...configPaths,
|
|
1254
|
-
...cacheOptions.buildDependencies?.config || []
|
|
1255
|
-
]
|
|
1256
|
-
};
|
|
1257
1255
|
}
|
|
1258
1256
|
if (void 0 === item.stats) item.stats = {
|
|
1259
1257
|
preset: 'errors-warnings',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-beta.1",
|
|
4
4
|
"description": "CLI for rspack",
|
|
5
5
|
"homepage": "https://rspack.rs",
|
|
6
6
|
"bugs": "https://github.com/web-infra-dev/rspack/issues",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@discoveryjs/json-ext": "^1.1.0",
|
|
32
|
-
"@microsoft/api-extractor": "^7.59.
|
|
33
|
-
"@rstackjs/load-config": "^1.0.
|
|
34
|
-
"@rspack/core": "2.
|
|
32
|
+
"@microsoft/api-extractor": "^7.59.4",
|
|
33
|
+
"@rstackjs/load-config": "^1.0.2",
|
|
34
|
+
"@rspack/core": "2.3.0-beta.1",
|
|
35
35
|
"@rspack/dev-server": "^2.2.1",
|
|
36
|
-
"cac": "^7.
|
|
36
|
+
"cac": "^7.1.0",
|
|
37
37
|
"concat-stream": "^2.0.0",
|
|
38
38
|
"execa": "^5.1.1",
|
|
39
39
|
"exit-hook": "^5.1.0",
|
|
40
40
|
"jiti": "^2.7.0",
|
|
41
41
|
"prebundle": "^1.6.5",
|
|
42
42
|
"rspack-merge": "1.0.1",
|
|
43
|
-
"rstack": "^0.8.
|
|
43
|
+
"rstack": "^0.8.4",
|
|
44
44
|
"typescript": "^6.0.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@rspack/core": "^2.
|
|
47
|
+
"@rspack/core": "^2.3.0-0",
|
|
48
48
|
"@rspack/dev-server": "^2.0.0-0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|