rolldown 0.10.3 → 0.10.4

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.
Files changed (74) hide show
  1. package/dist/cjs/cli.cjs +25 -597
  2. package/dist/cjs/index.cjs +20 -9
  3. package/dist/cjs/parallel-plugin-worker.cjs +8 -3
  4. package/dist/cjs/parallel-plugin.cjs +13 -2
  5. package/dist/esm/cli.mjs +21 -596
  6. package/dist/esm/index.mjs +6 -4
  7. package/dist/esm/parallel-plugin-worker.mjs +4 -2
  8. package/dist/esm/parallel-plugin.mjs +2 -1
  9. package/dist/shared/{chunk-WMSF1LUG.cjs → chunk-eib2uzZZ.cjs} +10 -3
  10. package/dist/shared/{rolldown-7z0huS4W.mjs → rolldown-ftFKbC6A.mjs} +5 -3
  11. package/dist/shared/{rolldown-pt4wPK1i.cjs → rolldown-l_Cw2GW3.cjs} +7 -3
  12. package/dist/shared/utils_index-D-jBnBMP.cjs +1375 -0
  13. package/dist/shared/utils_index-ywWHgCJG.mjs +1406 -0
  14. package/dist/types/cli/colors.d.ts +2 -0
  15. package/dist/types/cli/commands/bundle.d.ts +1 -0
  16. package/dist/types/cli/constants.d.ts +1 -0
  17. package/dist/types/cli/index.d.ts +1 -0
  18. package/dist/types/cli/utils.d.ts +6 -0
  19. package/dist/types/index.d.ts +12 -0
  20. package/dist/types/log/logHandler.d.ts +4 -0
  21. package/dist/types/log/logger.d.ts +13 -0
  22. package/dist/types/log/logging.d.ts +14 -0
  23. package/dist/types/log/logs.d.ts +13 -0
  24. package/dist/types/options/bindingify-input-options.d.ts +4 -0
  25. package/dist/types/options/bindingify-output-options.d.ts +3 -0
  26. package/dist/types/options/input-options.d.ts +93 -0
  27. package/dist/types/options/normalized-input-options.d.ts +10 -0
  28. package/dist/types/options/normalized-output-options.d.ts +20 -0
  29. package/dist/types/options/output-options.d.ts +40 -0
  30. package/dist/types/parallel-plugin-worker.d.ts +1 -0
  31. package/dist/types/parallel-plugin.d.ts +1 -0
  32. package/dist/types/plugin/bindingify-build-hooks.d.ts +10 -0
  33. package/dist/types/plugin/bindingify-output-hooks.d.ts +10 -0
  34. package/dist/types/plugin/bindingify-plugin.d.ts +5 -0
  35. package/dist/types/plugin/index.d.ts +65 -0
  36. package/dist/types/plugin/parallel-plugin-implementation.d.ts +10 -0
  37. package/dist/types/plugin/plugin-context.d.ts +12 -0
  38. package/dist/types/plugin/plugin-driver.d.ts +4 -0
  39. package/dist/types/plugin/transfrom-plugin-context.d.ts +13 -0
  40. package/dist/types/rolldown-build.d.ts +10 -0
  41. package/dist/types/rolldown.d.ts +9 -0
  42. package/dist/types/rollup-types.d.ts +1 -0
  43. package/dist/types/types/config-export.d.ts +5 -0
  44. package/dist/types/types/module-info.d.ts +13 -0
  45. package/dist/types/types/output-bundle.d.ts +4 -0
  46. package/dist/types/types/rendered-module.d.ts +2 -0
  47. package/dist/types/types/rolldown-options.d.ts +5 -0
  48. package/dist/types/types/rolldown-output.d.ts +38 -0
  49. package/dist/types/types/sourcemap.d.ts +10 -0
  50. package/dist/types/types/utils.d.ts +7 -0
  51. package/dist/types/utils/async-flatten.d.ts +1 -0
  52. package/dist/types/utils/code-frame.d.ts +1 -0
  53. package/dist/types/utils/create-bundler.d.ts +7 -0
  54. package/dist/types/utils/define-config.d.ts +2 -0
  55. package/dist/types/utils/ensure-array.d.ts +1 -0
  56. package/dist/types/utils/index.d.ts +13 -0
  57. package/dist/types/utils/initialize-parallel-plugins.d.ts +20 -0
  58. package/dist/types/utils/normalize-hook.d.ts +5 -0
  59. package/dist/types/utils/normalize-input-options.d.ts +3 -0
  60. package/dist/types/utils/normalize-output-options.d.ts +3 -0
  61. package/dist/types/utils/normalize-plugin-option.d.ts +8 -0
  62. package/dist/types/utils/transform-module-info.d.ts +3 -0
  63. package/dist/types/utils/transform-side-effects.d.ts +3 -0
  64. package/dist/types/utils/transform-sourcemap.d.ts +1 -0
  65. package/dist/types/utils/transform-to-rollup-output.d.ts +5 -0
  66. package/dist/types/utils/type-assert.d.ts +12 -0
  67. package/dist/types/utils/zod-ext.d.ts +15 -0
  68. package/package.json +22 -22
  69. package/dist/shared/consola_36c0034f-ED9jtJgC.mjs +0 -942
  70. package/dist/shared/consola_36c0034f-RVbq7gBJ.cjs +0 -945
  71. package/dist/shared/prompt-Q6AgPcFh.cjs +0 -859
  72. package/dist/shared/prompt-uoOfg_gh.mjs +0 -860
  73. package/dist/shared/utils_index-0Q22WhZL.cjs +0 -5331
  74. package/dist/shared/utils_index-Wfcc8MjH.mjs +0 -5361
package/dist/cjs/cli.cjs CHANGED
@@ -1,535 +1,18 @@
1
- const { __commonJSMin, __export, __toESM } = require("../shared/chunk-WMSF1LUG.cjs");
2
- const { arraify } = require("../shared/utils_index-0Q22WhZL.cjs");
3
- const { rolldown } = require("../shared/rolldown-pt4wPK1i.cjs");
4
- const { colors, consola, createConsola } = require("../shared/consola_36c0034f-RVbq7gBJ.cjs");
1
+ "use strict";
2
+
3
+ const { __export, __toCommonJS, __toESM } = require("../shared/chunk-eib2uzZZ.cjs");
4
+ const { arraify } = require("../shared/utils_index-D-jBnBMP.cjs");
5
+ const { rolldown } = require("../shared/rolldown-l_Cw2GW3.cjs");
5
6
  const { pathToFileURL } = __toESM(require("node:url"));
6
7
  const { default: nodePath } = __toESM(require("node:path"));
7
8
  const { default: process$1, env } = __toESM(require("node:process"));
8
- require("node:util");
9
- require("node:tty");
9
+ const { default: parseArgs } = __toESM(require("mri"));
10
+ const { defineCommand, runMain, showUsage } = __toESM(require("citty"));
10
11
  const { performance } = __toESM(require("node:perf_hooks"));
11
- const tty = __toESM(require("tty"));
12
-
13
- // ../../node_modules/.pnpm/mri@1.2.0/node_modules/mri/lib/index.js
14
- var require_lib_index = __commonJSMin((exports, module) => {
15
- function toArr$1(any) {
16
- return any == null ? [] : Array.isArray(any) ? any : [any];
17
- }
18
- function toVal$1(out, key, val, opts) {
19
- var x, old = out[key], nxt = ! ! ~opts.string.indexOf(key) ? val == null || val === true ? '' : String(val) : typeof val === 'boolean' ? val : ! ! ~opts.boolean.indexOf(key) ? val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val), ! !val) : (x = +val,x * 0 === 0) ? x : val;
20
- (out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
21
- }
22
- module.exports = function(args, opts) {
23
- args = args || [];
24
- opts = opts || {};
25
- var k, arr, arg, name, val, out = {
26
- _:[]
27
- };
28
- var i = 0, j = 0, idx = 0, len = args.length;
29
- const alibi = opts.alias !== void 0;
30
- const strict = opts.unknown !== void 0;
31
- const defaults = opts.default !== void 0;
32
- opts.alias = opts.alias || {};
33
- (opts.string = toArr$1(opts.string));
34
- (opts.boolean = toArr$1(opts.boolean));
35
- if (alibi) {
36
- for (k in opts.alias) {
37
- arr = opts.alias[k] = toArr$1(opts.alias[k]);
38
- for (i = 0; i < arr.length; i++) {
39
- (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
40
- }
41
- }
42
- }
43
- for (i = opts.boolean.length; i-- > 0; ) {
44
- arr = opts.alias[opts.boolean[i]] || [];
45
- for (j = arr.length; j-- > 0; ) opts.boolean.push(arr[j]);
46
- }
47
- for (i = opts.string.length; i-- > 0; ) {
48
- arr = opts.alias[opts.string[i]] || [];
49
- for (j = arr.length; j-- > 0; ) opts.string.push(arr[j]);
50
- }
51
- if (defaults) {
52
- for (k in opts.default) {
53
- name = typeof opts.default[k];
54
- arr = opts.alias[k] = opts.alias[k] || [];
55
- if (opts[name] !== void 0) {
56
- opts[name].push(k);
57
- for (i = 0; i < arr.length; i++) {
58
- opts[name].push(arr[i]);
59
- }
60
- }
61
- }
62
- }
63
- const keys = strict ? Object.keys(opts.alias) : [];
64
- for (i = 0; i < len; i++) {
65
- arg = args[i];
66
- if (arg === '--') {
67
- out._ = out._.concat(args.slice( ++i));
68
- break;
69
- }
70
- for (j = 0; j < arg.length; j++) {
71
- if (arg.charCodeAt(j) !== 45) break;
72
-
73
- }
74
- if (j === 0) {
75
- out._.push(arg);
76
- } else if (arg.substring(j, j + 3) === 'no-') {
77
- name = arg.substring(j + 3);
78
- if (strict && ! ~keys.indexOf(name)) {
79
- return opts.unknown(arg);
80
- }
81
- (out[name] = false);
82
- } else {
83
- for (idx = j + 1; idx < arg.length; idx++) {
84
- if (arg.charCodeAt(idx) === 61) break;
85
-
86
- }
87
- name = arg.substring(j, idx);
88
- val = arg.substring( ++idx) || i + 1 === len || ('' + args[i + 1]).charCodeAt(0) === 45 || args[ ++i];
89
- arr = j === 2 ? [name] : name;
90
- for (idx = 0; idx < arr.length; idx++) {
91
- name = arr[idx];
92
- if (strict && ! ~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
93
-
94
- toVal$1(out, name, idx + 1 < arr.length || val, opts);
95
- }
96
- }
97
- }
98
- if (defaults) {
99
- for (k in opts.default) {
100
- if (out[k] === void 0) {
101
- (out[k] = opts.default[k]);
102
- }
103
- }
104
- }
105
- if (alibi) {
106
- for (k in out) {
107
- arr = opts.alias[k] || [];
108
- while(arr.length > 0) {
109
- (out[arr.shift()] = out[k]);
110
- }
111
- }
112
- }
113
- return out;
114
- };
115
- });
116
-
117
- // ../../node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs
118
- function toArray(val) {
119
- if (Array.isArray(val)) {
120
- return val;
121
- }
122
- return val === void 0 ? [] : [val];
123
- }
124
- function formatLineColumns(lines, linePrefix='') {
125
- const maxLengh = [];
126
- for (const line of lines) {
127
- for (const [i,element] of line.entries()) {
128
- maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
129
- }
130
- }
131
- return lines.map(l => l.map((c, i) => linePrefix + c[i === 0 ? 'padStart' : 'padEnd'](maxLengh[i])).join(' ')).join('\n');
132
- }
133
- function resolveValue(input) {
134
- return typeof input === 'function' ? input() : input;
135
- }
136
- class CLIError extends Error {
137
- constructor(message, code){
138
- super(message);
139
- this.code = code;
140
- this.name = 'CLIError';
141
- }
142
- }
143
- const NUMBER_CHAR_RE = /\d/;
144
- const STR_SPLITTERS = ['-', '_', '/', '.'];
145
- function isUppercase(char='') {
146
- if (NUMBER_CHAR_RE.test(char)) {
147
- return void 0;
148
- }
149
- return char !== char.toLowerCase();
150
- }
151
- function splitByCase(str, separators) {
152
- const splitters = separators ?? STR_SPLITTERS;
153
- const parts = [];
154
- if ( !str || typeof str !== 'string') {
155
- return parts;
156
- }
157
- let buff = '';
158
- let previousUpper;
159
- let previousSplitter;
160
- for (const char of str) {
161
- const isSplitter = splitters.includes(char);
162
- if (isSplitter === true) {
163
- parts.push(buff);
164
- buff = '';
165
- previousUpper = void 0;
166
- continue;
167
- }
168
- const isUpper = isUppercase(char);
169
- if (previousSplitter === false) {
170
- if (previousUpper === false && isUpper === true) {
171
- parts.push(buff);
172
- buff = char;
173
- previousUpper = isUpper;
174
- continue;
175
- }
176
- if (previousUpper === true && isUpper === false && buff.length > 1) {
177
- const lastChar = buff.at( -1);
178
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
179
- buff = lastChar + char;
180
- previousUpper = isUpper;
181
- continue;
182
- }
183
- }
184
- buff += char;
185
- previousUpper = isUpper;
186
- previousSplitter = isSplitter;
187
- }
188
- parts.push(buff);
189
- return parts;
190
- }
191
- function upperFirst(str) {
192
- return str ? str[0].toUpperCase() + str.slice(1) : '';
193
- }
194
- function lowerFirst(str) {
195
- return str ? str[0].toLowerCase() + str.slice(1) : '';
196
- }
197
- function pascalCase(str, opts) {
198
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map(p => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join('') : '';
199
- }
200
- function camelCase(str, opts) {
201
- return lowerFirst(pascalCase(str || '', opts));
202
- }
203
- function kebabCase(str, joiner) {
204
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map(p => p.toLowerCase()).join(joiner ?? '-') : '';
205
- }
206
- function toArr(any) {
207
- return any == void 0 ? [] : Array.isArray(any) ? any : [any];
208
- }
209
- function toVal(out, key, val, opts) {
210
- let x;
211
- const old = out[key];
212
- const nxt = ~opts.string.indexOf(key) ? val == void 0 || val === true ? '' : String(val) : typeof val === 'boolean' ? val : ~opts.boolean.indexOf(key) ? val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val), ! !val) : (x = +val,x * 0 === 0) ? x : val;
213
- (out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
214
- }
215
- function parseRawArgs(args=[], opts={}) {
216
- let k;
217
- let arr;
218
- let arg;
219
- let name;
220
- let val;
221
- const out = {
222
- _:[]
223
- };
224
- let i = 0;
225
- let j = 0;
226
- let idx = 0;
227
- const len = args.length;
228
- const alibi = opts.alias !== void 0;
229
- const strict = opts.unknown !== void 0;
230
- const defaults = opts.default !== void 0;
231
- opts.alias = opts.alias || {};
232
- (opts.string = toArr(opts.string));
233
- (opts.boolean = toArr(opts.boolean));
234
- if (alibi) {
235
- for (k in opts.alias) {
236
- arr = opts.alias[k] = toArr(opts.alias[k]);
237
- for (i = 0; i < arr.length; i++) {
238
- (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
239
- }
240
- }
241
- }
242
- for (i = opts.boolean.length; i-- > 0; ) {
243
- arr = opts.alias[opts.boolean[i]] || [];
244
- for (j = arr.length; j-- > 0; ) {
245
- opts.boolean.push(arr[j]);
246
- }
247
- }
248
- for (i = opts.string.length; i-- > 0; ) {
249
- arr = opts.alias[opts.string[i]] || [];
250
- for (j = arr.length; j-- > 0; ) {
251
- opts.string.push(arr[j]);
252
- }
253
- }
254
- if (defaults) {
255
- for (k in opts.default) {
256
- name = typeof opts.default[k];
257
- arr = opts.alias[k] = opts.alias[k] || [];
258
- if (opts[name] !== void 0) {
259
- opts[name].push(k);
260
- for (i = 0; i < arr.length; i++) {
261
- opts[name].push(arr[i]);
262
- }
263
- }
264
- }
265
- }
266
- const keys = strict ? Object.keys(opts.alias) : [];
267
- for (i = 0; i < len; i++) {
268
- arg = args[i];
269
- if (arg === '--') {
270
- out._ = out._.concat(args.slice( ++i));
271
- break;
272
- }
273
- for (j = 0; j < arg.length; j++) {
274
- if (arg.charCodeAt(j) !== 45) {
275
- break;
276
- }
277
- }
278
- if (j === 0) {
279
- out._.push(arg);
280
- } else if (arg.substring(j, j + 3) === 'no-') {
281
- name = arg.slice(Math.max(0, j + 3));
282
- if (strict && ! ~keys.indexOf(name)) {
283
- return opts.unknown(arg);
284
- }
285
- (out[name] = false);
286
- } else {
287
- for (idx = j + 1; idx < arg.length; idx++) {
288
- if (arg.charCodeAt(idx) === 61) {
289
- break;
290
- }
291
- }
292
- name = arg.substring(j, idx);
293
- val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ('' + args[i + 1]).charCodeAt(0) === 45 || args[ ++i];
294
- arr = j === 2 ? [name] : name;
295
- for (idx = 0; idx < arr.length; idx++) {
296
- name = arr[idx];
297
- if (strict && ! ~keys.indexOf(name)) {
298
- return opts.unknown('-'.repeat(j) + name);
299
- }
300
- toVal(out, name, idx + 1 < arr.length || val, opts);
301
- }
302
- }
303
- }
304
- if (defaults) {
305
- for (k in opts.default) {
306
- if (out[k] === void 0) {
307
- (out[k] = opts.default[k]);
308
- }
309
- }
310
- }
311
- if (alibi) {
312
- for (k in out) {
313
- arr = opts.alias[k] || [];
314
- while(arr.length > 0) {
315
- (out[arr.shift()] = out[k]);
316
- }
317
- }
318
- }
319
- return out;
320
- }
321
- function parseArgs$1(rawArgs, argsDef) {
322
- const parseOptions = {
323
- boolean:[],
324
- string:[],
325
- mixed:[],
326
- alias:{},
327
- default:{}
328
- };
329
- const args = resolveArgs(argsDef);
330
- for (const arg of args) {
331
- if (arg.type === 'positional') {
332
- continue;
333
- }
334
- if (arg.type === 'string') {
335
- parseOptions.string.push(arg.name);
336
- } else if (arg.type === 'boolean') {
337
- parseOptions.boolean.push(arg.name);
338
- }
339
- if (arg.default !== void 0) {
340
- parseOptions.default[arg.name] = arg.default;
341
- }
342
- if (arg.alias) {
343
- parseOptions.alias[arg.name] = arg.alias;
344
- }
345
- }
346
- const parsed = parseRawArgs(rawArgs, parseOptions);
347
- const [...positionalArguments] = parsed._;
348
- const parsedArgsProxy = new Proxy(parsed, {
349
- get(target, prop){
350
- return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
351
- }
352
- });
353
- for (const [,arg] of args.entries()) {
354
- if (arg.type === 'positional') {
355
- const nextPositionalArgument = positionalArguments.shift();
356
- if (nextPositionalArgument !== void 0) {
357
- parsedArgsProxy[arg.name] = nextPositionalArgument;
358
- } else if (arg.default === void 0 && arg.required !== false) {
359
- throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, 'EARG');
360
- } else {
361
- parsedArgsProxy[arg.name] = arg.default;
362
- }
363
- } else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
364
- throw new CLIError(`Missing required argument: --${arg.name}`, 'EARG');
365
- }
366
- }
367
- return parsedArgsProxy;
368
- }
369
- function resolveArgs(argsDef) {
370
- const args = [];
371
- for (const [name,argDef] of Object.entries(argsDef || {})) {
372
- args.push({
373
- ...argDef,
374
- name,
375
- alias:toArray(argDef.alias)
376
- });
377
- }
378
- return args;
379
- }
380
- function defineCommand(def) {
381
- return def;
382
- }
383
- async function runCommand(cmd, opts) {
384
- const cmdArgs = await resolveValue(cmd.args || {});
385
- const parsedArgs = parseArgs$1(opts.rawArgs, cmdArgs);
386
- const context = {
387
- rawArgs:opts.rawArgs,
388
- args:parsedArgs,
389
- data:opts.data,
390
- cmd
391
- };
392
- if (typeof cmd.setup === 'function') {
393
- await cmd.setup(context);
394
- }
395
- let result;
396
- try{
397
- const subCommands = await resolveValue(cmd.subCommands);
398
- if (subCommands && Object.keys(subCommands).length > 0) {
399
- const subCommandArgIndex = opts.rawArgs.findIndex(arg => !arg.startsWith('-'));
400
- const subCommandName = opts.rawArgs[subCommandArgIndex];
401
- if (subCommandName) {
402
- if ( !subCommands[subCommandName]) {
403
- throw new CLIError(`Unknown command \`${subCommandName}\``, 'E_UNKNOWN_COMMAND');
404
- }
405
- const subCommand = await resolveValue(subCommands[subCommandName]);
406
- if (subCommand) {
407
- await runCommand(subCommand, {
408
- rawArgs:opts.rawArgs.slice(subCommandArgIndex + 1)
409
- });
410
- }
411
- } else if ( !cmd.run) {
412
- throw new CLIError(`No command specified.`, 'E_NO_COMMAND');
413
- }
414
- }
415
- if (typeof cmd.run === 'function') {
416
- result = await cmd.run(context);
417
- }
418
- }finally{
419
- if (typeof cmd.cleanup === 'function') {
420
- await cmd.cleanup(context);
421
- }
422
- } return {
423
- result
424
- };
425
- }
426
- async function resolveSubCommand(cmd, rawArgs, parent) {
427
- const subCommands = await resolveValue(cmd.subCommands);
428
- if (subCommands && Object.keys(subCommands).length > 0) {
429
- const subCommandArgIndex = rawArgs.findIndex(arg => !arg.startsWith('-'));
430
- const subCommandName = rawArgs[subCommandArgIndex];
431
- const subCommand = await resolveValue(subCommands[subCommandName]);
432
- if (subCommand) {
433
- return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
434
- }
435
- }
436
- return [cmd, parent];
437
- }
438
- async function showUsage(cmd, parent) {
439
- try{
440
- consola.log(await renderUsage(cmd, parent) + '\n');
441
- }catch(error){
442
- consola.error(error);
443
- }}
444
- async function renderUsage(cmd, parent) {
445
- const cmdMeta = await resolveValue(cmd.meta || {});
446
- const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
447
- const parentMeta = await resolveValue(parent?.meta || {});
448
- const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ''}` + (cmdMeta.name || process.argv[1]);
449
- const argLines = [];
450
- const posLines = [];
451
- const commandsLines = [];
452
- const usageLine = [];
453
- for (const arg of cmdArgs) {
454
- if (arg.type === 'positional') {
455
- const name = arg.name.toUpperCase();
456
- const isRequired = arg.required !== false && arg.default === void 0;
457
- const defaultHint = arg.default ? `="${arg.default}"` : '';
458
- posLines.push(['`' + name + defaultHint + '`', arg.description || '', arg.valueHint ? `<${arg.valueHint}>` : '']);
459
- usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
460
- } else {
461
- const isRequired = arg.required === true && arg.default === void 0;
462
- const argStr = (arg.type === 'boolean' && arg.default === true ? [...(arg.alias || []).map(a => `--no-${a}`), `--no-${arg.name}`].join(', ') : [...(arg.alias || []).map(a => `-${a}`), `--${arg.name}`].join(', ')) + (arg.type === 'string' && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ''}"`}` : '');
463
- argLines.push(['`' + argStr + (isRequired ? ' (required)' : '') + '`', arg.description || '']);
464
- if (isRequired) {
465
- usageLine.push(argStr);
466
- }
467
- }
468
- }
469
- if (cmd.subCommands) {
470
- const commandNames = [];
471
- const subCommands = await resolveValue(cmd.subCommands);
472
- for (const [name,sub] of Object.entries(subCommands)) {
473
- const subCmd = await resolveValue(sub);
474
- const meta = await resolveValue(subCmd?.meta);
475
- commandsLines.push([`\`${name}\``, meta?.description || '']);
476
- commandNames.push(name);
477
- }
478
- usageLine.push(commandNames.join('|'));
479
- }
480
- const usageLines = [];
481
- const version$1 = cmdMeta.version || parentMeta.version;
482
- usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version$1 ? ` v${version$1}` : '')})`), '');
483
- const hasOptions = argLines.length > 0 || posLines.length > 0;
484
- usageLines.push(`${colors.underline(colors.bold('USAGE'))} \`${commandName}${hasOptions ? ' [OPTIONS]' : ''} ${usageLine.join(' ')}\``, '');
485
- if (posLines.length > 0) {
486
- usageLines.push(colors.underline(colors.bold('ARGUMENTS')), '');
487
- usageLines.push(formatLineColumns(posLines, ' '));
488
- usageLines.push('');
489
- }
490
- if (argLines.length > 0) {
491
- usageLines.push(colors.underline(colors.bold('OPTIONS')), '');
492
- usageLines.push(formatLineColumns(argLines, ' '));
493
- usageLines.push('');
494
- }
495
- if (commandsLines.length > 0) {
496
- usageLines.push(colors.underline(colors.bold('COMMANDS')), '');
497
- usageLines.push(formatLineColumns(commandsLines, ' '));
498
- usageLines.push('', `Use \`${commandName} <command> --help\` for more information about a command.`);
499
- }
500
- return usageLines.filter(l => typeof l === 'string').join('\n');
501
- }
502
- async function runMain(cmd, opts={}) {
503
- const rawArgs = opts.rawArgs || process.argv.slice(2);
504
- const showUsage$1 = opts.showUsage || showUsage;
505
- try{
506
- if (rawArgs.includes('--help') || rawArgs.includes('-h')) {
507
- await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
508
- process.exit(0);
509
- } else if (rawArgs.length === 1 && rawArgs[0] === '--version') {
510
- const meta = typeof cmd.meta === 'function' ? await cmd.meta() : await cmd.meta;
511
- if ( !meta?.version) {
512
- throw new CLIError('No version specified', 'E_NO_VERSION');
513
- }
514
- consola.log(meta.version);
515
- } else {
516
- await runCommand(cmd, {
517
- rawArgs
518
- });
519
- }
520
- }catch(error){
521
- const isCLIError = error instanceof CLIError;
522
- if ( !isCLIError) {
523
- consola.error(error, '\n');
524
- }
525
- if (isCLIError) {
526
- await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
527
- }
528
- consola.error(error.message);
529
- process.exit(1);
530
- }}
12
+ const { createConsola } = __toESM(require("consola"));
13
+ const { createColors } = __toESM(require("colorette"));
531
14
 
532
- // src/cli/utils.ts
15
+ //#region src/cli/utils.ts
533
16
  const logger = createConsola({
534
17
  formatOptions:{
535
18
  date:false
@@ -549,69 +32,8 @@ function isSupportedFormat(configPath) {
549
32
  return SUPPORTED_CONFIG_FORMATS.includes(ext);
550
33
  }
551
34
 
552
- // ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
553
- const {env:env$1={}, argv=[], platform=''} = typeof process === 'undefined' ? {} : process;
554
- const isDisabled = 'NO_COLOR'in env$1 || argv.includes('--no-color');
555
- const isForced = 'FORCE_COLOR'in env$1 || argv.includes('--color');
556
- const isWindows = platform === 'win32';
557
- const isDumbTerminal = env$1.TERM === 'dumb';
558
- const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
559
- const isCI = 'CI'in env$1 && ('GITHUB_ACTIONS'in env$1 || 'GITLAB_CI'in env$1 || 'CIRCLECI'in env$1);
560
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
561
- 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));
562
- const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
563
- const filterEmpty = (open, close, replace=open, at=open.length + 1) => string => string || !(string === '' || string === undefined) ? clearBleed(('' + string).indexOf(close, at), string, open, close, replace) : '';
564
- const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
565
- const colors$1 = {
566
- reset:init(0, 0),
567
- bold:init(1, 22, '\x1B[22m\x1B[1m'),
568
- dim:init(2, 22, '\x1B[22m\x1B[2m'),
569
- italic:init(3, 23),
570
- underline:init(4, 24),
571
- inverse:init(7, 27),
572
- hidden:init(8, 28),
573
- strikethrough:init(9, 29),
574
- black:init(30, 39),
575
- red:init(31, 39),
576
- green:init(32, 39),
577
- yellow:init(33, 39),
578
- blue:init(34, 39),
579
- magenta:init(35, 39),
580
- cyan:init(36, 39),
581
- white:init(37, 39),
582
- gray:init(90, 39),
583
- bgBlack:init(40, 49),
584
- bgRed:init(41, 49),
585
- bgGreen:init(42, 49),
586
- bgYellow:init(43, 49),
587
- bgBlue:init(44, 49),
588
- bgMagenta:init(45, 49),
589
- bgCyan:init(46, 49),
590
- bgWhite:init(47, 49),
591
- blackBright:init(90, 39),
592
- redBright:init(91, 39),
593
- greenBright:init(92, 39),
594
- yellowBright:init(93, 39),
595
- blueBright:init(94, 39),
596
- magentaBright:init(95, 39),
597
- cyanBright:init(96, 39),
598
- whiteBright:init(97, 39),
599
- bgBlackBright:init(100, 49),
600
- bgRedBright:init(101, 49),
601
- bgGreenBright:init(102, 49),
602
- bgYellowBright:init(103, 49),
603
- bgBlueBright:init(104, 49),
604
- bgMagentaBright:init(105, 49),
605
- bgCyanBright:init(106, 49),
606
- bgWhiteBright:init(107, 49)
607
- };
608
- const createColors = ({useColor=isColorSupported}={}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
609
- ...colors$2,
610
- [key]:String
611
- }), {});
612
- const {reset, bold:bold$1, dim:dim$1, italic, underline:underline$1, inverse, hidden, strikethrough, black, red:red$1, green:green$1, yellow:yellow$1, blue, magenta, cyan:cyan$1, white, gray:gray$1, 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();
613
-
614
- // src/cli/colors.ts
35
+ //#endregion
36
+ //#region src/cli/colors.ts
615
37
  var colors_ns = {};
616
38
  __export(colors_ns, {
617
39
  bold:() => bold,
@@ -627,7 +49,8 @@ const {bold, cyan, dim, gray, green, red, underline, yellow} = createColors({
627
49
  useColor:env.FORCE_COLOR !== '0' && !env.NO_COLOR
628
50
  });
629
51
 
630
- // src/cli/commands/bundle.ts
52
+ //#endregion
53
+ //#region src/cli/commands/bundle.ts
631
54
  async function bundle(configPath) {
632
55
  const config = await ensureConfig(configPath);
633
56
  if ( !config) {
@@ -714,8 +137,9 @@ function withTrailingSlash(path) {
714
137
  return path;
715
138
  }
716
139
 
717
- // package.json
718
- const version = '0.10.3';
140
+ //#endregion
141
+ //#region package.json
142
+ const version = '0.10.4';
719
143
  const description = 'Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.';
720
144
  const keywords = ['webpack', 'parcel', 'esbuild', 'rollup', 'bundler', 'rolldown'];
721
145
  const files = ['bin', 'cli', 'dist', '!dist/*.node'];
@@ -732,11 +156,13 @@ const napi = {
732
156
  'dtsHeader':'type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\n'
733
157
  };
734
158
 
735
- // src/cli/constants.ts
159
+ //#endregion
160
+ //#region src/cli/constants.ts
736
161
  const DEFAULT_CONFIG_FILENAME = 'rolldown.config.js';
737
162
 
738
- // src/cli/index.ts
739
- var import_lib_index = __toESM(require_lib_index());
163
+ //#endregion
164
+ //#region src/cli/index.ts
165
+ var cli_index_ns = {};
740
166
  const main = defineCommand({
741
167
  meta:{
742
168
  name:'rolldown',
@@ -756,7 +182,7 @@ const main = defineCommand({
756
182
  }
757
183
  },
758
184
  async run(_ctx){
759
- const parsedArgs = (0,import_lib_index.default)(process$1.argv.slice(2));
185
+ const parsedArgs = parseArgs(process$1.argv.slice(2));
760
186
  let argConfig = parsedArgs.c || parsedArgs.config;
761
187
  if (argConfig) {
762
188
  if (argConfig == true) {
@@ -770,3 +196,5 @@ const main = defineCommand({
770
196
  }
771
197
  });
772
198
  runMain(main);
199
+
200
+ //#endregion