rolldown 0.10.5 → 0.11.0

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/esm/cli.mjs CHANGED
@@ -1,24 +1,528 @@
1
1
  import __node_module__ from 'node:module';
2
2
  const require = __node_module__.createRequire(import.meta.url)
3
- import { __export, arraify } from "../shared/bindingify_plugin-gPrr_HPR.mjs";
4
- import { rolldown } from "../shared/rolldown-bgokD9pg.mjs";
3
+ import { __commonJSMin, __export, __toESM, arraify } from "../shared/utils_index-DAvBTBzR.mjs";
4
+ import { rolldown } from "../shared/rolldown-RjvHfXoR.mjs";
5
+ import { colors, consola, createConsola } from "../shared/consola_36c0034f-5LhwiLE2.mjs";
5
6
  import { pathToFileURL } from "node:url";
6
7
  import { default as nodePath } from "node:path";
7
8
  import { default as process$1, env } from "node:process";
8
- import { default as parseArgs } from "mri";
9
- import { defineCommand, runMain, showUsage } from "citty";
9
+ import "node:util";
10
+ import * as tty from "node:tty";
10
11
  import { performance } from "node:perf_hooks";
11
- import { createConsola } from "consola";
12
- import { createColors } from "colorette";
13
12
 
14
- //#region src/cli/utils.ts
15
- const logger = createConsola({
16
- formatOptions:{
17
- date:false
13
+ //#region ../../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];
18
21
  }
22
+ module.exports = function(args, opts) {
23
+ args = args || [];
24
+ opts = opts || {};
25
+ var k, arr, arg, name, val, out = {_: []};
26
+ var i = 0, j = 0, idx = 0, len = args.length;
27
+ const alibi = opts.alias !== void 0;
28
+ const strict = opts.unknown !== void 0;
29
+ const defaults = opts.default !== void 0;
30
+ opts.alias = opts.alias || {};
31
+ opts.string = toArr$1(opts.string);
32
+ opts.boolean = toArr$1(opts.boolean);
33
+ if (alibi) {
34
+ for (k in opts.alias) {
35
+ arr = opts.alias[k] = toArr$1(opts.alias[k]);
36
+ for (i = 0; i < arr.length; i++) {
37
+ (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
38
+ }
39
+ }
40
+ }
41
+ for (i = opts.boolean.length; i-- > 0;) {
42
+ arr = opts.alias[opts.boolean[i]] || [];
43
+ for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
44
+ }
45
+ for (i = opts.string.length; i-- > 0;) {
46
+ arr = opts.alias[opts.string[i]] || [];
47
+ for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
48
+ }
49
+ if (defaults) {
50
+ for (k in opts.default) {
51
+ name = typeof opts.default[k];
52
+ arr = opts.alias[k] = opts.alias[k] || [];
53
+ if (opts[name] !== void 0) {
54
+ opts[name].push(k);
55
+ for (i = 0; i < arr.length; i++) {
56
+ opts[name].push(arr[i]);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ const keys = strict ? Object.keys(opts.alias) : [];
62
+ for (i = 0; i < len; i++) {
63
+ arg = args[i];
64
+ if (arg === '--') {
65
+ out._ = out._.concat(args.slice(++i));
66
+ break;
67
+ }
68
+ for (j = 0; j < arg.length; j++) {
69
+ if (arg.charCodeAt(j) !== 45) break;
70
+ }
71
+ if (j === 0) {
72
+ out._.push(arg);
73
+ } else if (arg.substring(j, j + 3) === 'no-') {
74
+ name = arg.substring(j + 3);
75
+ if (strict && !~keys.indexOf(name)) {
76
+ return opts.unknown(arg);
77
+ }
78
+ out[name] = false;
79
+ } else {
80
+ for (idx = j + 1; idx < arg.length; idx++) {
81
+ if (arg.charCodeAt(idx) === 61) break;
82
+ }
83
+ name = arg.substring(j, idx);
84
+ val = arg.substring(++idx) || i + 1 === len || ('' + args[i + 1]).charCodeAt(0) === 45 || args[++i];
85
+ arr = j === 2 ? [name] : name;
86
+ for (idx = 0; idx < arr.length; idx++) {
87
+ name = arr[idx];
88
+ if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
89
+ toVal$1(out, name, idx + 1 < arr.length || val, opts);
90
+ }
91
+ }
92
+ }
93
+ if (defaults) {
94
+ for (k in opts.default) {
95
+ if (out[k] === void 0) {
96
+ out[k] = opts.default[k];
97
+ }
98
+ }
99
+ }
100
+ if (alibi) {
101
+ for (k in out) {
102
+ arr = opts.alias[k] || [];
103
+ while (arr.length > 0) {
104
+ out[arr.shift()] = out[k];
105
+ }
106
+ }
107
+ }
108
+ return out;
109
+ };
19
110
  });
111
+
112
+ //#endregion
113
+ //#region ../../node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs
114
+ function toArray(val) {
115
+ if (Array.isArray(val)) {
116
+ return val;
117
+ }
118
+ return val === void 0 ? [] : [val];
119
+ }
120
+ function formatLineColumns(lines, linePrefix = '') {
121
+ const maxLengh = [];
122
+ for (const line of lines) {
123
+ for (const [i, element] of line.entries()) {
124
+ maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
125
+ }
126
+ }
127
+ return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? 'padStart' : 'padEnd'](maxLengh[i])).join(' ')).join('\n');
128
+ }
129
+ function resolveValue(input) {
130
+ return typeof input === 'function' ? input() : input;
131
+ }
132
+ class CLIError extends Error {
133
+ constructor(message, code) {
134
+ super(message);
135
+ this.code = code;
136
+ this.name = 'CLIError';
137
+ }
138
+ }
139
+ const NUMBER_CHAR_RE = /\d/;
140
+ const STR_SPLITTERS = ['-', '_', '/', '.'];
141
+ function isUppercase(char = '') {
142
+ if (NUMBER_CHAR_RE.test(char)) {
143
+ return void 0;
144
+ }
145
+ return char !== char.toLowerCase();
146
+ }
147
+ function splitByCase(str, separators) {
148
+ const splitters = separators ?? STR_SPLITTERS;
149
+ const parts = [];
150
+ if (!str || typeof str !== 'string') {
151
+ return parts;
152
+ }
153
+ let buff = '';
154
+ let previousUpper;
155
+ let previousSplitter;
156
+ for (const char of str) {
157
+ const isSplitter = splitters.includes(char);
158
+ if (isSplitter === true) {
159
+ parts.push(buff);
160
+ buff = '';
161
+ previousUpper = void 0;
162
+ continue;
163
+ }
164
+ const isUpper = isUppercase(char);
165
+ if (previousSplitter === false) {
166
+ if (previousUpper === false && isUpper === true) {
167
+ parts.push(buff);
168
+ buff = char;
169
+ previousUpper = isUpper;
170
+ continue;
171
+ }
172
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
173
+ const lastChar = buff.at(-1);
174
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
175
+ buff = lastChar + char;
176
+ previousUpper = isUpper;
177
+ continue;
178
+ }
179
+ }
180
+ buff += char;
181
+ previousUpper = isUpper;
182
+ previousSplitter = isSplitter;
183
+ }
184
+ parts.push(buff);
185
+ return parts;
186
+ }
187
+ function upperFirst(str) {
188
+ return str ? str[0].toUpperCase() + str.slice(1) : '';
189
+ }
190
+ function lowerFirst(str) {
191
+ return str ? str[0].toLowerCase() + str.slice(1) : '';
192
+ }
193
+ function pascalCase(str, opts) {
194
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join('') : '';
195
+ }
196
+ function camelCase(str, opts) {
197
+ return lowerFirst(pascalCase(str || '', opts));
198
+ }
199
+ function kebabCase(str, joiner) {
200
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? '-') : '';
201
+ }
202
+ function toArr(any) {
203
+ return any == void 0 ? [] : Array.isArray(any) ? any : [any];
204
+ }
205
+ function toVal(out, key, val, opts) {
206
+ let x;
207
+ const old = out[key];
208
+ 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;
209
+ out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
210
+ }
211
+ function parseRawArgs(args = [], opts = {}) {
212
+ let k;
213
+ let arr;
214
+ let arg;
215
+ let name;
216
+ let val;
217
+ const out = {_: []};
218
+ let i = 0;
219
+ let j = 0;
220
+ let idx = 0;
221
+ const len = args.length;
222
+ const alibi = opts.alias !== void 0;
223
+ const strict = opts.unknown !== void 0;
224
+ const defaults = opts.default !== void 0;
225
+ opts.alias = opts.alias || {};
226
+ opts.string = toArr(opts.string);
227
+ opts.boolean = toArr(opts.boolean);
228
+ if (alibi) {
229
+ for (k in opts.alias) {
230
+ arr = opts.alias[k] = toArr(opts.alias[k]);
231
+ for (i = 0; i < arr.length; i++) {
232
+ (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
233
+ }
234
+ }
235
+ }
236
+ for (i = opts.boolean.length; i-- > 0;) {
237
+ arr = opts.alias[opts.boolean[i]] || [];
238
+ for (j = arr.length; j-- > 0;) {
239
+ opts.boolean.push(arr[j]);
240
+ }
241
+ }
242
+ for (i = opts.string.length; i-- > 0;) {
243
+ arr = opts.alias[opts.string[i]] || [];
244
+ for (j = arr.length; j-- > 0;) {
245
+ opts.string.push(arr[j]);
246
+ }
247
+ }
248
+ if (defaults) {
249
+ for (k in opts.default) {
250
+ name = typeof opts.default[k];
251
+ arr = opts.alias[k] = opts.alias[k] || [];
252
+ if (opts[name] !== void 0) {
253
+ opts[name].push(k);
254
+ for (i = 0; i < arr.length; i++) {
255
+ opts[name].push(arr[i]);
256
+ }
257
+ }
258
+ }
259
+ }
260
+ const keys = strict ? Object.keys(opts.alias) : [];
261
+ for (i = 0; i < len; i++) {
262
+ arg = args[i];
263
+ if (arg === '--') {
264
+ out._ = out._.concat(args.slice(++i));
265
+ break;
266
+ }
267
+ for (j = 0; j < arg.length; j++) {
268
+ if (arg.charCodeAt(j) !== 45) {
269
+ break;
270
+ }
271
+ }
272
+ if (j === 0) {
273
+ out._.push(arg);
274
+ } else if (arg.substring(j, j + 3) === 'no-') {
275
+ name = arg.slice(Math.max(0, j + 3));
276
+ if (strict && !~keys.indexOf(name)) {
277
+ return opts.unknown(arg);
278
+ }
279
+ out[name] = false;
280
+ } else {
281
+ for (idx = j + 1; idx < arg.length; idx++) {
282
+ if (arg.charCodeAt(idx) === 61) {
283
+ break;
284
+ }
285
+ }
286
+ name = arg.substring(j, idx);
287
+ val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ('' + args[i + 1]).charCodeAt(0) === 45 || args[++i];
288
+ arr = j === 2 ? [name] : name;
289
+ for (idx = 0; idx < arr.length; idx++) {
290
+ name = arr[idx];
291
+ if (strict && !~keys.indexOf(name)) {
292
+ return opts.unknown('-'.repeat(j) + name);
293
+ }
294
+ toVal(out, name, idx + 1 < arr.length || val, opts);
295
+ }
296
+ }
297
+ }
298
+ if (defaults) {
299
+ for (k in opts.default) {
300
+ if (out[k] === void 0) {
301
+ out[k] = opts.default[k];
302
+ }
303
+ }
304
+ }
305
+ if (alibi) {
306
+ for (k in out) {
307
+ arr = opts.alias[k] || [];
308
+ while (arr.length > 0) {
309
+ out[arr.shift()] = out[k];
310
+ }
311
+ }
312
+ }
313
+ return out;
314
+ }
315
+ function parseArgs$1(rawArgs, argsDef) {
316
+ const parseOptions = {
317
+ boolean: [],
318
+ string: [],
319
+ mixed: [],
320
+ alias: {},
321
+ default: {}
322
+ };
323
+ const args = resolveArgs(argsDef);
324
+ for (const arg of args) {
325
+ if (arg.type === 'positional') {
326
+ continue;
327
+ }
328
+ if (arg.type === 'string') {
329
+ parseOptions.string.push(arg.name);
330
+ } else if (arg.type === 'boolean') {
331
+ parseOptions.boolean.push(arg.name);
332
+ }
333
+ if (arg.default !== void 0) {
334
+ parseOptions.default[arg.name] = arg.default;
335
+ }
336
+ if (arg.alias) {
337
+ parseOptions.alias[arg.name] = arg.alias;
338
+ }
339
+ }
340
+ const parsed = parseRawArgs(rawArgs, parseOptions);
341
+ const [ ...positionalArguments] = parsed._;
342
+ const parsedArgsProxy = new Proxy(parsed, {get(target, prop) {
343
+ return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
344
+ }});
345
+ for (const [, arg] of args.entries()) {
346
+ if (arg.type === 'positional') {
347
+ const nextPositionalArgument = positionalArguments.shift();
348
+ if (nextPositionalArgument !== void 0) {
349
+ parsedArgsProxy[arg.name] = nextPositionalArgument;
350
+ } else if (arg.default === void 0 && arg.required !== false) {
351
+ throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, 'EARG');
352
+ } else {
353
+ parsedArgsProxy[arg.name] = arg.default;
354
+ }
355
+ } else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
356
+ throw new CLIError(`Missing required argument: --${arg.name}`, 'EARG');
357
+ }
358
+ }
359
+ return parsedArgsProxy;
360
+ }
361
+ function resolveArgs(argsDef) {
362
+ const args = [];
363
+ for (const [name, argDef] of Object.entries(argsDef || {})) {
364
+ args.push({
365
+ ...argDef,
366
+ name,
367
+ alias: toArray(argDef.alias)
368
+ });
369
+ }
370
+ return args;
371
+ }
372
+ function defineCommand(def) {
373
+ return def;
374
+ }
375
+ async function runCommand(cmd, opts) {
376
+ const cmdArgs = await resolveValue(cmd.args || {});
377
+ const parsedArgs = parseArgs$1(opts.rawArgs, cmdArgs);
378
+ const context = {
379
+ rawArgs: opts.rawArgs,
380
+ args: parsedArgs,
381
+ data: opts.data,
382
+ cmd
383
+ };
384
+ if (typeof cmd.setup === 'function') {
385
+ await cmd.setup(context);
386
+ }
387
+ let result;
388
+ try {
389
+ const subCommands = await resolveValue(cmd.subCommands);
390
+ if (subCommands && Object.keys(subCommands).length > 0) {
391
+ const subCommandArgIndex = opts.rawArgs.findIndex((arg) => !arg.startsWith('-'));
392
+ const subCommandName = opts.rawArgs[subCommandArgIndex];
393
+ if (subCommandName) {
394
+ if (!subCommands[subCommandName]) {
395
+ throw new CLIError(`Unknown command \`${subCommandName}\``, 'E_UNKNOWN_COMMAND');
396
+ }
397
+ const subCommand = await resolveValue(subCommands[subCommandName]);
398
+ if (subCommand) {
399
+ await runCommand(subCommand, {rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1)});
400
+ }
401
+ } else if (!cmd.run) {
402
+ throw new CLIError(`No command specified.`, 'E_NO_COMMAND');
403
+ }
404
+ }
405
+ if (typeof cmd.run === 'function') {
406
+ result = await cmd.run(context);
407
+ }
408
+ } finally {
409
+ if (typeof cmd.cleanup === 'function') {
410
+ await cmd.cleanup(context);
411
+ }
412
+ }
413
+ return {result};
414
+ }
415
+ async function resolveSubCommand(cmd, rawArgs, parent) {
416
+ const subCommands = await resolveValue(cmd.subCommands);
417
+ if (subCommands && Object.keys(subCommands).length > 0) {
418
+ const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith('-'));
419
+ const subCommandName = rawArgs[subCommandArgIndex];
420
+ const subCommand = await resolveValue(subCommands[subCommandName]);
421
+ if (subCommand) {
422
+ return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
423
+ }
424
+ }
425
+ return [cmd, parent];
426
+ }
427
+ async function showUsage(cmd, parent) {
428
+ try {
429
+ consola.log(await renderUsage(cmd, parent) + '\n');
430
+ } catch (error) {
431
+ consola.error(error);
432
+ }
433
+ }
434
+ async function renderUsage(cmd, parent) {
435
+ const cmdMeta = await resolveValue(cmd.meta || {});
436
+ const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
437
+ const parentMeta = await resolveValue(parent?.meta || {});
438
+ const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ''}` + (cmdMeta.name || process.argv[1]);
439
+ const argLines = [];
440
+ const posLines = [];
441
+ const commandsLines = [];
442
+ const usageLine = [];
443
+ for (const arg of cmdArgs) {
444
+ if (arg.type === 'positional') {
445
+ const name = arg.name.toUpperCase();
446
+ const isRequired = arg.required !== false && arg.default === void 0;
447
+ const defaultHint = arg.default ? `="${arg.default}"` : '';
448
+ posLines.push(['`' + name + defaultHint + '`', arg.description || '', arg.valueHint ? `<${arg.valueHint}>` : '']);
449
+ usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
450
+ } else {
451
+ const isRequired = arg.required === true && arg.default === void 0;
452
+ 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 || ''}"`}` : '');
453
+ argLines.push(['`' + argStr + (isRequired ? ' (required)' : '') + '`', arg.description || '']);
454
+ if (isRequired) {
455
+ usageLine.push(argStr);
456
+ }
457
+ }
458
+ }
459
+ if (cmd.subCommands) {
460
+ const commandNames = [];
461
+ const subCommands = await resolveValue(cmd.subCommands);
462
+ for (const [name, sub] of Object.entries(subCommands)) {
463
+ const subCmd = await resolveValue(sub);
464
+ const meta = await resolveValue(subCmd?.meta);
465
+ commandsLines.push([`\`${name}\``, meta?.description || '']);
466
+ commandNames.push(name);
467
+ }
468
+ usageLine.push(commandNames.join('|'));
469
+ }
470
+ const usageLines = [];
471
+ const version$1 = cmdMeta.version || parentMeta.version;
472
+ usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version$1 ? ` v${version$1}` : '')})`), '');
473
+ const hasOptions = argLines.length > 0 || posLines.length > 0;
474
+ usageLines.push(`${colors.underline(colors.bold('USAGE'))} \`${commandName}${hasOptions ? ' [OPTIONS]' : ''} ${usageLine.join(' ')}\``, '');
475
+ if (posLines.length > 0) {
476
+ usageLines.push(colors.underline(colors.bold('ARGUMENTS')), '');
477
+ usageLines.push(formatLineColumns(posLines, ' '));
478
+ usageLines.push('');
479
+ }
480
+ if (argLines.length > 0) {
481
+ usageLines.push(colors.underline(colors.bold('OPTIONS')), '');
482
+ usageLines.push(formatLineColumns(argLines, ' '));
483
+ usageLines.push('');
484
+ }
485
+ if (commandsLines.length > 0) {
486
+ usageLines.push(colors.underline(colors.bold('COMMANDS')), '');
487
+ usageLines.push(formatLineColumns(commandsLines, ' '));
488
+ usageLines.push('', `Use \`${commandName} <command> --help\` for more information about a command.`);
489
+ }
490
+ return usageLines.filter((l) => typeof l === 'string').join('\n');
491
+ }
492
+ async function runMain(cmd, opts = {}) {
493
+ const rawArgs = opts.rawArgs || process.argv.slice(2);
494
+ const showUsage$1 = opts.showUsage || showUsage;
495
+ try {
496
+ if (rawArgs.includes('--help') || rawArgs.includes('-h')) {
497
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
498
+ process.exit(0);
499
+ } else if (rawArgs.length === 1 && rawArgs[0] === '--version') {
500
+ const meta = typeof cmd.meta === 'function' ? await cmd.meta() : await cmd.meta;
501
+ if (!meta?.version) {
502
+ throw new CLIError('No version specified', 'E_NO_VERSION');
503
+ }
504
+ consola.log(meta.version);
505
+ } else {
506
+ await runCommand(cmd, {rawArgs});
507
+ }
508
+ } catch (error) {
509
+ const isCLIError = error instanceof CLIError;
510
+ if (!isCLIError) {
511
+ consola.error(error, '\n');
512
+ }
513
+ if (isCLIError) {
514
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
515
+ }
516
+ consola.error(error.message);
517
+ process.exit(1);
518
+ }
519
+ }
520
+
521
+ //#endregion
522
+ //#region src/cli/utils.ts
523
+ const logger = createConsola({formatOptions: {date: false}});
20
524
  async function ensureConfig(configPath) {
21
- if ( !isSupportedFormat(configPath)) {
525
+ if (!isSupportedFormat(configPath)) {
22
526
  throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(',')}\` but got \`${nodePath.extname(configPath)}\``);
23
527
  }
24
528
  const fileUrl = pathToFileURL(configPath).toString();
@@ -31,33 +535,94 @@ function isSupportedFormat(configPath) {
31
535
  return SUPPORTED_CONFIG_FORMATS.includes(ext);
32
536
  }
33
537
 
538
+ //#endregion
539
+ //#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
540
+ const { env: env$1 = {}, argv = [], platform = '' } = typeof process === 'undefined' ? {} : process;
541
+ const isDisabled = 'NO_COLOR'in env$1 || argv.includes('--no-color');
542
+ const isForced = 'FORCE_COLOR'in env$1 || argv.includes('--color');
543
+ const isWindows = platform === 'win32';
544
+ const isDumbTerminal = env$1.TERM === 'dumb';
545
+ const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
546
+ const isCI = 'CI'in env$1 && ('GITHUB_ACTIONS'in env$1 || 'GITLAB_CI'in env$1 || 'CIRCLECI'in env$1);
547
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
548
+ 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));
549
+ const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
550
+ const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === '' || string === undefined) ? clearBleed(('' + string).indexOf(close, at), string, open, close, replace) : '';
551
+ const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
552
+ const colors$1 = {
553
+ reset: init(0, 0),
554
+ bold: init(1, 22, '\x1B[22m\x1B[1m'),
555
+ dim: init(2, 22, '\x1B[22m\x1B[2m'),
556
+ italic: init(3, 23),
557
+ underline: init(4, 24),
558
+ inverse: init(7, 27),
559
+ hidden: init(8, 28),
560
+ strikethrough: init(9, 29),
561
+ black: init(30, 39),
562
+ red: init(31, 39),
563
+ green: init(32, 39),
564
+ yellow: init(33, 39),
565
+ blue: init(34, 39),
566
+ magenta: init(35, 39),
567
+ cyan: init(36, 39),
568
+ white: init(37, 39),
569
+ gray: init(90, 39),
570
+ bgBlack: init(40, 49),
571
+ bgRed: init(41, 49),
572
+ bgGreen: init(42, 49),
573
+ bgYellow: init(43, 49),
574
+ bgBlue: init(44, 49),
575
+ bgMagenta: init(45, 49),
576
+ bgCyan: init(46, 49),
577
+ bgWhite: init(47, 49),
578
+ blackBright: init(90, 39),
579
+ redBright: init(91, 39),
580
+ greenBright: init(92, 39),
581
+ yellowBright: init(93, 39),
582
+ blueBright: init(94, 39),
583
+ magentaBright: init(95, 39),
584
+ cyanBright: init(96, 39),
585
+ whiteBright: init(97, 39),
586
+ bgBlackBright: init(100, 49),
587
+ bgRedBright: init(101, 49),
588
+ bgGreenBright: init(102, 49),
589
+ bgYellowBright: init(103, 49),
590
+ bgBlueBright: init(104, 49),
591
+ bgMagentaBright: init(105, 49),
592
+ bgCyanBright: init(106, 49),
593
+ bgWhiteBright: init(107, 49)
594
+ };
595
+ const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
596
+ ...colors$2,
597
+ [key]: String
598
+ }), {});
599
+ 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();
600
+
34
601
  //#endregion
35
602
  //#region src/cli/colors.ts
36
603
  var colors_ns = {};
37
604
  __export(colors_ns, {
38
- bold:() => bold,
39
- cyan:() => cyan,
40
- dim:() => dim,
41
- gray:() => gray,
42
- green:() => green,
43
- red:() => red,
44
- underline:() => underline,
45
- yellow:() => yellow
46
- });
47
- const {bold, cyan, dim, gray, green, red, underline, yellow} = createColors({
48
- useColor:env.FORCE_COLOR !== '0' && !env.NO_COLOR
605
+ bold: () => bold,
606
+ cyan: () => cyan,
607
+ dim: () => dim,
608
+ gray: () => gray,
609
+ green: () => green,
610
+ red: () => red,
611
+ underline: () => underline,
612
+ yellow: () => yellow
49
613
  });
614
+ const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({useColor: env.FORCE_COLOR !== '0' && !env.NO_COLOR});
50
615
 
51
616
  //#endregion
52
617
  //#region src/cli/commands/bundle.ts
53
618
  async function bundle(configPath) {
54
619
  const config = await ensureConfig(configPath);
55
- if ( !config) {
620
+ if (!config) {
56
621
  logger.error(`No configuration found at ${config}`);
57
622
  process.exit(1);
58
623
  }
59
624
  const configList = arraify(config);
60
- for (const config$1 of configList) {
625
+ for (const config$1 of configList) {
61
626
  await bundleInner(config$1);
62
627
  }
63
628
  }
@@ -68,7 +633,7 @@ async function bundleInner(options) {
68
633
  const endTime = performance.now();
69
634
  printBundleOutputPretty(bundleOutput);
70
635
  logger.log(``);
71
- logger.success(`Finished in ${colors_ns.bold((endTime - startTime).toFixed(2))} ms`);
636
+ logger.success(`Finished in ${bold((endTime - startTime).toFixed(2))} ms`);
72
637
  }
73
638
  function printBundleOutputPretty(output) {
74
639
  const outputEntries = collectOutputEntries(output.output);
@@ -76,16 +641,16 @@ function printBundleOutputPretty(output) {
76
641
  printOutputEntries(outputEntries, outputLayoutSizes, '<DIR>');
77
642
  }
78
643
  function collectOutputEntries(output) {
79
- return output.map(chunk => ({
80
- type:chunk.type,
81
- fileName:chunk.fileName,
82
- size:chunk.type === 'chunk' ? chunk.code.length : chunk.source.length
644
+ return output.map((chunk) => ({
645
+ type: chunk.type,
646
+ fileName: chunk.fileName,
647
+ size: chunk.type === 'chunk' ? chunk.code.length : chunk.source.length
83
648
  }));
84
649
  }
85
650
  function collectOutputLayoutAdjustmentSizes(entries) {
86
651
  let longest = 0;
87
652
  let biggestSize = 0;
88
- for (const entry of entries) {
653
+ for (const entry of entries) {
89
654
  if (entry.fileName.length > longest) {
90
655
  longest = entry.fileName.length;
91
656
  }
@@ -101,30 +666,30 @@ function collectOutputLayoutAdjustmentSizes(entries) {
101
666
  };
102
667
  }
103
668
  const numberFormatter = new Intl.NumberFormat('en', {
104
- maximumFractionDigits:2,
105
- minimumFractionDigits:2
669
+ maximumFractionDigits: 2,
670
+ minimumFractionDigits: 2
106
671
  });
107
672
  function displaySize(bytes) {
108
673
  return `${numberFormatter.format(bytes / 1000)} kB`;
109
674
  }
110
675
  const CHUNK_GROUPS = [{
111
- type:'asset',
112
- color:'green'
676
+ type: 'asset',
677
+ color: 'green'
113
678
  }, {
114
- type:'chunk',
115
- color:'cyan'
679
+ type: 'chunk',
680
+ color: 'cyan'
116
681
  },];
117
682
  function printOutputEntries(entries, sizeAdjustment, distPath) {
118
- for (const group of CHUNK_GROUPS) {
119
- const filtered = entries.filter(e => e.type === group.type);
120
- if ( !filtered.length) {
683
+ for (const group of CHUNK_GROUPS) {
684
+ const filtered = entries.filter((e) => e.type === group.type);
685
+ if (!filtered.length) {
121
686
  continue;
122
687
  }
123
- for (const entry of filtered.sort((a, z) => a.size - z.size)) {
124
- let log = colors_ns.dim(withTrailingSlash(distPath));
688
+ for (const entry of filtered.sort((a, z) => a.size - z.size)) {
689
+ let log = dim(withTrailingSlash(distPath));
125
690
  log += colors_ns[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
126
- log += colors_ns.dim(entry.type);
127
- log += colors_ns.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
691
+ log += dim(entry.type);
692
+ log += dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
128
693
  logger.log(log);
129
694
  }
130
695
  }
@@ -138,21 +703,19 @@ function withTrailingSlash(path) {
138
703
 
139
704
  //#endregion
140
705
  //#region package.json
141
- const version = '0.10.5';
706
+ const version = '0.11.0';
142
707
  const description = 'Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.';
143
708
  const keywords = ['webpack', 'parcel', 'esbuild', 'rollup', 'bundler', 'rolldown'];
144
709
  const files = ['bin', 'cli', 'dist', '!dist/*.node'];
145
710
  const napi = {
146
- 'binaryName':'rolldown-binding',
147
- 'packageName':'@rolldown/binding',
148
- 'targets':['x86_64-apple-darwin', 'x86_64-pc-windows-msvc', 'x86_64-unknown-linux-gnu', 'x86_64-unknown-linux-musl', 'i686-pc-windows-msvc', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', 'aarch64-apple-darwin', 'aarch64-unknown-linux-musl', 'aarch64-pc-windows-msvc', 'wasm32-wasip1-threads'],
149
- 'wasm':{
150
- 'initialMemory':16384,
151
- 'browser':{
152
- 'fs':true
153
- }
711
+ 'binaryName': 'rolldown-binding',
712
+ 'packageName': '@rolldown/binding',
713
+ 'targets': ['x86_64-apple-darwin', 'x86_64-pc-windows-msvc', 'x86_64-unknown-linux-gnu', 'x86_64-unknown-linux-musl', 'i686-pc-windows-msvc', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', 'aarch64-apple-darwin', 'aarch64-unknown-linux-musl', 'aarch64-pc-windows-msvc', 'wasm32-wasip1-threads'],
714
+ 'wasm': {
715
+ 'initialMemory': 16384,
716
+ 'browser': {'fs': true}
154
717
  },
155
- 'dtsHeader':'type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\n'
718
+ 'dtsHeader': 'type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\n'
156
719
  };
157
720
 
158
721
  //#endregion
@@ -161,26 +724,27 @@ const DEFAULT_CONFIG_FILENAME = 'rolldown.config.js';
161
724
 
162
725
  //#endregion
163
726
  //#region src/cli/index.ts
727
+ var import_lib_index = __toESM(require_lib_index());
164
728
  const main = defineCommand({
165
- meta:{
166
- name:'rolldown',
729
+ meta: {
730
+ name: 'rolldown',
167
731
  version,
168
732
  description
169
733
  },
170
- args:{
171
- config:{
172
- type:'string',
173
- alias:'c',
174
- description:'Use this config file (if argument is used but value is unspecified, defaults to `rolldown.config.js`)'
734
+ args: {
735
+ config: {
736
+ type: 'string',
737
+ alias: 'c',
738
+ description: 'Use this config file (if argument is used but value is unspecified, defaults to `rolldown.config.js`)'
175
739
  },
176
- help:{
177
- type:'boolean',
178
- alias:'h',
179
- description:'Show this help message'
740
+ help: {
741
+ type: 'boolean',
742
+ alias: 'h',
743
+ description: 'Show this help message'
180
744
  }
181
745
  },
182
- async run(_ctx){
183
- const parsedArgs = parseArgs(process$1.argv.slice(2));
746
+ async run(_ctx) {
747
+ const parsedArgs = (0, import_lib_index.default)(process$1.argv.slice(2));
184
748
  let argConfig = parsedArgs.c || parsedArgs.config;
185
749
  if (argConfig) {
186
750
  if (argConfig == true) {