@rspack-canary/cli 1.6.0-canary-c1ffd5c5-20251016085846 → 1.6.0-canary-beafb11e-20251017173713
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/0~361.js +5 -5
- package/dist/1~361.mjs +5 -5
- package/dist/cli.d.ts +11 -9
- package/dist/index.js +807 -264
- package/dist/index.mjs +779 -265
- package/dist/types.d.ts +0 -30
- package/dist/utils/loadConfig.d.ts +6 -6
- package/dist/utils/options.d.ts +23 -71
- package/dist/utils/rspackCore.d.ts +2 -0
- package/package.json +7 -8
package/dist/index.js
CHANGED
|
@@ -1,7 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
2
5
|
var __webpack_modules__ = {
|
|
3
|
-
"@
|
|
4
|
-
module
|
|
6
|
+
"../../node_modules/.pnpm/pirates@4.0.7/node_modules/pirates/lib/index.js": function(module, exports1, __webpack_require__) {
|
|
7
|
+
module = __webpack_require__.nmd(module);
|
|
8
|
+
const BuiltinModule = __webpack_require__("module");
|
|
9
|
+
const path = __webpack_require__("path");
|
|
10
|
+
const nodeModulesRegex = /^(?:.*[\\/])?node_modules(?:[\\/].*)?$/;
|
|
11
|
+
const Module = module.constructor.length > 1 ? module.constructor : BuiltinModule;
|
|
12
|
+
const HOOK_RETURNED_NOTHING_ERROR_MESSAGE = "[Pirates] A hook returned a non-string, or nothing at all! This is a violation of intergalactic law!\n--------------------\nIf you have no idea what this means or what Pirates is, let me explain: Pirates is a module that makes it easy to implement require hooks. One of the require hooks you're using uses it. One of these require hooks didn't return anything from it's handler, so we don't know what to do. You might want to debug this.";
|
|
13
|
+
function shouldCompile(filename, exts, matcher, ignoreNodeModules) {
|
|
14
|
+
if ('string' != typeof filename) return false;
|
|
15
|
+
if (-1 === exts.indexOf(path.extname(filename))) return false;
|
|
16
|
+
const resolvedFilename = path.resolve(filename);
|
|
17
|
+
if (ignoreNodeModules && nodeModulesRegex.test(resolvedFilename)) return false;
|
|
18
|
+
if (matcher && 'function' == typeof matcher) return !!matcher(resolvedFilename);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
function addHook(hook, opts = {}) {
|
|
22
|
+
let reverted = false;
|
|
23
|
+
const loaders = [];
|
|
24
|
+
const oldLoaders = [];
|
|
25
|
+
let exts;
|
|
26
|
+
const originalJSLoader = Module._extensions['.js'];
|
|
27
|
+
const matcher = opts.matcher || null;
|
|
28
|
+
const ignoreNodeModules = false !== opts.ignoreNodeModules;
|
|
29
|
+
exts = opts.extensions || opts.exts || opts.extension || opts.ext || [
|
|
30
|
+
'.js'
|
|
31
|
+
];
|
|
32
|
+
if (!Array.isArray(exts)) exts = [
|
|
33
|
+
exts
|
|
34
|
+
];
|
|
35
|
+
exts.forEach((ext)=>{
|
|
36
|
+
if ('string' != typeof ext) throw new TypeError(`Invalid Extension: ${ext}`);
|
|
37
|
+
const oldLoader = Module._extensions[ext] || originalJSLoader;
|
|
38
|
+
oldLoaders[ext] = Module._extensions[ext];
|
|
39
|
+
loaders[ext] = Module._extensions[ext] = function(mod, filename) {
|
|
40
|
+
let compile;
|
|
41
|
+
if (!reverted) {
|
|
42
|
+
if (shouldCompile(filename, exts, matcher, ignoreNodeModules)) {
|
|
43
|
+
compile = mod._compile;
|
|
44
|
+
mod._compile = function(code) {
|
|
45
|
+
mod._compile = compile;
|
|
46
|
+
const newCode = hook(code, filename);
|
|
47
|
+
if ('string' != typeof newCode) throw new Error(HOOK_RETURNED_NOTHING_ERROR_MESSAGE);
|
|
48
|
+
return mod._compile(newCode, filename);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
oldLoader(mod, filename);
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
return function() {
|
|
56
|
+
if (reverted) return;
|
|
57
|
+
reverted = true;
|
|
58
|
+
exts.forEach((ext)=>{
|
|
59
|
+
if (Module._extensions[ext] === loaders[ext]) if (oldLoaders[ext]) Module._extensions[ext] = oldLoaders[ext];
|
|
60
|
+
else delete Module._extensions[ext];
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports1.addHook = addHook;
|
|
65
|
+
},
|
|
66
|
+
"./src/utils/rspackCore.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
67
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
68
|
+
Z: ()=>rspack
|
|
69
|
+
});
|
|
70
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
71
|
+
const rspackCore_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
72
|
+
const rspack = rspackCore_require("@rspack/core");
|
|
73
|
+
},
|
|
74
|
+
module: function(module) {
|
|
75
|
+
module.exports = require("module");
|
|
5
76
|
},
|
|
6
77
|
"node:fs": function(module) {
|
|
7
78
|
module.exports = require("node:fs");
|
|
@@ -9,6 +80,9 @@ var __webpack_modules__ = {
|
|
|
9
80
|
"node:path": function(module) {
|
|
10
81
|
module.exports = require("node:path");
|
|
11
82
|
},
|
|
83
|
+
path: function(module) {
|
|
84
|
+
module.exports = require("path");
|
|
85
|
+
},
|
|
12
86
|
"@discoveryjs/json-ext": function(module) {
|
|
13
87
|
module.exports = import("@discoveryjs/json-ext").then(function(module) {
|
|
14
88
|
return module;
|
|
@@ -35,9 +109,12 @@ function __webpack_require__(moduleId) {
|
|
|
35
109
|
var cachedModule = __webpack_module_cache__[moduleId];
|
|
36
110
|
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
37
111
|
var module = __webpack_module_cache__[moduleId] = {
|
|
112
|
+
id: moduleId,
|
|
113
|
+
loaded: false,
|
|
38
114
|
exports: {}
|
|
39
115
|
};
|
|
40
116
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
117
|
+
module.loaded = true;
|
|
41
118
|
return module.exports;
|
|
42
119
|
}
|
|
43
120
|
__webpack_require__.m = __webpack_modules__;
|
|
@@ -50,6 +127,33 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
50
127
|
return getter;
|
|
51
128
|
};
|
|
52
129
|
})();
|
|
130
|
+
(()=>{
|
|
131
|
+
var getProto = Object.getPrototypeOf ? (obj)=>Object.getPrototypeOf(obj) : (obj)=>obj.__proto__;
|
|
132
|
+
var leafPrototypes;
|
|
133
|
+
__webpack_require__.t = function(value, mode) {
|
|
134
|
+
if (1 & mode) value = this(value);
|
|
135
|
+
if (8 & mode) return value;
|
|
136
|
+
if ('object' == typeof value && value) {
|
|
137
|
+
if (4 & mode && value.__esModule) return value;
|
|
138
|
+
if (16 & mode && 'function' == typeof value.then) return value;
|
|
139
|
+
}
|
|
140
|
+
var ns = Object.create(null);
|
|
141
|
+
__webpack_require__.r(ns);
|
|
142
|
+
var def = {};
|
|
143
|
+
leafPrototypes = leafPrototypes || [
|
|
144
|
+
null,
|
|
145
|
+
getProto({}),
|
|
146
|
+
getProto([]),
|
|
147
|
+
getProto(getProto)
|
|
148
|
+
];
|
|
149
|
+
for(var current = 2 & mode && value; 'object' == typeof current && !~leafPrototypes.indexOf(current); current = getProto(current))Object.getOwnPropertyNames(current).forEach((key)=>{
|
|
150
|
+
def[key] = ()=>value[key];
|
|
151
|
+
});
|
|
152
|
+
def['default'] = ()=>value;
|
|
153
|
+
__webpack_require__.d(ns, def);
|
|
154
|
+
return ns;
|
|
155
|
+
};
|
|
156
|
+
})();
|
|
53
157
|
(()=>{
|
|
54
158
|
__webpack_require__.d = (exports1, definition)=>{
|
|
55
159
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -81,6 +185,13 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
81
185
|
});
|
|
82
186
|
};
|
|
83
187
|
})();
|
|
188
|
+
(()=>{
|
|
189
|
+
__webpack_require__.nmd = (module)=>{
|
|
190
|
+
module.paths = [];
|
|
191
|
+
if (!module.children) module.children = [];
|
|
192
|
+
return module;
|
|
193
|
+
};
|
|
194
|
+
})();
|
|
84
195
|
(()=>{
|
|
85
196
|
var installedChunks = {
|
|
86
197
|
410: 1
|
|
@@ -107,77 +218,608 @@ var __webpack_exports__ = {};
|
|
|
107
218
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_);
|
|
108
219
|
const external_node_util_namespaceObject = require("node:util");
|
|
109
220
|
var external_node_util_default = /*#__PURE__*/ __webpack_require__.n(external_node_util_namespaceObject);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
221
|
+
const external_events_namespaceObject = require("events");
|
|
222
|
+
function toArr(any) {
|
|
223
|
+
return null == any ? [] : Array.isArray(any) ? any : [
|
|
224
|
+
any
|
|
225
|
+
];
|
|
226
|
+
}
|
|
227
|
+
function toVal(out, key, val, opts) {
|
|
228
|
+
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || true === val ? '' : String(val) : 'boolean' == typeof val ? val : ~opts.boolean.indexOf(key) ? 'false' === val ? false : 'true' === val || (out._.push((x = +val, 0 * x === 0) ? x : val), !!val) : (x = +val, 0 * x === 0) ? x : val;
|
|
229
|
+
out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
|
|
230
|
+
old,
|
|
231
|
+
nxt
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
function mri2(args, opts) {
|
|
235
|
+
args = args || [];
|
|
236
|
+
opts = opts || {};
|
|
237
|
+
var k, arr, arg, name, val, out = {
|
|
238
|
+
_: []
|
|
239
|
+
};
|
|
240
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
241
|
+
const alibi = void 0 !== opts.alias;
|
|
242
|
+
const strict = void 0 !== opts.unknown;
|
|
243
|
+
const defaults = void 0 !== opts.default;
|
|
244
|
+
opts.alias = opts.alias || {};
|
|
245
|
+
opts.string = toArr(opts.string);
|
|
246
|
+
opts.boolean = toArr(opts.boolean);
|
|
247
|
+
if (alibi) for(k in opts.alias){
|
|
248
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
249
|
+
for(i = 0; i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
250
|
+
}
|
|
251
|
+
for(i = opts.boolean.length; i-- > 0;){
|
|
252
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
253
|
+
for(j = arr.length; j-- > 0;)opts.boolean.push(arr[j]);
|
|
254
|
+
}
|
|
255
|
+
for(i = opts.string.length; i-- > 0;){
|
|
256
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
257
|
+
for(j = arr.length; j-- > 0;)opts.string.push(arr[j]);
|
|
258
|
+
}
|
|
259
|
+
if (defaults) for(k in opts.default){
|
|
260
|
+
name = typeof opts.default[k];
|
|
261
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
262
|
+
if (void 0 !== opts[name]) {
|
|
263
|
+
opts[name].push(k);
|
|
264
|
+
for(i = 0; i < arr.length; i++)opts[name].push(arr[i]);
|
|
137
265
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
string: true,
|
|
164
|
-
describe: "env passed to config function"
|
|
165
|
-
},
|
|
166
|
-
devtool: {
|
|
167
|
-
type: "string",
|
|
168
|
-
describe: "Specify a developer tool for debugging. Defaults to `cheap-module-source-map` in development and `source-map` in production.",
|
|
169
|
-
alias: "d",
|
|
170
|
-
coerce: (arg)=>{
|
|
171
|
-
if ("true" === arg) return "source-map";
|
|
172
|
-
if ("false" === arg || "" === arg.trim()) return false;
|
|
173
|
-
return arg;
|
|
266
|
+
}
|
|
267
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
268
|
+
for(i = 0; i < len; i++){
|
|
269
|
+
arg = args[i];
|
|
270
|
+
if ('--' === arg) {
|
|
271
|
+
out._ = out._.concat(args.slice(++i));
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
|
|
275
|
+
if (0 === j) out._.push(arg);
|
|
276
|
+
else if ('no-' === arg.substring(j, j + 3)) {
|
|
277
|
+
name = arg.substring(j + 3);
|
|
278
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
279
|
+
out[name] = false;
|
|
280
|
+
} else {
|
|
281
|
+
for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
|
|
282
|
+
name = arg.substring(j, idx);
|
|
283
|
+
val = arg.substring(++idx) || i + 1 === len || 45 === ('' + args[i + 1]).charCodeAt(0) || args[++i];
|
|
284
|
+
arr = 2 === j ? [
|
|
285
|
+
name
|
|
286
|
+
] : name;
|
|
287
|
+
for(idx = 0; idx < arr.length; idx++){
|
|
288
|
+
name = arr[idx];
|
|
289
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
290
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
174
291
|
}
|
|
175
292
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
293
|
+
}
|
|
294
|
+
if (defaults) {
|
|
295
|
+
for(k in opts.default)if (void 0 === out[k]) out[k] = opts.default[k];
|
|
296
|
+
}
|
|
297
|
+
if (alibi) for(k in out){
|
|
298
|
+
arr = opts.alias[k] || [];
|
|
299
|
+
while(arr.length > 0)out[arr.shift()] = out[k];
|
|
300
|
+
}
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
303
|
+
const removeBrackets = (v)=>v.replace(/[<[].+/, "").trim();
|
|
304
|
+
const findAllBrackets = (v)=>{
|
|
305
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
306
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
307
|
+
const res = [];
|
|
308
|
+
const parse = (match)=>{
|
|
309
|
+
let variadic = false;
|
|
310
|
+
let value = match[1];
|
|
311
|
+
if (value.startsWith("...")) {
|
|
312
|
+
value = value.slice(3);
|
|
313
|
+
variadic = true;
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
required: match[0].startsWith("<"),
|
|
317
|
+
value,
|
|
318
|
+
variadic
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
let angledMatch;
|
|
322
|
+
while(angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v))res.push(parse(angledMatch));
|
|
323
|
+
let squareMatch;
|
|
324
|
+
while(squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))res.push(parse(squareMatch));
|
|
325
|
+
return res;
|
|
326
|
+
};
|
|
327
|
+
const getMriOptions = (options)=>{
|
|
328
|
+
const result = {
|
|
329
|
+
alias: {},
|
|
330
|
+
boolean: []
|
|
331
|
+
};
|
|
332
|
+
for (const [index, option] of options.entries()){
|
|
333
|
+
if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
|
|
334
|
+
if (option.isBoolean) if (option.negated) {
|
|
335
|
+
const hasStringTypeOption = options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required);
|
|
336
|
+
if (!hasStringTypeOption) result.boolean.push(option.names[0]);
|
|
337
|
+
} else result.boolean.push(option.names[0]);
|
|
338
|
+
}
|
|
339
|
+
return result;
|
|
340
|
+
};
|
|
341
|
+
const findLongest = (arr)=>arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
|
|
342
|
+
const padRight = (str, length)=>str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
343
|
+
const camelcase = (input)=>input.replace(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
|
|
344
|
+
const setDotProp = (obj, keys, val)=>{
|
|
345
|
+
let i = 0;
|
|
346
|
+
let length = keys.length;
|
|
347
|
+
let t = obj;
|
|
348
|
+
let x;
|
|
349
|
+
for(; i < length; ++i){
|
|
350
|
+
x = t[keys[i]];
|
|
351
|
+
t = t[keys[i]] = i === length - 1 ? val : null != x ? x : !~keys[i + 1].indexOf(".") && +keys[i + 1] > -1 ? [] : {};
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const setByType = (obj, transforms)=>{
|
|
355
|
+
for (const key of Object.keys(transforms)){
|
|
356
|
+
const transform = transforms[key];
|
|
357
|
+
if (transform.shouldTransform) {
|
|
358
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
359
|
+
if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
const getFileName = (input)=>{
|
|
364
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
365
|
+
return m ? m[1] : "";
|
|
366
|
+
};
|
|
367
|
+
const camelcaseOptionName = (name)=>name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
|
|
368
|
+
class CACError extends Error {
|
|
369
|
+
constructor(message){
|
|
370
|
+
super(message);
|
|
371
|
+
this.name = this.constructor.name;
|
|
372
|
+
if ("function" == typeof Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
373
|
+
else this.stack = new Error(message).stack;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
class Option {
|
|
377
|
+
constructor(rawName, description, config){
|
|
378
|
+
this.rawName = rawName;
|
|
379
|
+
this.description = description;
|
|
380
|
+
this.config = Object.assign({}, config);
|
|
381
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
382
|
+
this.negated = false;
|
|
383
|
+
this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
384
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
385
|
+
if (name.startsWith("no-")) {
|
|
386
|
+
this.negated = true;
|
|
387
|
+
name = name.replace(/^no-/, "");
|
|
388
|
+
}
|
|
389
|
+
return camelcaseOptionName(name);
|
|
390
|
+
}).sort((a, b)=>a.length > b.length ? 1 : -1);
|
|
391
|
+
this.name = this.names[this.names.length - 1];
|
|
392
|
+
if (this.negated && null == this.config.default) this.config.default = true;
|
|
393
|
+
if (rawName.includes("<")) this.required = true;
|
|
394
|
+
else if (rawName.includes("[")) this.required = false;
|
|
395
|
+
else this.isBoolean = true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const processArgs = process.argv;
|
|
399
|
+
const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
400
|
+
class Command {
|
|
401
|
+
constructor(rawName, description, config = {}, cli){
|
|
402
|
+
this.rawName = rawName;
|
|
403
|
+
this.description = description;
|
|
404
|
+
this.config = config;
|
|
405
|
+
this.cli = cli;
|
|
406
|
+
this.options = [];
|
|
407
|
+
this.aliasNames = [];
|
|
408
|
+
this.name = removeBrackets(rawName);
|
|
409
|
+
this.args = findAllBrackets(rawName);
|
|
410
|
+
this.examples = [];
|
|
411
|
+
}
|
|
412
|
+
usage(text) {
|
|
413
|
+
this.usageText = text;
|
|
414
|
+
return this;
|
|
415
|
+
}
|
|
416
|
+
allowUnknownOptions() {
|
|
417
|
+
this.config.allowUnknownOptions = true;
|
|
418
|
+
return this;
|
|
419
|
+
}
|
|
420
|
+
ignoreOptionDefaultValue() {
|
|
421
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
version(version, customFlags = "-v, --version") {
|
|
425
|
+
this.versionNumber = version;
|
|
426
|
+
this.option(customFlags, "Display version number");
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
example(example) {
|
|
430
|
+
this.examples.push(example);
|
|
431
|
+
return this;
|
|
432
|
+
}
|
|
433
|
+
option(rawName, description, config) {
|
|
434
|
+
const option = new Option(rawName, description, config);
|
|
435
|
+
this.options.push(option);
|
|
436
|
+
return this;
|
|
437
|
+
}
|
|
438
|
+
alias(name) {
|
|
439
|
+
this.aliasNames.push(name);
|
|
440
|
+
return this;
|
|
441
|
+
}
|
|
442
|
+
action(callback) {
|
|
443
|
+
this.commandAction = callback;
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
isMatched(name) {
|
|
447
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
448
|
+
}
|
|
449
|
+
get isDefaultCommand() {
|
|
450
|
+
return "" === this.name || this.aliasNames.includes("!");
|
|
451
|
+
}
|
|
452
|
+
get isGlobalCommand() {
|
|
453
|
+
return this instanceof GlobalCommand;
|
|
454
|
+
}
|
|
455
|
+
hasOption(name) {
|
|
456
|
+
name = name.split(".")[0];
|
|
457
|
+
return this.options.find((option)=>option.names.includes(name));
|
|
458
|
+
}
|
|
459
|
+
outputHelp() {
|
|
460
|
+
const { name, commands } = this.cli;
|
|
461
|
+
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
|
|
462
|
+
let sections = [
|
|
463
|
+
{
|
|
464
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
465
|
+
}
|
|
466
|
+
];
|
|
467
|
+
sections.push({
|
|
468
|
+
title: "Usage",
|
|
469
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
470
|
+
});
|
|
471
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
472
|
+
if (showCommands) {
|
|
473
|
+
const longestCommandName = findLongest(commands.map((command)=>command.rawName));
|
|
474
|
+
sections.push({
|
|
475
|
+
title: "Commands",
|
|
476
|
+
body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
|
|
477
|
+
});
|
|
478
|
+
sections.push({
|
|
479
|
+
title: "For more info, run any command with the `--help` flag",
|
|
480
|
+
body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
let options = this.isGlobalCommand ? globalOptions : [
|
|
484
|
+
...this.options,
|
|
485
|
+
...globalOptions || []
|
|
486
|
+
];
|
|
487
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option)=>"version" !== option.name);
|
|
488
|
+
if (options.length > 0) {
|
|
489
|
+
const longestOptionName = findLongest(options.map((option)=>option.rawName));
|
|
490
|
+
sections.push({
|
|
491
|
+
title: "Options",
|
|
492
|
+
body: options.map((option)=>` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${void 0 === option.config.default ? "" : `(default: ${option.config.default})`}`).join("\n")
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
if (this.examples.length > 0) sections.push({
|
|
496
|
+
title: "Examples",
|
|
497
|
+
body: this.examples.map((example)=>{
|
|
498
|
+
if ("function" == typeof example) return example(name);
|
|
499
|
+
return example;
|
|
500
|
+
}).join("\n")
|
|
501
|
+
});
|
|
502
|
+
if (helpCallback) sections = helpCallback(sections) || sections;
|
|
503
|
+
console.log(sections.map((section)=>section.title ? `${section.title}:
|
|
504
|
+
${section.body}` : section.body).join("\n\n"));
|
|
505
|
+
}
|
|
506
|
+
outputVersion() {
|
|
507
|
+
const { name } = this.cli;
|
|
508
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
509
|
+
if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
510
|
+
}
|
|
511
|
+
checkRequiredArgs() {
|
|
512
|
+
const minimalArgsCount = this.args.filter((arg)=>arg.required).length;
|
|
513
|
+
if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
514
|
+
}
|
|
515
|
+
checkUnknownOptions() {
|
|
516
|
+
const { options, globalCommand } = this.cli;
|
|
517
|
+
if (!this.config.allowUnknownOptions) {
|
|
518
|
+
for (const name of Object.keys(options))if ("--" !== name && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
checkOptionValue() {
|
|
522
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
523
|
+
const options = [
|
|
524
|
+
...globalCommand.options,
|
|
525
|
+
...this.options
|
|
526
|
+
];
|
|
527
|
+
for (const option of options){
|
|
528
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
529
|
+
if (option.required) {
|
|
530
|
+
const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
531
|
+
if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
class GlobalCommand extends Command {
|
|
537
|
+
constructor(cli){
|
|
538
|
+
super("@@global@@", "", {}, cli);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
var __assign = Object.assign;
|
|
542
|
+
class CAC extends external_events_namespaceObject.EventEmitter {
|
|
543
|
+
constructor(name = ""){
|
|
544
|
+
super();
|
|
545
|
+
this.name = name;
|
|
546
|
+
this.commands = [];
|
|
547
|
+
this.rawArgs = [];
|
|
548
|
+
this.args = [];
|
|
549
|
+
this.options = {};
|
|
550
|
+
this.globalCommand = new GlobalCommand(this);
|
|
551
|
+
this.globalCommand.usage("<command> [options]");
|
|
552
|
+
}
|
|
553
|
+
usage(text) {
|
|
554
|
+
this.globalCommand.usage(text);
|
|
555
|
+
return this;
|
|
556
|
+
}
|
|
557
|
+
command(rawName, description, config) {
|
|
558
|
+
const command = new Command(rawName, description || "", config, this);
|
|
559
|
+
command.globalCommand = this.globalCommand;
|
|
560
|
+
this.commands.push(command);
|
|
561
|
+
return command;
|
|
562
|
+
}
|
|
563
|
+
option(rawName, description, config) {
|
|
564
|
+
this.globalCommand.option(rawName, description, config);
|
|
565
|
+
return this;
|
|
566
|
+
}
|
|
567
|
+
help(callback) {
|
|
568
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
569
|
+
this.globalCommand.helpCallback = callback;
|
|
570
|
+
this.showHelpOnExit = true;
|
|
571
|
+
return this;
|
|
572
|
+
}
|
|
573
|
+
version(version, customFlags = "-v, --version") {
|
|
574
|
+
this.globalCommand.version(version, customFlags);
|
|
575
|
+
this.showVersionOnExit = true;
|
|
576
|
+
return this;
|
|
577
|
+
}
|
|
578
|
+
example(example) {
|
|
579
|
+
this.globalCommand.example(example);
|
|
580
|
+
return this;
|
|
581
|
+
}
|
|
582
|
+
outputHelp() {
|
|
583
|
+
if (this.matchedCommand) this.matchedCommand.outputHelp();
|
|
584
|
+
else this.globalCommand.outputHelp();
|
|
585
|
+
}
|
|
586
|
+
outputVersion() {
|
|
587
|
+
this.globalCommand.outputVersion();
|
|
588
|
+
}
|
|
589
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
590
|
+
this.args = args;
|
|
591
|
+
this.options = options;
|
|
592
|
+
if (matchedCommand) this.matchedCommand = matchedCommand;
|
|
593
|
+
if (matchedCommandName) this.matchedCommandName = matchedCommandName;
|
|
594
|
+
return this;
|
|
595
|
+
}
|
|
596
|
+
unsetMatchedCommand() {
|
|
597
|
+
this.matchedCommand = void 0;
|
|
598
|
+
this.matchedCommandName = void 0;
|
|
599
|
+
}
|
|
600
|
+
parse(argv = processArgs, { run = true } = {}) {
|
|
601
|
+
this.rawArgs = argv;
|
|
602
|
+
if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
603
|
+
let shouldParse = true;
|
|
604
|
+
for (const command of this.commands){
|
|
605
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
606
|
+
const commandName = parsed.args[0];
|
|
607
|
+
if (command.isMatched(commandName)) {
|
|
608
|
+
shouldParse = false;
|
|
609
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
610
|
+
args: parsed.args.slice(1)
|
|
611
|
+
});
|
|
612
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
613
|
+
this.emit(`command:${commandName}`, command);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (shouldParse) {
|
|
617
|
+
for (const command of this.commands)if ("" === command.name) {
|
|
618
|
+
shouldParse = false;
|
|
619
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
620
|
+
this.setParsedInfo(parsed, command);
|
|
621
|
+
this.emit("command:!", command);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
if (shouldParse) {
|
|
625
|
+
const parsed = this.mri(argv.slice(2));
|
|
626
|
+
this.setParsedInfo(parsed);
|
|
627
|
+
}
|
|
628
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
629
|
+
this.outputHelp();
|
|
630
|
+
run = false;
|
|
631
|
+
this.unsetMatchedCommand();
|
|
632
|
+
}
|
|
633
|
+
if (this.options.version && this.showVersionOnExit && null == this.matchedCommandName) {
|
|
634
|
+
this.outputVersion();
|
|
635
|
+
run = false;
|
|
636
|
+
this.unsetMatchedCommand();
|
|
637
|
+
}
|
|
638
|
+
const parsedArgv = {
|
|
639
|
+
args: this.args,
|
|
640
|
+
options: this.options
|
|
641
|
+
};
|
|
642
|
+
if (run) this.runMatchedCommand();
|
|
643
|
+
if (!this.matchedCommand && this.args[0]) this.emit("command:*");
|
|
644
|
+
return parsedArgv;
|
|
645
|
+
}
|
|
646
|
+
mri(argv, command) {
|
|
647
|
+
const cliOptions = [
|
|
648
|
+
...this.globalCommand.options,
|
|
649
|
+
...command ? command.options : []
|
|
650
|
+
];
|
|
651
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
652
|
+
let argsAfterDoubleDashes = [];
|
|
653
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
654
|
+
if (doubleDashesIndex > -1) {
|
|
655
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
656
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
657
|
+
}
|
|
658
|
+
let parsed = mri2(argv, mriOptions);
|
|
659
|
+
parsed = Object.keys(parsed).reduce((res, name)=>__assign(__assign({}, res), {
|
|
660
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
661
|
+
}), {
|
|
662
|
+
_: []
|
|
663
|
+
});
|
|
664
|
+
const args = parsed._;
|
|
665
|
+
const options = {
|
|
666
|
+
"--": argsAfterDoubleDashes
|
|
667
|
+
};
|
|
668
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
669
|
+
let transforms = Object.create(null);
|
|
670
|
+
for (const cliOption of cliOptions){
|
|
671
|
+
if (!ignoreDefault && void 0 !== cliOption.config.default) for (const name of cliOption.names)options[name] = cliOption.config.default;
|
|
672
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
673
|
+
if (void 0 === transforms[cliOption.name]) {
|
|
674
|
+
transforms[cliOption.name] = Object.create(null);
|
|
675
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
676
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
for (const key of Object.keys(parsed))if ("_" !== key) {
|
|
681
|
+
const keys = key.split(".");
|
|
682
|
+
setDotProp(options, keys, parsed[key]);
|
|
683
|
+
setByType(options, transforms);
|
|
684
|
+
}
|
|
685
|
+
return {
|
|
686
|
+
args,
|
|
687
|
+
options
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
runMatchedCommand() {
|
|
691
|
+
const { args, options, matchedCommand: command } = this;
|
|
692
|
+
if (!command || !command.commandAction) return;
|
|
693
|
+
command.checkUnknownOptions();
|
|
694
|
+
command.checkOptionValue();
|
|
695
|
+
command.checkRequiredArgs();
|
|
696
|
+
const actionArgs = [];
|
|
697
|
+
command.args.forEach((arg, index)=>{
|
|
698
|
+
if (arg.variadic) actionArgs.push(args.slice(index));
|
|
699
|
+
else actionArgs.push(args[index]);
|
|
700
|
+
});
|
|
701
|
+
actionArgs.push(options);
|
|
702
|
+
return command.commandAction.apply(this, actionArgs);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
const cac = (name = "")=>new CAC(name);
|
|
706
|
+
const dist = cac;
|
|
707
|
+
const external_tty_namespaceObject = require("tty");
|
|
708
|
+
var external_tty_namespaceObject_0 = /*#__PURE__*/ __webpack_require__.t(external_tty_namespaceObject, 2);
|
|
709
|
+
const { env: colorette_env = {}, argv: colorette_argv = [], platform = "" } = "undefined" == typeof process ? {} : process;
|
|
710
|
+
const isDisabled = "NO_COLOR" in colorette_env || colorette_argv.includes("--no-color");
|
|
711
|
+
const isForced = "FORCE_COLOR" in colorette_env || colorette_argv.includes("--color");
|
|
712
|
+
const isWindows = "win32" === platform;
|
|
713
|
+
const isDumbTerminal = "dumb" === colorette_env.TERM;
|
|
714
|
+
const isCompatibleTerminal = external_tty_namespaceObject_0 && external_tty_namespaceObject.isatty && external_tty_namespaceObject.isatty(1) && colorette_env.TERM && !isDumbTerminal;
|
|
715
|
+
const isCI = "CI" in colorette_env && ("GITHUB_ACTIONS" in colorette_env || "GITLAB_CI" in colorette_env || "CIRCLECI" in colorette_env);
|
|
716
|
+
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
717
|
+
const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close))=>head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
718
|
+
const clearBleed = (index, string, open, close, replace)=>index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
719
|
+
const filterEmpty = (open, close, replace = open, at = open.length + 1)=>(string)=>string || !("" === string || void 0 === string) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
720
|
+
const init = (open, close, replace)=>filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
721
|
+
const colorette_colors = {
|
|
722
|
+
reset: init(0, 0),
|
|
723
|
+
bold: init(1, 22, "\x1b[22m\x1b[1m"),
|
|
724
|
+
dim: init(2, 22, "\x1b[22m\x1b[2m"),
|
|
725
|
+
italic: init(3, 23),
|
|
726
|
+
underline: init(4, 24),
|
|
727
|
+
inverse: init(7, 27),
|
|
728
|
+
hidden: init(8, 28),
|
|
729
|
+
strikethrough: init(9, 29),
|
|
730
|
+
black: init(30, 39),
|
|
731
|
+
red: init(31, 39),
|
|
732
|
+
green: init(32, 39),
|
|
733
|
+
yellow: init(33, 39),
|
|
734
|
+
blue: init(34, 39),
|
|
735
|
+
magenta: init(35, 39),
|
|
736
|
+
cyan: init(36, 39),
|
|
737
|
+
white: init(37, 39),
|
|
738
|
+
gray: init(90, 39),
|
|
739
|
+
bgBlack: init(40, 49),
|
|
740
|
+
bgRed: init(41, 49),
|
|
741
|
+
bgGreen: init(42, 49),
|
|
742
|
+
bgYellow: init(43, 49),
|
|
743
|
+
bgBlue: init(44, 49),
|
|
744
|
+
bgMagenta: init(45, 49),
|
|
745
|
+
bgCyan: init(46, 49),
|
|
746
|
+
bgWhite: init(47, 49),
|
|
747
|
+
blackBright: init(90, 39),
|
|
748
|
+
redBright: init(91, 39),
|
|
749
|
+
greenBright: init(92, 39),
|
|
750
|
+
yellowBright: init(93, 39),
|
|
751
|
+
blueBright: init(94, 39),
|
|
752
|
+
magentaBright: init(95, 39),
|
|
753
|
+
cyanBright: init(96, 39),
|
|
754
|
+
whiteBright: init(97, 39),
|
|
755
|
+
bgBlackBright: init(100, 49),
|
|
756
|
+
bgRedBright: init(101, 49),
|
|
757
|
+
bgGreenBright: init(102, 49),
|
|
758
|
+
bgYellowBright: init(103, 49),
|
|
759
|
+
bgBlueBright: init(104, 49),
|
|
760
|
+
bgMagentaBright: init(105, 49),
|
|
761
|
+
bgCyanBright: init(106, 49),
|
|
762
|
+
bgWhiteBright: init(107, 49)
|
|
763
|
+
};
|
|
764
|
+
const createColors = ({ useColor = isColorSupported } = {})=>useColor ? colorette_colors : Object.keys(colorette_colors).reduce((colors, key)=>({
|
|
765
|
+
...colors,
|
|
766
|
+
[key]: String
|
|
767
|
+
}), {});
|
|
768
|
+
const { reset: colorette_reset, bold, dim, italic, underline, inverse, hidden: colorette_hidden, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
|
|
769
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
770
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_);
|
|
771
|
+
const commonOptions = (command)=>command.option("-c, --config <path>", "config file").option("--config-name <name>", "Name(s) of the configuration to use.", {
|
|
772
|
+
type: [
|
|
773
|
+
String
|
|
774
|
+
],
|
|
775
|
+
default: []
|
|
776
|
+
}).option("--config-loader <loader>", "Specify the loader to load the config file, can be `native` or `register`.", {
|
|
777
|
+
default: "register"
|
|
778
|
+
}).option("--env <env>", "env passed to config function", {
|
|
779
|
+
type: [
|
|
780
|
+
String
|
|
781
|
+
],
|
|
782
|
+
default: []
|
|
783
|
+
}).option("--node-env <value>", "sets `process.env.NODE_ENV` to be specified value");
|
|
784
|
+
function normalizeDevtoolOption(value) {
|
|
785
|
+
if ("string" == typeof value) {
|
|
786
|
+
const trimmed = value.trim();
|
|
787
|
+
if ("" === trimmed || "false" === trimmed) return false;
|
|
788
|
+
if ("true" === trimmed) return "source-map";
|
|
789
|
+
return trimmed;
|
|
790
|
+
}
|
|
791
|
+
if ("boolean" == typeof value) return value ? "source-map" : false;
|
|
792
|
+
}
|
|
793
|
+
const normalizeCommonOptions = (options, action)=>{
|
|
794
|
+
const isEmptyArray = (arr)=>Array.isArray(arr) && 0 === arr.length;
|
|
795
|
+
for (const key of [
|
|
796
|
+
"entry",
|
|
797
|
+
"configName"
|
|
798
|
+
]){
|
|
799
|
+
const val = options[key];
|
|
800
|
+
if (isEmptyArray(val)) options[key] = void 0;
|
|
801
|
+
}
|
|
802
|
+
const env = Array.isArray(options.env) ? normalizeEnvToObject(options) : {};
|
|
803
|
+
options.env = env;
|
|
804
|
+
if ("serve" === action) setBuiltinEnvArg(env, "SERVE", true);
|
|
805
|
+
else if ("build" === action) if (options.watch) setBuiltinEnvArg(env, "WATCH", true);
|
|
806
|
+
else {
|
|
807
|
+
setBuiltinEnvArg(env, "BUNDLE", true);
|
|
808
|
+
setBuiltinEnvArg(env, "BUILD", true);
|
|
809
|
+
}
|
|
810
|
+
if ("devtool" in options) options.devtool = normalizeDevtoolOption(options.devtool);
|
|
811
|
+
};
|
|
812
|
+
const commonOptionsForBuildAndServe = (command)=>command.option("--analyze", "analyze").option("-d, --devtool <value>", "specify a developer tool for debugging. Defaults to `cheap-module-source-map` in development and `source-map` in production.").option("--entry <entry>", "entry file", {
|
|
813
|
+
type: [
|
|
814
|
+
String
|
|
815
|
+
],
|
|
816
|
+
default: []
|
|
817
|
+
}).option("-m, --mode <mode>", "mode").option("-o, --output-path <dir>", "output path dir").option("--profile", "capture timing information for each module").option("-w, --watch", "watch");
|
|
818
|
+
function setBuiltinEnvArg(env, envNameSuffix, value) {
|
|
819
|
+
const envName = `RSPACK_${envNameSuffix}`;
|
|
820
|
+
if (!(envName in env)) env[envName] = value;
|
|
821
|
+
}
|
|
822
|
+
function normalizeEnvToObject(options) {
|
|
181
823
|
function parseValue(previous, value) {
|
|
182
824
|
const [allKeys, val] = value.split(/=(.+)/, 2);
|
|
183
825
|
const splitKeys = allKeys.split(/\.(?!$)/);
|
|
@@ -196,155 +838,80 @@ var __webpack_exports__ = {};
|
|
|
196
838
|
});
|
|
197
839
|
return previous;
|
|
198
840
|
}
|
|
199
|
-
|
|
200
|
-
argv.env = envObj;
|
|
201
|
-
}
|
|
202
|
-
function setBuiltinEnvArg(env, envNameSuffix, value) {
|
|
203
|
-
const envNames = [
|
|
204
|
-
`RSPACK_${envNameSuffix}`
|
|
205
|
-
];
|
|
206
|
-
for (const envName of envNames)if (!(envName in env)) env[envName] = value;
|
|
207
|
-
}
|
|
208
|
-
function ensureEnvObject(options) {
|
|
209
|
-
if (Array.isArray(options.env)) normalizeEnv(options);
|
|
210
|
-
options.env = options.env || {};
|
|
211
|
-
return options.env;
|
|
841
|
+
return (options.env ?? []).reduce(parseValue, {});
|
|
212
842
|
}
|
|
213
843
|
function setDefaultNodeEnv(options, defaultEnv) {
|
|
214
|
-
if (void 0
|
|
215
|
-
process.env.NODE_ENV = "string" == typeof options.nodeEnv ? options.nodeEnv : defaultEnv;
|
|
844
|
+
if (void 0 === process.env.NODE_ENV) process.env.NODE_ENV = "string" == typeof options.nodeEnv ? options.nodeEnv : defaultEnv;
|
|
216
845
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}, async (options)=>{
|
|
241
|
-
setDefaultNodeEnv(options, "production");
|
|
242
|
-
const env = ensureEnvObject(options);
|
|
243
|
-
if (options.watch) setBuiltinEnvArg(env, "WATCH", true);
|
|
244
|
-
else {
|
|
245
|
-
setBuiltinEnvArg(env, "BUNDLE", true);
|
|
246
|
-
setBuiltinEnvArg(env, "BUILD", true);
|
|
247
|
-
}
|
|
248
|
-
const logger = cli.getLogger();
|
|
249
|
-
let createJsonStringifyStream;
|
|
250
|
-
if (options.json) {
|
|
251
|
-
const jsonExt = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@discoveryjs/json-ext"));
|
|
252
|
-
createJsonStringifyStream = jsonExt.default.stringifyStream;
|
|
253
|
-
}
|
|
254
|
-
const errorHandler = (error, stats)=>{
|
|
255
|
-
if (error) {
|
|
256
|
-
logger.error(error);
|
|
257
|
-
process.exit(2);
|
|
258
|
-
}
|
|
259
|
-
if (stats?.hasErrors()) process.exitCode = 1;
|
|
260
|
-
if (!compiler || !stats) return;
|
|
261
|
-
const statsOptions = cli.isMultipleCompiler(compiler) ? {
|
|
262
|
-
children: compiler.compilers.map((compiler)=>compiler.options ? compiler.options.stats : void 0)
|
|
263
|
-
} : compiler.options ? compiler.options.stats : void 0;
|
|
264
|
-
if (options.json && createJsonStringifyStream) {
|
|
265
|
-
const handleWriteError = (error)=>{
|
|
266
|
-
logger.error(error);
|
|
267
|
-
process.exit(2);
|
|
268
|
-
};
|
|
269
|
-
if (true === options.json) createJsonStringifyStream(stats.toJson(statsOptions)).on("error", handleWriteError).pipe(process.stdout).on("error", handleWriteError).on("close", ()=>process.stdout.write("\n"));
|
|
270
|
-
else if ("string" == typeof options.json) createJsonStringifyStream(stats.toJson(statsOptions)).on("error", handleWriteError).pipe(external_node_fs_.createWriteStream(options.json)).on("error", handleWriteError).on("close", ()=>{
|
|
271
|
-
process.stderr.write(`[rspack-cli] ${cli.colors.green(`stats are successfully stored as json to ${options.json}`)}\n`);
|
|
272
|
-
});
|
|
273
|
-
} else {
|
|
274
|
-
const printedStats = stats.toString(statsOptions);
|
|
275
|
-
if (printedStats) logger.raw(printedStats);
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
const rspackOptions = {
|
|
279
|
-
...options,
|
|
280
|
-
argv: {
|
|
281
|
-
...options
|
|
282
|
-
}
|
|
846
|
+
async function runBuild(cli, options) {
|
|
847
|
+
setDefaultNodeEnv(options, "production");
|
|
848
|
+
normalizeCommonOptions(options, "build");
|
|
849
|
+
const logger = cli.getLogger();
|
|
850
|
+
let createJsonStringifyStream;
|
|
851
|
+
if (options.json) {
|
|
852
|
+
const jsonExt = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@discoveryjs/json-ext"));
|
|
853
|
+
createJsonStringifyStream = jsonExt.default.stringifyStream;
|
|
854
|
+
}
|
|
855
|
+
const errorHandler = (error, stats)=>{
|
|
856
|
+
if (error) {
|
|
857
|
+
logger.error(error);
|
|
858
|
+
process.exit(2);
|
|
859
|
+
}
|
|
860
|
+
if (stats?.hasErrors()) process.exitCode = 1;
|
|
861
|
+
if (!compiler || !stats) return;
|
|
862
|
+
const statsOptions = cli.isMultipleCompiler(compiler) ? {
|
|
863
|
+
children: compiler.compilers.map((item)=>item.options ? item.options.stats : void 0)
|
|
864
|
+
} : compiler.options?.stats;
|
|
865
|
+
if (options.json && createJsonStringifyStream) {
|
|
866
|
+
const handleWriteError = (error)=>{
|
|
867
|
+
logger.error(error);
|
|
868
|
+
process.exit(2);
|
|
283
869
|
};
|
|
284
|
-
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
-
compiler.close((closeErr)=>{
|
|
288
|
-
if (closeErr) logger.error(closeErr);
|
|
289
|
-
errorHandler(error, stats);
|
|
290
|
-
});
|
|
870
|
+
if (true === options.json) createJsonStringifyStream(stats.toJson(statsOptions)).on("error", handleWriteError).pipe(process.stdout).on("error", handleWriteError).on("close", ()=>process.stdout.write("\n"));
|
|
871
|
+
else if ("string" == typeof options.json) createJsonStringifyStream(stats.toJson(statsOptions)).on("error", handleWriteError).pipe(external_node_fs_default().createWriteStream(options.json)).on("error", handleWriteError).on("close", ()=>{
|
|
872
|
+
process.stderr.write(`[rspack-cli] ${cli.colors.green(`stats are successfully stored as json to ${options.json}`)}\n`);
|
|
291
873
|
});
|
|
874
|
+
} else {
|
|
875
|
+
const printedStats = stats.toString(statsOptions);
|
|
876
|
+
if (printedStats) logger.raw(printedStats);
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
const compiler = await cli.createCompiler(options, "build", errorHandler);
|
|
880
|
+
if (!compiler || cli.isWatch(compiler)) return;
|
|
881
|
+
compiler.run((error, stats)=>{
|
|
882
|
+
compiler.close((closeErr)=>{
|
|
883
|
+
if (closeErr) logger.error(closeErr);
|
|
884
|
+
errorHandler(error, stats);
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
class BuildCommand {
|
|
889
|
+
async apply(cli) {
|
|
890
|
+
const command = cli.program.command("", "run the Rspack build").alias("build").alias("bundle").alias("b");
|
|
891
|
+
commonOptionsForBuildAndServe(commonOptions(command)).option("--json [path]", "emit stats json");
|
|
892
|
+
command.action(async (options)=>{
|
|
893
|
+
await runBuild(cli, options);
|
|
292
894
|
});
|
|
293
895
|
}
|
|
294
896
|
}
|
|
295
|
-
|
|
296
|
-
yargs.positional("dir", {
|
|
297
|
-
type: "string",
|
|
298
|
-
describe: "directory want to preview"
|
|
299
|
-
});
|
|
300
|
-
return commonOptions(yargs).options({
|
|
301
|
-
publicPath: {
|
|
302
|
-
type: "string",
|
|
303
|
-
describe: "static resource server path"
|
|
304
|
-
},
|
|
305
|
-
port: {
|
|
306
|
-
type: "number",
|
|
307
|
-
describe: "preview server port"
|
|
308
|
-
},
|
|
309
|
-
host: {
|
|
310
|
-
type: "string",
|
|
311
|
-
describe: "preview server host"
|
|
312
|
-
},
|
|
313
|
-
open: {
|
|
314
|
-
type: "boolean",
|
|
315
|
-
describe: "open browser"
|
|
316
|
-
},
|
|
317
|
-
server: {
|
|
318
|
-
type: "string",
|
|
319
|
-
describe: "Configuration items for the server."
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
const defaultRoot = "dist";
|
|
897
|
+
var rspackCore = __webpack_require__("./src/utils/rspackCore.ts");
|
|
324
898
|
class PreviewCommand {
|
|
325
899
|
async apply(cli) {
|
|
326
|
-
cli.program.command([
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
"p"
|
|
330
|
-
], "run the rspack server for build output", previewOptions, async (options)=>{
|
|
900
|
+
const command = cli.program.command("preview [dir]", "run the Rspack server for build output").alias("p");
|
|
901
|
+
commonOptions(command).option("--public-path <path>", "static resource server path").option("--port <port>", "preview server port").option("--host <host>", "preview server host").option("--open", "open browser").option("--server <config>", "Configuration items for the server.");
|
|
902
|
+
command.action(async (dir, options)=>{
|
|
331
903
|
setDefaultNodeEnv(options, "production");
|
|
332
|
-
|
|
333
|
-
...options,
|
|
334
|
-
argv: {
|
|
335
|
-
...options
|
|
336
|
-
}
|
|
337
|
-
};
|
|
904
|
+
normalizeCommonOptions(options, "preview");
|
|
338
905
|
const { RspackDevServer } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@rspack/dev-server"));
|
|
339
|
-
let { config } = await cli.loadConfig(
|
|
340
|
-
config = await getPreviewConfig(config, options);
|
|
906
|
+
let { config } = await cli.loadConfig(options);
|
|
907
|
+
config = await getPreviewConfig(config, options, dir);
|
|
341
908
|
if (!Array.isArray(config)) config = [
|
|
342
909
|
config
|
|
343
910
|
];
|
|
344
|
-
|
|
345
|
-
const devServerOptions =
|
|
911
|
+
const singleConfig = config.find((item)=>item.devServer) || config[0];
|
|
912
|
+
const devServerOptions = singleConfig.devServer;
|
|
346
913
|
try {
|
|
347
|
-
const compiler = (0,
|
|
914
|
+
const compiler = (0, rspackCore.Z)({
|
|
348
915
|
entry: {}
|
|
349
916
|
});
|
|
350
917
|
if (!compiler) return;
|
|
@@ -358,11 +925,12 @@ var __webpack_exports__ = {};
|
|
|
358
925
|
});
|
|
359
926
|
}
|
|
360
927
|
}
|
|
361
|
-
async function getPreviewConfig(item, options) {
|
|
928
|
+
async function getPreviewConfig(item, options, dir) {
|
|
929
|
+
const DEFAULT_ROOT = "dist";
|
|
362
930
|
const internalPreviewConfig = async (item)=>{
|
|
363
931
|
item.devServer = {
|
|
364
932
|
static: {
|
|
365
|
-
directory:
|
|
933
|
+
directory: dir ? external_node_path_default().join(item.context ?? process.cwd(), dir) : item.output?.path ?? external_node_path_default().join(item.context ?? process.cwd(), DEFAULT_ROOT),
|
|
366
934
|
publicPath: options.publicPath ?? "/"
|
|
367
935
|
},
|
|
368
936
|
port: options.port ?? 8080,
|
|
@@ -377,42 +945,21 @@ var __webpack_exports__ = {};
|
|
|
377
945
|
if (Array.isArray(item)) return Promise.all(item.map(internalPreviewConfig));
|
|
378
946
|
return internalPreviewConfig(item);
|
|
379
947
|
}
|
|
948
|
+
function normalizeHotOption(value) {
|
|
949
|
+
if ("boolean" == typeof value || "only" === value) return value;
|
|
950
|
+
if ("false" === value) return false;
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
380
953
|
class ServeCommand {
|
|
381
954
|
async apply(cli) {
|
|
382
|
-
cli.program.command(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
"s",
|
|
386
|
-
"dev"
|
|
387
|
-
], "run the rspack dev server.", (yargs)=>commonOptionsForBuildAndServe(commonOptions(yargs)).options({
|
|
388
|
-
hot: {
|
|
389
|
-
coerce: (arg)=>{
|
|
390
|
-
if ("boolean" == typeof arg || "only" === arg) return arg;
|
|
391
|
-
if ("false" === arg) return false;
|
|
392
|
-
return true;
|
|
393
|
-
},
|
|
394
|
-
describe: "enables hot module replacement"
|
|
395
|
-
},
|
|
396
|
-
port: {
|
|
397
|
-
type: "number",
|
|
398
|
-
coerce: (arg)=>Number.isInteger(arg) ? arg : void 0,
|
|
399
|
-
describe: "allows to specify a port to use"
|
|
400
|
-
},
|
|
401
|
-
host: {
|
|
402
|
-
type: "string",
|
|
403
|
-
describe: "allows to specify a hostname to use"
|
|
404
|
-
}
|
|
405
|
-
}), async (options)=>{
|
|
955
|
+
const command = cli.program.command("serve", "run the rspack dev server.").alias("server").alias("s").alias("dev");
|
|
956
|
+
commonOptionsForBuildAndServe(commonOptions(command)).option("--hot [mode]", "enables hot module replacement").option("--port <port>", "allows to specify a port to use").option("--host <host>", "allows to specify a hostname to use");
|
|
957
|
+
command.action(async (options)=>{
|
|
406
958
|
setDefaultNodeEnv(options, "development");
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
...options,
|
|
410
|
-
argv: {
|
|
411
|
-
...options
|
|
412
|
-
}
|
|
413
|
-
};
|
|
959
|
+
normalizeCommonOptions(options, "serve");
|
|
960
|
+
options.hot = normalizeHotOption(options.hot);
|
|
414
961
|
const { RspackDevServer } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@rspack/dev-server"));
|
|
415
|
-
const compiler = await cli.createCompiler(
|
|
962
|
+
const compiler = await cli.createCompiler(options, "serve");
|
|
416
963
|
if (!compiler) return;
|
|
417
964
|
const compilers = cli.isMultipleCompiler(compiler) ? compiler.compilers : [
|
|
418
965
|
compiler
|
|
@@ -436,8 +983,8 @@ var __webpack_exports__ = {};
|
|
|
436
983
|
}
|
|
437
984
|
}
|
|
438
985
|
const result = compilerForDevServer.options.devServer ??= {};
|
|
439
|
-
const setupMiddlewares = result
|
|
440
|
-
const lazyCompileMiddleware =
|
|
986
|
+
const { setupMiddlewares } = result;
|
|
987
|
+
const lazyCompileMiddleware = rspackCore.Z.experiments.lazyCompilationMiddleware(compiler);
|
|
441
988
|
result.setupMiddlewares = (middlewares, server)=>{
|
|
442
989
|
let finalMiddlewares = middlewares;
|
|
443
990
|
if (setupMiddlewares) finalMiddlewares = setupMiddlewares(finalMiddlewares, server);
|
|
@@ -448,7 +995,7 @@ var __webpack_exports__ = {};
|
|
|
448
995
|
};
|
|
449
996
|
result.hot = options.hot ?? result.hot ?? true;
|
|
450
997
|
result.host = options.host || result.host;
|
|
451
|
-
result.port = options.port
|
|
998
|
+
result.port = options.port ?? result.port;
|
|
452
999
|
if (false !== result.client) {
|
|
453
1000
|
if (true === result.client || null == result.client) result.client = {};
|
|
454
1001
|
result.client = {
|
|
@@ -479,7 +1026,7 @@ var __webpack_exports__ = {};
|
|
|
479
1026
|
});
|
|
480
1027
|
}
|
|
481
1028
|
}
|
|
482
|
-
|
|
1029
|
+
var lib = __webpack_require__("../../node_modules/.pnpm/pirates@4.0.7/node_modules/pirates/lib/index.js");
|
|
483
1030
|
const external_node_url_namespaceObject = require("node:url");
|
|
484
1031
|
const readPackageUp = (cwd = process.cwd())=>{
|
|
485
1032
|
let currentDir = external_node_path_default().resolve(cwd);
|
|
@@ -535,7 +1082,7 @@ var __webpack_exports__ = {};
|
|
|
535
1082
|
return TS_EXTENSION.includes(ext);
|
|
536
1083
|
};
|
|
537
1084
|
const isTsFile = isTsFile_isTsFile;
|
|
538
|
-
const injectInlineSourceMap = ({
|
|
1085
|
+
const injectInlineSourceMap = ({ code, map })=>{
|
|
539
1086
|
if (map) {
|
|
540
1087
|
const base64Map = Buffer.from(map, "utf8").toString("base64");
|
|
541
1088
|
const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`;
|
|
@@ -544,7 +1091,7 @@ var __webpack_exports__ = {};
|
|
|
544
1091
|
return code;
|
|
545
1092
|
};
|
|
546
1093
|
function compile(sourcecode, filename) {
|
|
547
|
-
const { code, map } =
|
|
1094
|
+
const { code, map } = rspackCore.Z.experiments.swc.transformSync(sourcecode, {
|
|
548
1095
|
jsc: {
|
|
549
1096
|
parser: {
|
|
550
1097
|
syntax: "typescript",
|
|
@@ -561,7 +1108,6 @@ var __webpack_exports__ = {};
|
|
|
561
1108
|
isModule: true
|
|
562
1109
|
});
|
|
563
1110
|
return injectInlineSourceMap({
|
|
564
|
-
filename,
|
|
565
1111
|
code,
|
|
566
1112
|
map
|
|
567
1113
|
});
|
|
@@ -570,7 +1116,7 @@ var __webpack_exports__ = {};
|
|
|
570
1116
|
const registerLoader = (configPath)=>{
|
|
571
1117
|
if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
|
|
572
1118
|
if (!isTsFile(configPath)) throw new Error(`config file "${configPath}" is not supported.`);
|
|
573
|
-
(0,
|
|
1119
|
+
(0, lib.addHook)((code, filename)=>{
|
|
574
1120
|
try {
|
|
575
1121
|
return compile(code, filename);
|
|
576
1122
|
} catch (err) {
|
|
@@ -635,7 +1181,7 @@ var __webpack_exports__ = {};
|
|
|
635
1181
|
if (isTsFile(resolvedPath) && "register" === options.configLoader) registerLoader(resolvedPath);
|
|
636
1182
|
let loadedConfig = await crossImport(resolvedPath, cwd);
|
|
637
1183
|
if ("function" == typeof loadedConfig) {
|
|
638
|
-
loadedConfig = loadedConfig(options.
|
|
1184
|
+
loadedConfig = loadedConfig(options.env, options);
|
|
639
1185
|
if ("function" == typeof loadedConfig.then) loadedConfig = await loadedConfig;
|
|
640
1186
|
}
|
|
641
1187
|
const { config: extendedConfig, pathMap: extendedPathMap } = await loadExtendedConfig(loadedConfig, resolvedPath, cwd, options);
|
|
@@ -643,7 +1189,7 @@ var __webpack_exports__ = {};
|
|
|
643
1189
|
...pathMap.get(resultConfig) || [],
|
|
644
1190
|
...extendedPathMap.get(extendedConfig) || []
|
|
645
1191
|
];
|
|
646
|
-
resultConfig =
|
|
1192
|
+
resultConfig = rspackCore.Z.util.cleverMerge(extendedConfig, resultConfig);
|
|
647
1193
|
pathMap.set(resultConfig, configPaths);
|
|
648
1194
|
}
|
|
649
1195
|
return {
|
|
@@ -672,19 +1218,21 @@ var __webpack_exports__ = {};
|
|
|
672
1218
|
colors;
|
|
673
1219
|
program;
|
|
674
1220
|
constructor(){
|
|
1221
|
+
const program = dist("rspack");
|
|
675
1222
|
this.colors = this.createColors();
|
|
676
|
-
this.program =
|
|
1223
|
+
this.program = program;
|
|
1224
|
+
program.help();
|
|
1225
|
+
program.version("1.6.0-canary-beafb11e-20251017173713");
|
|
677
1226
|
}
|
|
678
1227
|
async createCompiler(options, rspackCommand, callback) {
|
|
679
|
-
process.env.RSPACK_CONFIG_VALIDATE ??= "loose";
|
|
680
1228
|
let { config, pathMap } = await this.loadConfig(options);
|
|
681
1229
|
config = await this.buildConfig(config, pathMap, options, rspackCommand);
|
|
682
1230
|
const isWatch = Array.isArray(config) ? config.some((i)=>i.watch) : config.watch;
|
|
683
1231
|
let compiler;
|
|
684
1232
|
try {
|
|
685
|
-
compiler = (0,
|
|
1233
|
+
compiler = (0, rspackCore.Z)(config, isWatch ? callback : void 0);
|
|
686
1234
|
} catch (e) {
|
|
687
|
-
if (e instanceof
|
|
1235
|
+
if (e instanceof rspackCore.Z.ValidationError) {
|
|
688
1236
|
this.getLogger().error(e.message);
|
|
689
1237
|
process.exit(2);
|
|
690
1238
|
} else if (e instanceof Error) {
|
|
@@ -697,9 +1245,9 @@ var __webpack_exports__ = {};
|
|
|
697
1245
|
return compiler;
|
|
698
1246
|
}
|
|
699
1247
|
createColors(useColor) {
|
|
700
|
-
const shouldUseColor = useColor ||
|
|
1248
|
+
const shouldUseColor = useColor || isColorSupported;
|
|
701
1249
|
return {
|
|
702
|
-
...
|
|
1250
|
+
...createColors({
|
|
703
1251
|
useColor: shouldUseColor
|
|
704
1252
|
}),
|
|
705
1253
|
isColorSupported: shouldUseColor
|
|
@@ -716,13 +1264,8 @@ var __webpack_exports__ = {};
|
|
|
716
1264
|
};
|
|
717
1265
|
}
|
|
718
1266
|
async run(argv) {
|
|
719
|
-
this.
|
|
720
|
-
this.program.
|
|
721
|
-
this.program.scriptName("rspack");
|
|
722
|
-
this.program.strictCommands(true).strict(true);
|
|
723
|
-
this.program.middleware(normalizeEnv);
|
|
724
|
-
this.registerCommands();
|
|
725
|
-
await this.program.parseAsync((0, helpers_namespaceObject.hideBin)(argv));
|
|
1267
|
+
await this.registerCommands();
|
|
1268
|
+
this.program.parse(argv);
|
|
726
1269
|
}
|
|
727
1270
|
async registerCommands() {
|
|
728
1271
|
const builtinCommands = [
|
|
@@ -730,7 +1273,7 @@ var __webpack_exports__ = {};
|
|
|
730
1273
|
new ServeCommand(),
|
|
731
1274
|
new PreviewCommand()
|
|
732
1275
|
];
|
|
733
|
-
for (const command of builtinCommands)command.apply(this);
|
|
1276
|
+
for (const command of builtinCommands)await command.apply(this);
|
|
734
1277
|
}
|
|
735
1278
|
async buildConfig(item, pathMap, options, command) {
|
|
736
1279
|
const isBuild = "build" === command;
|
|
@@ -763,8 +1306,8 @@ var __webpack_exports__ = {};
|
|
|
763
1306
|
if (void 0 === item.devtool) item.devtool = isBuild ? "source-map" : "cheap-module-source-map";
|
|
764
1307
|
if (void 0 !== options.devtool) item.devtool = options.devtool;
|
|
765
1308
|
if (isServe) {
|
|
766
|
-
const installed = (item.plugins ||= []).find((item)=>item instanceof
|
|
767
|
-
if (!installed) (item.plugins ??= []).push(new
|
|
1309
|
+
const installed = (item.plugins ||= []).find((item)=>item instanceof rspackCore.Z.ProgressPlugin);
|
|
1310
|
+
if (!installed) (item.plugins ??= []).push(new rspackCore.Z.ProgressPlugin());
|
|
768
1311
|
}
|
|
769
1312
|
const cacheOptions = item.experiments?.cache;
|
|
770
1313
|
if ("object" == typeof cacheOptions && "persistent" === cacheOptions.type) {
|
|
@@ -800,7 +1343,7 @@ var __webpack_exports__ = {};
|
|
|
800
1343
|
};
|
|
801
1344
|
let { loadedConfig, configPath } = config;
|
|
802
1345
|
if ("function" == typeof loadedConfig) {
|
|
803
|
-
let functionResult = loadedConfig(options.
|
|
1346
|
+
let functionResult = loadedConfig(options.env, options);
|
|
804
1347
|
if ("function" == typeof functionResult.then) functionResult = await functionResult;
|
|
805
1348
|
loadedConfig = functionResult;
|
|
806
1349
|
}
|