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