@rolldown/browser 1.0.0-rc.6 → 1.0.0-rc.8

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 (46) hide show
  1. package/dist/cli.mjs +618 -196
  2. package/dist/config.d.mts +1 -1
  3. package/dist/config.mjs +9 -10
  4. package/dist/{constructors-WyngiSlS.js → constructors-BgL_dmUe.js} +2 -4
  5. package/dist/{error-D4EjR7H_.js → error-DkAP_6fk.js} +1 -6
  6. package/dist/experimental-index.browser.mjs +22 -19
  7. package/dist/experimental-index.d.mts +18 -4
  8. package/dist/experimental-index.mjs +24 -21
  9. package/dist/filter-index.d.mts +1 -1
  10. package/dist/filter-index.mjs +2 -6
  11. package/dist/get-log-filter.mjs +1 -2
  12. package/dist/index.browser.mjs +67 -73
  13. package/dist/index.d.mts +2 -2
  14. package/dist/index.mjs +9 -12
  15. package/dist/{normalize-string-or-regex-B0X1hEA4.js → normalize-string-or-regex-TtAGUp42.js} +5 -11
  16. package/dist/parallel-plugin-worker.mjs +6 -8
  17. package/dist/parallel-plugin.d.mts +1 -1
  18. package/dist/parallel-plugin.mjs +1 -2
  19. package/dist/parse-ast-index.mjs +3 -5
  20. package/dist/plugins-index.browser.mjs +3 -5
  21. package/dist/plugins-index.mjs +3 -5
  22. package/dist/rolldown-binding.wasi-browser.js +0 -1
  23. package/dist/rolldown-binding.wasi.cjs +0 -1
  24. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  25. package/dist/{rolldown-build-DwnjyX40.js → rolldown-build-Clh1p2eh.js} +446 -522
  26. package/dist/shared/{bindingify-input-options-CSIYh5O4.mjs → bindingify-input-options-CxjTlvCV.mjs} +36 -56
  27. package/dist/shared/{composable-filters-C_jBPRPI.mjs → composable-filters-B2ByPP8y.mjs} +1 -4
  28. package/dist/shared/{constructors-B2viugwd.mjs → constructors-C7Kkidxk.mjs} +2 -4
  29. package/dist/shared/{define-config-BMj_QknW.mjs → define-config-DJOr6Iwt.mjs} +1 -2
  30. package/dist/shared/{define-config-DMEhSrNE.d.mts → define-config-TEoV5q6D.d.mts} +83 -29
  31. package/dist/shared/{error-DDzqVYr_.mjs → error-CQ6njWsV.mjs} +1 -4
  32. package/dist/shared/{load-config-CmC4WvoS.mjs → load-config-Cs9h9aXF.mjs} +2 -4
  33. package/dist/shared/{logs-CCc_0vhs.mjs → logs-D80CXhvg.mjs} +5 -8
  34. package/dist/shared/{normalize-string-or-regex-FTOVR1Jb.mjs → normalize-string-or-regex-CF3Uz6aU.mjs} +2 -5
  35. package/dist/shared/{parse-DIZtKd4C.mjs → parse-DDUnGYGU.mjs} +1 -4
  36. package/dist/shared/{prompt-B56gTa4S.mjs → prompt-BYQIwEjg.mjs} +1 -3
  37. package/dist/shared/{rolldown-D7O5_axp.mjs → rolldown-D2p2QuF1.mjs} +2 -4
  38. package/dist/shared/{rolldown-build-BV90HQts.mjs → rolldown-build-D_FXM8pA.mjs} +426 -472
  39. package/dist/shared/{transform-D49mi4JH.mjs → transform-B_n5An0U.mjs} +2 -5
  40. package/dist/shared/{watch-COON6c2j.mjs → watch-BMFUc4Au.mjs} +69 -75
  41. package/dist/{transform-qJgOBSav.js → transform-UkHb5h4g.js} +2 -5
  42. package/dist/utils-index.browser.mjs +7 -16
  43. package/dist/utils-index.mjs +8 -17
  44. package/package.json +1 -1
  45. package/dist/cli-setup.d.mts +0 -1
  46. package/dist/cli-setup.mjs +0 -16
package/dist/cli.mjs CHANGED
@@ -1,17 +1,495 @@
1
- import { n as onExit, t as watch } from "./shared/watch-COON6c2j.mjs";
2
- import "./shared/normalize-string-or-regex-FTOVR1Jb.mjs";
3
- import { S as version, x as description } from "./shared/bindingify-input-options-CSIYh5O4.mjs";
4
- import { h as arraify } from "./shared/composable-filters-C_jBPRPI.mjs";
5
- import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText$1, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-BV90HQts.mjs";
6
- import "./shared/error-DDzqVYr_.mjs";
7
- import "./shared/parse-DIZtKd4C.mjs";
8
- import { t as rolldown } from "./shared/rolldown-D7O5_axp.mjs";
9
- import { t as loadConfig } from "./shared/load-config-CmC4WvoS.mjs";
1
+ import { n as onExit, t as watch } from "./shared/watch-BMFUc4Au.mjs";
2
+ import "./shared/normalize-string-or-regex-CF3Uz6aU.mjs";
3
+ import { S as version, x as description } from "./shared/bindingify-input-options-CxjTlvCV.mjs";
4
+ import { h as arraify } from "./shared/composable-filters-B2ByPP8y.mjs";
5
+ import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-D_FXM8pA.mjs";
6
+ import "./shared/error-CQ6njWsV.mjs";
7
+ import "./shared/parse-DDUnGYGU.mjs";
8
+ import { t as rolldown } from "./shared/rolldown-D2p2QuF1.mjs";
9
+ import { t as loadConfig } from "./shared/load-config-Cs9h9aXF.mjs";
10
10
  import path from "node:path";
11
- import { parseArgs } from "node:util";
12
11
  import process$1 from "node:process";
12
+ import { EventEmitter } from "events";
13
13
  import { performance } from "node:perf_hooks";
14
-
14
+ //#region ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
15
+ function toArr(any) {
16
+ return any == null ? [] : Array.isArray(any) ? any : [any];
17
+ }
18
+ function toVal(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
+ function mri2(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(opts.string);
32
+ opts.boolean = toArr(opts.boolean);
33
+ if (alibi) for (k in opts.alias) {
34
+ arr = opts.alias[k] = toArr(opts.alias[k]);
35
+ for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
36
+ }
37
+ for (i = opts.boolean.length; i-- > 0;) {
38
+ arr = opts.alias[opts.boolean[i]] || [];
39
+ for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
40
+ }
41
+ for (i = opts.string.length; i-- > 0;) {
42
+ arr = opts.alias[opts.string[i]] || [];
43
+ for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
44
+ }
45
+ if (defaults) for (k in opts.default) {
46
+ name = typeof opts.default[k];
47
+ arr = opts.alias[k] = opts.alias[k] || [];
48
+ if (opts[name] !== void 0) {
49
+ opts[name].push(k);
50
+ for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
51
+ }
52
+ }
53
+ const keys = strict ? Object.keys(opts.alias) : [];
54
+ for (i = 0; i < len; i++) {
55
+ arg = args[i];
56
+ if (arg === "--") {
57
+ out._ = out._.concat(args.slice(++i));
58
+ break;
59
+ }
60
+ for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
61
+ if (j === 0) out._.push(arg);
62
+ else if (arg.substring(j, j + 3) === "no-") {
63
+ name = arg.substring(j + 3);
64
+ if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
65
+ out[name] = false;
66
+ } else {
67
+ for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
68
+ name = arg.substring(j, idx);
69
+ val = arg.substring(++idx) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
70
+ arr = j === 2 ? [name] : name;
71
+ for (idx = 0; idx < arr.length; idx++) {
72
+ name = arr[idx];
73
+ if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
74
+ toVal(out, name, idx + 1 < arr.length || val, opts);
75
+ }
76
+ }
77
+ }
78
+ if (defaults) {
79
+ for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
80
+ }
81
+ if (alibi) for (k in out) {
82
+ arr = opts.alias[k] || [];
83
+ while (arr.length > 0) out[arr.shift()] = out[k];
84
+ }
85
+ return out;
86
+ }
87
+ const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
88
+ const findAllBrackets = (v) => {
89
+ const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
90
+ const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
91
+ const res = [];
92
+ const parse = (match) => {
93
+ let variadic = false;
94
+ let value = match[1];
95
+ if (value.startsWith("...")) {
96
+ value = value.slice(3);
97
+ variadic = true;
98
+ }
99
+ return {
100
+ required: match[0].startsWith("<"),
101
+ value,
102
+ variadic
103
+ };
104
+ };
105
+ let angledMatch;
106
+ while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(angledMatch));
107
+ let squareMatch;
108
+ while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(squareMatch));
109
+ return res;
110
+ };
111
+ const getMriOptions = (options) => {
112
+ const result = {
113
+ alias: {},
114
+ boolean: []
115
+ };
116
+ for (const [index, option] of options.entries()) {
117
+ if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
118
+ if (option.isBoolean) if (option.negated) {
119
+ if (!options.some((o, i) => {
120
+ return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
121
+ })) result.boolean.push(option.names[0]);
122
+ } else result.boolean.push(option.names[0]);
123
+ }
124
+ return result;
125
+ };
126
+ const findLongest = (arr) => {
127
+ return arr.sort((a, b) => {
128
+ return a.length > b.length ? -1 : 1;
129
+ })[0];
130
+ };
131
+ const padRight = (str, length) => {
132
+ return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
133
+ };
134
+ const camelcase = (input) => {
135
+ return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
136
+ return p1 + p2.toUpperCase();
137
+ });
138
+ };
139
+ const setDotProp = (obj, keys, val) => {
140
+ let i = 0;
141
+ let length = keys.length;
142
+ let t = obj;
143
+ let x;
144
+ for (; i < length; ++i) {
145
+ x = t[keys[i]];
146
+ t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
147
+ }
148
+ };
149
+ const setByType = (obj, transforms) => {
150
+ for (const key of Object.keys(transforms)) {
151
+ const transform = transforms[key];
152
+ if (transform.shouldTransform) {
153
+ obj[key] = Array.prototype.concat.call([], obj[key]);
154
+ if (typeof transform.transformFunction === "function") obj[key] = obj[key].map(transform.transformFunction);
155
+ }
156
+ }
157
+ };
158
+ const getFileName = (input) => {
159
+ const m = /([^\\\/]+)$/.exec(input);
160
+ return m ? m[1] : "";
161
+ };
162
+ const camelcaseOptionName = (name) => {
163
+ return name.split(".").map((v, i) => {
164
+ return i === 0 ? camelcase(v) : v;
165
+ }).join(".");
166
+ };
167
+ var CACError = class extends Error {
168
+ constructor(message) {
169
+ super(message);
170
+ this.name = this.constructor.name;
171
+ if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, this.constructor);
172
+ else this.stack = new Error(message).stack;
173
+ }
174
+ };
175
+ var Option = class {
176
+ constructor(rawName, description, config) {
177
+ this.rawName = rawName;
178
+ this.description = description;
179
+ this.config = Object.assign({}, config);
180
+ rawName = rawName.replace(/\.\*/g, "");
181
+ this.negated = false;
182
+ this.names = removeBrackets(rawName).split(",").map((v) => {
183
+ let name = v.trim().replace(/^-{1,2}/, "");
184
+ if (name.startsWith("no-")) {
185
+ this.negated = true;
186
+ name = name.replace(/^no-/, "");
187
+ }
188
+ return camelcaseOptionName(name);
189
+ }).sort((a, b) => a.length > b.length ? 1 : -1);
190
+ this.name = this.names[this.names.length - 1];
191
+ if (this.negated && this.config.default == null) this.config.default = true;
192
+ if (rawName.includes("<")) this.required = true;
193
+ else if (rawName.includes("[")) this.required = false;
194
+ else this.isBoolean = true;
195
+ }
196
+ };
197
+ const processArgs = process.argv;
198
+ const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
199
+ var Command = class {
200
+ constructor(rawName, description, config = {}, cli) {
201
+ this.rawName = rawName;
202
+ this.description = description;
203
+ this.config = config;
204
+ this.cli = cli;
205
+ this.options = [];
206
+ this.aliasNames = [];
207
+ this.name = removeBrackets(rawName);
208
+ this.args = findAllBrackets(rawName);
209
+ this.examples = [];
210
+ }
211
+ usage(text) {
212
+ this.usageText = text;
213
+ return this;
214
+ }
215
+ allowUnknownOptions() {
216
+ this.config.allowUnknownOptions = true;
217
+ return this;
218
+ }
219
+ ignoreOptionDefaultValue() {
220
+ this.config.ignoreOptionDefaultValue = true;
221
+ return this;
222
+ }
223
+ version(version, customFlags = "-v, --version") {
224
+ this.versionNumber = version;
225
+ this.option(customFlags, "Display version number");
226
+ return this;
227
+ }
228
+ example(example) {
229
+ this.examples.push(example);
230
+ return this;
231
+ }
232
+ option(rawName, description, config) {
233
+ const option = new Option(rawName, description, config);
234
+ this.options.push(option);
235
+ return this;
236
+ }
237
+ alias(name) {
238
+ this.aliasNames.push(name);
239
+ return this;
240
+ }
241
+ action(callback) {
242
+ this.commandAction = callback;
243
+ return this;
244
+ }
245
+ isMatched(name) {
246
+ return this.name === name || this.aliasNames.includes(name);
247
+ }
248
+ get isDefaultCommand() {
249
+ return this.name === "" || this.aliasNames.includes("!");
250
+ }
251
+ get isGlobalCommand() {
252
+ return this instanceof GlobalCommand;
253
+ }
254
+ hasOption(name) {
255
+ name = name.split(".")[0];
256
+ return this.options.find((option) => {
257
+ return option.names.includes(name);
258
+ });
259
+ }
260
+ outputHelp() {
261
+ const { name, commands } = this.cli;
262
+ const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
263
+ let sections = [{ body: `${name}${versionNumber ? `/${versionNumber}` : ""}` }];
264
+ sections.push({
265
+ title: "Usage",
266
+ body: ` $ ${name} ${this.usageText || this.rawName}`
267
+ });
268
+ if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
269
+ const longestCommandName = findLongest(commands.map((command) => command.rawName));
270
+ sections.push({
271
+ title: "Commands",
272
+ body: commands.map((command) => {
273
+ return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
274
+ }).join("\n")
275
+ });
276
+ sections.push({
277
+ title: `For more info, run any command with the \`--help\` flag`,
278
+ body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
279
+ });
280
+ }
281
+ let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
282
+ if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option) => option.name !== "version");
283
+ if (options.length > 0) {
284
+ const longestOptionName = findLongest(options.map((option) => option.rawName));
285
+ sections.push({
286
+ title: "Options",
287
+ body: options.map((option) => {
288
+ return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
289
+ }).join("\n")
290
+ });
291
+ }
292
+ if (this.examples.length > 0) sections.push({
293
+ title: "Examples",
294
+ body: this.examples.map((example) => {
295
+ if (typeof example === "function") return example(name);
296
+ return example;
297
+ }).join("\n")
298
+ });
299
+ if (helpCallback) sections = helpCallback(sections) || sections;
300
+ console.log(sections.map((section) => {
301
+ return section.title ? `${section.title}:
302
+ ${section.body}` : section.body;
303
+ }).join("\n\n"));
304
+ }
305
+ outputVersion() {
306
+ const { name } = this.cli;
307
+ const { versionNumber } = this.cli.globalCommand;
308
+ if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
309
+ }
310
+ checkRequiredArgs() {
311
+ const minimalArgsCount = this.args.filter((arg) => arg.required).length;
312
+ if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
313
+ }
314
+ checkUnknownOptions() {
315
+ const { options, globalCommand } = this.cli;
316
+ if (!this.config.allowUnknownOptions) {
317
+ for (const name of Object.keys(options)) if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
318
+ }
319
+ }
320
+ checkOptionValue() {
321
+ const { options: parsedOptions, globalCommand } = this.cli;
322
+ const options = [...globalCommand.options, ...this.options];
323
+ for (const option of options) {
324
+ const value = parsedOptions[option.name.split(".")[0]];
325
+ if (option.required) {
326
+ const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
327
+ if (value === true || value === false && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
328
+ }
329
+ }
330
+ }
331
+ };
332
+ var GlobalCommand = class extends Command {
333
+ constructor(cli) {
334
+ super("@@global@@", "", {}, cli);
335
+ }
336
+ };
337
+ var __assign = Object.assign;
338
+ var CAC = class extends EventEmitter {
339
+ constructor(name = "") {
340
+ super();
341
+ this.name = name;
342
+ this.commands = [];
343
+ this.rawArgs = [];
344
+ this.args = [];
345
+ this.options = {};
346
+ this.globalCommand = new GlobalCommand(this);
347
+ this.globalCommand.usage("<command> [options]");
348
+ }
349
+ usage(text) {
350
+ this.globalCommand.usage(text);
351
+ return this;
352
+ }
353
+ command(rawName, description, config) {
354
+ const command = new Command(rawName, description || "", config, this);
355
+ command.globalCommand = this.globalCommand;
356
+ this.commands.push(command);
357
+ return command;
358
+ }
359
+ option(rawName, description, config) {
360
+ this.globalCommand.option(rawName, description, config);
361
+ return this;
362
+ }
363
+ help(callback) {
364
+ this.globalCommand.option("-h, --help", "Display this message");
365
+ this.globalCommand.helpCallback = callback;
366
+ this.showHelpOnExit = true;
367
+ return this;
368
+ }
369
+ version(version, customFlags = "-v, --version") {
370
+ this.globalCommand.version(version, customFlags);
371
+ this.showVersionOnExit = true;
372
+ return this;
373
+ }
374
+ example(example) {
375
+ this.globalCommand.example(example);
376
+ return this;
377
+ }
378
+ outputHelp() {
379
+ if (this.matchedCommand) this.matchedCommand.outputHelp();
380
+ else this.globalCommand.outputHelp();
381
+ }
382
+ outputVersion() {
383
+ this.globalCommand.outputVersion();
384
+ }
385
+ setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
386
+ this.args = args;
387
+ this.options = options;
388
+ if (matchedCommand) this.matchedCommand = matchedCommand;
389
+ if (matchedCommandName) this.matchedCommandName = matchedCommandName;
390
+ return this;
391
+ }
392
+ unsetMatchedCommand() {
393
+ this.matchedCommand = void 0;
394
+ this.matchedCommandName = void 0;
395
+ }
396
+ parse(argv = processArgs, { run = true } = {}) {
397
+ this.rawArgs = argv;
398
+ if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
399
+ let shouldParse = true;
400
+ for (const command of this.commands) {
401
+ const parsed = this.mri(argv.slice(2), command);
402
+ const commandName = parsed.args[0];
403
+ if (command.isMatched(commandName)) {
404
+ shouldParse = false;
405
+ const parsedInfo = __assign(__assign({}, parsed), { args: parsed.args.slice(1) });
406
+ this.setParsedInfo(parsedInfo, command, commandName);
407
+ this.emit(`command:${commandName}`, command);
408
+ }
409
+ }
410
+ if (shouldParse) {
411
+ for (const command of this.commands) if (command.name === "") {
412
+ shouldParse = false;
413
+ const parsed = this.mri(argv.slice(2), command);
414
+ this.setParsedInfo(parsed, command);
415
+ this.emit(`command:!`, command);
416
+ }
417
+ }
418
+ if (shouldParse) {
419
+ const parsed = this.mri(argv.slice(2));
420
+ this.setParsedInfo(parsed);
421
+ }
422
+ if (this.options.help && this.showHelpOnExit) {
423
+ this.outputHelp();
424
+ run = false;
425
+ this.unsetMatchedCommand();
426
+ }
427
+ if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
428
+ this.outputVersion();
429
+ run = false;
430
+ this.unsetMatchedCommand();
431
+ }
432
+ const parsedArgv = {
433
+ args: this.args,
434
+ options: this.options
435
+ };
436
+ if (run) this.runMatchedCommand();
437
+ if (!this.matchedCommand && this.args[0]) this.emit("command:*");
438
+ return parsedArgv;
439
+ }
440
+ mri(argv, command) {
441
+ const cliOptions = [...this.globalCommand.options, ...command ? command.options : []];
442
+ const mriOptions = getMriOptions(cliOptions);
443
+ let argsAfterDoubleDashes = [];
444
+ const doubleDashesIndex = argv.indexOf("--");
445
+ if (doubleDashesIndex > -1) {
446
+ argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
447
+ argv = argv.slice(0, doubleDashesIndex);
448
+ }
449
+ let parsed = mri2(argv, mriOptions);
450
+ parsed = Object.keys(parsed).reduce((res, name) => {
451
+ return __assign(__assign({}, res), { [camelcaseOptionName(name)]: parsed[name] });
452
+ }, { _: [] });
453
+ const args = parsed._;
454
+ const options = { "--": argsAfterDoubleDashes };
455
+ const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
456
+ let transforms = Object.create(null);
457
+ for (const cliOption of cliOptions) {
458
+ if (!ignoreDefault && cliOption.config.default !== void 0) for (const name of cliOption.names) options[name] = cliOption.config.default;
459
+ if (Array.isArray(cliOption.config.type)) {
460
+ if (transforms[cliOption.name] === void 0) {
461
+ transforms[cliOption.name] = Object.create(null);
462
+ transforms[cliOption.name]["shouldTransform"] = true;
463
+ transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
464
+ }
465
+ }
466
+ }
467
+ for (const key of Object.keys(parsed)) if (key !== "_") {
468
+ setDotProp(options, key.split("."), parsed[key]);
469
+ setByType(options, transforms);
470
+ }
471
+ return {
472
+ args,
473
+ options
474
+ };
475
+ }
476
+ runMatchedCommand() {
477
+ const { args, options, matchedCommand: command } = this;
478
+ if (!command || !command.commandAction) return;
479
+ command.checkUnknownOptions();
480
+ command.checkOptionValue();
481
+ command.checkRequiredArgs();
482
+ const actionArgs = [];
483
+ command.args.forEach((arg, index) => {
484
+ if (arg.variadic) actionArgs.push(args.slice(index));
485
+ else actionArgs.push(args[index]);
486
+ });
487
+ actionArgs.push(options);
488
+ return command.commandAction.apply(this, actionArgs);
489
+ }
490
+ };
491
+ const cac = (name = "") => new CAC(name);
492
+ //#endregion
15
493
  //#region src/cli/arguments/alias.ts
16
494
  const alias = {
17
495
  config: {
@@ -33,30 +511,17 @@ const alias = {
33
511
  format: { abbreviation: "f" },
34
512
  name: { abbreviation: "n" },
35
513
  globals: { abbreviation: "g" },
36
- sourcemap: {
37
- abbreviation: "s",
38
- default: true
39
- },
514
+ sourcemap: { abbreviation: "s" },
40
515
  minify: { abbreviation: "m" },
41
516
  platform: { abbreviation: "p" },
42
517
  assetFileNames: { hint: "name" },
43
518
  chunkFileNames: { hint: "name" },
44
519
  entryFileNames: { hint: "name" },
45
- externalLiveBindings: {
46
- default: true,
47
- reverse: true
48
- },
49
- treeshake: {
50
- default: true,
51
- reverse: true
52
- },
53
- preserveEntrySignatures: {
54
- default: "strict",
55
- reverse: true
56
- },
520
+ externalLiveBindings: { reverse: true },
521
+ treeshake: { reverse: true },
522
+ preserveEntrySignatures: { reverse: true },
57
523
  moduleTypes: { hint: "types" }
58
524
  };
59
-
60
525
  //#endregion
61
526
  //#region src/cli/arguments/utils.ts
62
527
  function setNestedProperty(obj, path, value) {
@@ -77,25 +542,17 @@ function setNestedProperty(obj, path, value) {
77
542
  function camelCaseToKebabCase(str) {
78
543
  return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
79
544
  }
80
- function kebabCaseToCamelCase(str) {
81
- return str.replace(/-./g, (match) => match[1].toUpperCase());
82
- }
83
-
84
545
  //#endregion
85
546
  //#region src/cli/arguments/normalize.ts
547
+ const reservedKeys = new Set([
548
+ "help",
549
+ "version",
550
+ "config",
551
+ "watch",
552
+ "environment"
553
+ ]);
86
554
  function normalizeCliOptions(cliOptions, positionals) {
87
- const prototypePollutionKeys = [
88
- "__proto__",
89
- "constructor",
90
- "prototype"
91
- ];
92
- const unflattenedCliOptions = {};
93
- for (let [key, value] of Object.entries(cliOptions)) if (prototypePollutionKeys.includes(key)) {} else if (key.includes(".")) {
94
- const [parentKey] = key.split(".");
95
- unflattenedCliOptions[parentKey] ??= {};
96
- setNestedProperty(unflattenedCliOptions, key, value);
97
- } else unflattenedCliOptions[key] = value;
98
- const [data, errors] = validateCliOptions(unflattenedCliOptions);
555
+ const [data, errors] = validateCliOptions(cliOptions);
99
556
  if (errors?.length) {
100
557
  errors.forEach((error) => {
101
558
  logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
@@ -111,21 +568,15 @@ function normalizeCliOptions(cliOptions, positionals) {
111
568
  watch: options.watch ?? false
112
569
  };
113
570
  if (typeof options.config === "string") result.config = options.config;
571
+ else if (options.config === true) result.config = "";
114
572
  if (options.environment !== void 0) result.environment = options.environment;
115
- const keysOfInput = getInputCliKeys();
116
- const keysOfOutput = getOutputCliKeys();
117
- const reservedKeys = [
118
- "help",
119
- "version",
120
- "config",
121
- "watch",
122
- "environment"
123
- ];
573
+ const keysOfInput = new Set(getInputCliKeys());
574
+ const keysOfOutput = new Set(getOutputCliKeys());
124
575
  for (let [key, value] of Object.entries(options)) {
125
576
  const [primary] = key.split(".");
126
- if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
127
- else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
128
- else if (!reservedKeys.includes(key)) {
577
+ if (keysOfInput.has(primary)) setNestedProperty(result.input, key, value);
578
+ else if (keysOfOutput.has(primary)) setNestedProperty(result.output, key, value);
579
+ else if (!reservedKeys.has(key)) {
129
580
  logger.error(`Unknown option: ${key}`);
130
581
  process.exit(1);
131
582
  }
@@ -134,128 +585,106 @@ function normalizeCliOptions(cliOptions, positionals) {
134
585
  else result.input.input = positionals;
135
586
  return result;
136
587
  }
137
-
138
588
  //#endregion
139
589
  //#region src/cli/arguments/index.ts
140
590
  const schemaInfo = getCliSchemaInfo();
141
591
  const options = Object.fromEntries(Object.entries(schemaInfo).filter(([_key, info]) => info.type !== "never").map(([key, info]) => {
142
- const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
592
+ const config = alias[key];
593
+ let description = info?.description ?? config?.description ?? "";
594
+ if (config?.reverse) {
595
+ if (description.startsWith("enable")) description = description.replace("enable", "disable");
596
+ else if (!description.startsWith("Avoid")) description = `disable ${description}`;
597
+ }
143
598
  const result = {
144
599
  type: info.type === "boolean" ? "boolean" : "string",
145
- description: info?.description ?? config?.description ?? "",
146
- hint: config?.hint
600
+ description
147
601
  };
148
- if (config && config?.abbreviation) result.short = config?.abbreviation;
149
- if (config && config.reverse) {
150
- if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
151
- else if (!result.description.startsWith("Avoid")) result.description = `disable ${result.description}`;
152
- }
153
- key = camelCaseToKebabCase(key);
154
- return [config?.reverse ? `no-${key}` : key, result];
602
+ if (config?.abbreviation) result.short = config.abbreviation;
603
+ if (config?.hint) result.hint = config.hint;
604
+ const kebabKey = camelCaseToKebabCase(key);
605
+ return [config?.reverse ? `no-${kebabKey}` : kebabKey, result];
155
606
  }));
607
+ const knownKeys = new Set(Object.keys(schemaInfo));
608
+ for (const key of Object.keys(schemaInfo)) {
609
+ const dotIdx = key.indexOf(".");
610
+ if (dotIdx > 0) knownKeys.add(key.substring(0, dotIdx));
611
+ }
612
+ const shortAliases = /* @__PURE__ */ new Set();
613
+ for (const config of Object.values(alias)) if (config?.abbreviation) shortAliases.add(config.abbreviation);
156
614
  function parseCliArguments() {
157
- const { values, tokens, positionals } = parseArgs({
158
- options,
159
- tokens: true,
160
- allowPositionals: true,
161
- strict: false
615
+ const cli = cac("rolldown");
616
+ for (const [key, info] of Object.entries(schemaInfo)) {
617
+ if (info.type === "never") continue;
618
+ const config = alias[key];
619
+ let rawName = "";
620
+ if (config?.abbreviation) rawName += `-${config.abbreviation}, `;
621
+ if (config?.reverse) rawName += `--no-${key}`;
622
+ else rawName += `--${key}`;
623
+ if (info.type !== "boolean" && !config?.reverse) if (config?.requireValue) rawName += ` <${config?.hint ?? key}>`;
624
+ else rawName += ` [${config?.hint ?? key}]`;
625
+ cli.option(rawName, info.description ?? config?.description ?? "");
626
+ }
627
+ let parsedInput = [];
628
+ let parsedOptions = {};
629
+ const cmd = cli.command("[...input]", "");
630
+ cmd.allowUnknownOptions();
631
+ cmd.ignoreOptionDefaultValue();
632
+ cmd.action((input, opts) => {
633
+ parsedInput = input;
634
+ parsedOptions = opts;
162
635
  });
163
- let invalid_options = tokens.filter((token) => token.kind === "option").map((option) => {
164
- let negative = false;
165
- if (option.name.startsWith("no-")) {
166
- const name = kebabCaseToCamelCase(option.name.substring(3));
167
- if (name in schemaInfo) {
168
- delete values[option.name];
169
- option.name = name;
170
- negative = true;
171
- }
636
+ try {
637
+ cli.parse(process.argv, { run: true });
638
+ } catch (err) {
639
+ if (err?.name === "CACError") {
640
+ const match = err.message.match(/option `(.+?)` value is missing/);
641
+ if (match) {
642
+ const optName = match[1].replace(/ [<[].*/, "").replace(/^-\w, /, "");
643
+ logger.error(`Option \`${optName}\` requires a value but none was provided.`);
644
+ } else logger.error(err.message);
645
+ process.exit(1);
172
646
  }
173
- delete values[option.name];
174
- option.name = kebabCaseToCamelCase(option.name);
175
- let originalInfo = schemaInfo[option.name];
176
- if (!originalInfo) return {
177
- name: option.name,
178
- value: option.value
179
- };
180
- let type = originalInfo.type;
181
- if (type === "string" && typeof option.value !== "string") {
182
- let opt = option;
183
- let config = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
184
- if (config?.requireValue) {
185
- logger.error(`Option \`--${camelCaseToKebabCase(opt.name)}\` requires a value but none was provided.`);
186
- process.exit(1);
187
- }
188
- Object.defineProperty(values, opt.name, {
189
- value: config?.default ?? "",
190
- enumerable: true,
191
- configurable: true,
192
- writable: true
193
- });
194
- } else if (type === "object" && typeof option.value === "string") {
195
- const pairs = option.value.split(",").map((x) => x.split("="));
196
- if (!values[option.name]) Object.defineProperty(values, option.name, {
197
- value: {},
198
- enumerable: true,
199
- configurable: true,
200
- writable: true
201
- });
202
- for (const [key, value] of pairs) if (key && value) Object.defineProperty(values[option.name], key, {
203
- value,
204
- enumerable: true,
205
- configurable: true,
206
- writable: true
207
- });
208
- } else if (type === "array" && typeof option.value === "string") {
209
- if (!values[option.name]) Object.defineProperty(values, option.name, {
210
- value: [],
211
- enumerable: true,
212
- configurable: true,
213
- writable: true
214
- });
215
- values[option.name].push(option.value);
216
- } else if (type === "boolean") Object.defineProperty(values, option.name, {
217
- value: !negative,
218
- enumerable: true,
219
- configurable: true,
220
- writable: true
221
- });
222
- else if (type === "union") {
223
- let defaultValue = Object.getOwnPropertyDescriptor(alias, option.name)?.value;
224
- Object.defineProperty(values, option.name, {
225
- value: option.value ?? defaultValue?.default ?? "",
226
- enumerable: true,
227
- configurable: true,
228
- writable: true
229
- });
230
- } else Object.defineProperty(values, option.name, {
231
- value: option.value ?? "",
232
- enumerable: true,
233
- configurable: true,
234
- writable: true
235
- });
236
- }).filter((item) => {
237
- return item !== void 0;
238
- });
239
- invalid_options.sort((a, b) => {
240
- return a.name.localeCompare(b.name);
241
- });
242
- if (invalid_options.length !== 0) {
243
- let single = invalid_options.length === 1;
244
- logger.warn(`Option \`${invalid_options.map((item) => item.name).join(",")}\` ${single ? "is" : "are"} unrecognized. We will ignore ${single ? "this" : "those"} option${single ? "" : "s"}.`);
245
- }
246
- let rawArgs = {
247
- ...values,
248
- ...invalid_options.reduce((acc, cur) => {
249
- acc[cur.name] = cur.value;
250
- return acc;
251
- }, Object.create(null))
252
- };
647
+ throw err;
648
+ }
649
+ delete parsedOptions["--"];
650
+ for (const short of shortAliases) delete parsedOptions[short];
651
+ for (const key of Object.keys(parsedOptions)) if (key === "__proto__" || key === "constructor" || key === "prototype" || key.startsWith("__proto__.") || key.startsWith("constructor.") || key.startsWith("prototype.")) delete parsedOptions[key];
652
+ const unknownKeys = Object.keys(parsedOptions).filter((k) => !knownKeys.has(k));
653
+ if (unknownKeys.length > 0) {
654
+ unknownKeys.sort();
655
+ const single = unknownKeys.length === 1;
656
+ logger.warn(`Option \`${unknownKeys.join(",")}\` ${single ? "is" : "are"} unrecognized. We will ignore ${single ? "this" : "those"} option${single ? "" : "s"}.`);
657
+ }
658
+ const rawArgs = { ...parsedOptions };
659
+ for (const key of unknownKeys) delete parsedOptions[key];
660
+ for (const [key, value] of Object.entries(parsedOptions)) {
661
+ const type = schemaInfo[key]?.type;
662
+ if (Array.isArray(value)) {
663
+ if (type !== "array" && type !== "object") parsedOptions[key] = value[value.length - 1];
664
+ } else if (type === "array" && typeof value === "string") parsedOptions[key] = [value];
665
+ }
666
+ for (const [schemaKey, info] of Object.entries(schemaInfo)) {
667
+ if (info.type !== "object") continue;
668
+ const parts = schemaKey.split(".");
669
+ let parent = parsedOptions;
670
+ for (let i = 0; i < parts.length - 1; i++) parent = parent?.[parts[i]];
671
+ const leafKey = parts[parts.length - 1];
672
+ const value = parent?.[leafKey];
673
+ if (value === void 0) continue;
674
+ const values = Array.isArray(value) ? value : [value];
675
+ if (typeof values[0] !== "string") continue;
676
+ const result = {};
677
+ for (const v of values) for (const pair of String(v).split(",")) {
678
+ const [k, ...rest] = pair.split("=");
679
+ if (k && rest.length > 0) result[k] = rest.join("=");
680
+ }
681
+ parent[leafKey] = result;
682
+ }
253
683
  return {
254
- ...normalizeCliOptions(values, positionals),
684
+ ...normalizeCliOptions(parsedOptions, parsedInput),
255
685
  rawArgs
256
686
  };
257
687
  }
258
-
259
688
  //#endregion
260
689
  //#region src/utils/clear-screen.ts
261
690
  const CLEAR_SCREEN = "\x1Bc";
@@ -266,7 +695,6 @@ function getClearScreenFunction(options) {
266
695
  process.stdout.write(CLEAR_SCREEN);
267
696
  };
268
697
  }
269
-
270
698
  //#endregion
271
699
  //#region \0@oxc-project+runtime@0.115.0/helpers/usingCtx.js
272
700
  function _usingCtx() {
@@ -323,7 +751,6 @@ function _usingCtx() {
323
751
  }
324
752
  };
325
753
  }
326
-
327
754
  //#endregion
328
755
  //#region src/cli/commands/bundle.ts
329
756
  async function bundleWithConfig(configPath, cliOptions, rawArgs = {}) {
@@ -357,7 +784,7 @@ async function bundleWithCliOptions(cliOptions) {
357
784
  process.exit(1);
358
785
  }
359
786
  for (const file of outputs) {
360
- if (outputs.length > 1) logger.log(`\n${styleText$1(["cyan", "bold"], `|→ ${file.fileName}:`)}\n`);
787
+ if (outputs.length > 1) logger.log(`\n${styleText(["cyan", "bold"], `|→ ${file.fileName}:`)}\n`);
361
788
  console.log(file.type === "asset" ? file.source : file.code);
362
789
  }
363
790
  } catch (_) {
@@ -397,12 +824,12 @@ async function watchInner(config, cliOptions) {
397
824
  clearScreen?.();
398
825
  break;
399
826
  case "BUNDLE_START":
400
- if (changedFile.length > 0) logger.log(`Found ${styleText$1("bold", changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
827
+ if (changedFile.length > 0) logger.log(`Found ${styleText("bold", changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
401
828
  changedFile.length = 0;
402
829
  break;
403
830
  case "BUNDLE_END":
404
831
  await event.result.close();
405
- logger.success(`Rebuilt ${styleText$1("bold", relativeId(event.output[0]))} in ${styleText$1("green", ms(event.duration))}.`);
832
+ logger.success(`Rebuilt ${styleText("bold", relativeId(event.output[0]))} in ${styleText("green", ms(event.duration))}.`);
406
833
  break;
407
834
  case "ERROR":
408
835
  await event.result.close();
@@ -435,7 +862,7 @@ async function bundleInner(config, cliOptions) {
435
862
  result.forEach(printBundleOutputPretty);
436
863
  logger.log(``);
437
864
  const duration = performance.now() - startTime;
438
- logger.success(`rolldown v${version} Finished in ${styleText$1("green", ms(duration))}`);
865
+ logger.success(`rolldown v${version} Finished in ${styleText("green", ms(duration))}`);
439
866
  }
440
867
  function printBundleOutputPretty(output) {
441
868
  const outputEntries = collectOutputEntries(output.output);
@@ -481,10 +908,10 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
481
908
  const filtered = entries.filter((e) => e.type === group.type);
482
909
  if (!filtered.length) continue;
483
910
  for (const entry of filtered.sort((a, z) => a.size - z.size)) {
484
- let log = styleText$1("dim", withTrailingSlash(distPath));
485
- log += styleText$1(group.color, entry.fileName.padEnd(sizeAdjustment.longest + 2));
486
- log += styleText$1("dim", entry.type);
487
- log += styleText$1("dim", ` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
911
+ let log = styleText("dim", withTrailingSlash(distPath));
912
+ log += styleText(group.color, entry.fileName.padEnd(sizeAdjustment.longest + 2));
913
+ log += styleText("dim", entry.type);
914
+ log += styleText("dim", ` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
488
915
  logger.log(log);
489
916
  }
490
917
  }
@@ -500,7 +927,6 @@ function relativeId(id) {
500
927
  if (!path.isAbsolute(id)) return id;
501
928
  return path.relative(path.resolve(), id);
502
929
  }
503
-
504
930
  //#endregion
505
931
  //#region src/cli/commands/help.ts
506
932
  const examples = [
@@ -525,22 +951,17 @@ const examples = [
525
951
  command: "rolldown src/main.ts -d dist -n bundle -f iife -e jQuery,window._ -g jQuery=$"
526
952
  }
527
953
  ];
528
- const notes = [
529
- "Due to the API limitation, you need to pass `-s` for `.map` sourcemap file as the last argument.",
530
- "If you are using the configuration, please pass the `-c` as the last argument if you ignore the default configuration file.",
531
- "CLI options will override the configuration file.",
532
- "For more information, please visit https://rolldown.rs/."
533
- ];
954
+ const notes = ["CLI options will override the configuration file.", "For more information, please visit https://rolldown.rs/."];
534
955
  /**
535
956
  * Generates the CLI help text as a string.
536
957
  */
537
958
  function generateHelpText() {
538
959
  const lines = [];
539
- lines.push(`${styleText$1("gray", `${description} (rolldown v${version})`)}`);
960
+ lines.push(`${styleText("gray", `${description} (rolldown v${version})`)}`);
540
961
  lines.push("");
541
- lines.push(`${styleText$1(["bold", "underline"], "USAGE")} ${styleText$1("cyan", "rolldown -c <config>")} or ${styleText$1("cyan", "rolldown <input> <options>")}`);
962
+ lines.push(`${styleText(["bold", "underline"], "USAGE")} ${styleText("cyan", "rolldown -c <config>")} or ${styleText("cyan", "rolldown <input> <options>")}`);
542
963
  lines.push("");
543
- lines.push(`${styleText$1(["bold", "underline"], "OPTIONS")}`);
964
+ lines.push(`${styleText(["bold", "underline"], "OPTIONS")}`);
544
965
  lines.push("");
545
966
  lines.push(Object.entries(options).sort(([a], [b]) => {
546
967
  if (options[a].short && !options[b].short) return -1;
@@ -553,27 +974,26 @@ function generateHelpText() {
553
974
  if (short) optionStr += `-${short}, `;
554
975
  if (type === "string") optionStr += `<${hint ?? option}>`;
555
976
  if (description && description.length > 0) description = description[0].toUpperCase() + description.slice(1);
556
- return styleText$1("cyan", optionStr.padEnd(30)) + description + (description && description?.endsWith(".") ? "" : ".");
977
+ return styleText("cyan", optionStr.padEnd(30)) + description + (description && description?.endsWith(".") ? "" : ".");
557
978
  }).join("\n"));
558
979
  lines.push("");
559
- lines.push(`${styleText$1(["bold", "underline"], "EXAMPLES")}`);
980
+ lines.push(`${styleText(["bold", "underline"], "EXAMPLES")}`);
560
981
  lines.push("");
561
982
  examples.forEach(({ title, command }, ord) => {
562
983
  lines.push(` ${ord + 1}. ${title}:`);
563
- lines.push(` ${styleText$1("cyan", command)}`);
984
+ lines.push(` ${styleText("cyan", command)}`);
564
985
  lines.push("");
565
986
  });
566
- lines.push(`${styleText$1(["bold", "underline"], "NOTES")}`);
987
+ lines.push(`${styleText(["bold", "underline"], "NOTES")}`);
567
988
  lines.push("");
568
989
  notes.forEach((note) => {
569
- lines.push(` * ${styleText$1("gray", note)}`);
990
+ lines.push(` * ${styleText("gray", note)}`);
570
991
  });
571
992
  return lines.join("\n");
572
993
  }
573
994
  function showHelp() {
574
995
  logger.log(generateHelpText());
575
996
  }
576
-
577
997
  //#endregion
578
998
  //#region src/cli/version-check.ts
579
999
  function checkNodeVersion(nodeVersion) {
@@ -582,7 +1002,6 @@ function checkNodeVersion(nodeVersion) {
582
1002
  const minor = parseInt(currentVersion[1], 10);
583
1003
  return major === 20 && minor >= 19 || major === 22 && minor >= 12 || major > 22;
584
1004
  }
585
-
586
1005
  //#endregion
587
1006
  //#region src/cli/index.ts
588
1007
  if (!checkNodeVersion(process$1.versions.node)) logger.warn(`You are using Node.js ${process$1.versions.node}. Rolldown requires Node.js version 20.19+ or 22.12+. Please upgrade your Node.js version.`);
@@ -595,6 +1014,14 @@ async function main() {
595
1014
  process$1.env[key] = value.length === 0 ? String(true) : value.join(":");
596
1015
  }
597
1016
  }
1017
+ if (cliOptions.help) {
1018
+ showHelp();
1019
+ return;
1020
+ }
1021
+ if (cliOptions.version) {
1022
+ logger.log(`rolldown v${version}`);
1023
+ return;
1024
+ }
598
1025
  if (cliOptions.config || cliOptions.config === "") {
599
1026
  await bundleWithConfig(cliOptions.config, cliOptions, rawArgs);
600
1027
  return;
@@ -603,16 +1030,11 @@ async function main() {
603
1030
  await bundleWithCliOptions(cliOptions);
604
1031
  return;
605
1032
  }
606
- if (cliOptions.version) {
607
- logger.log(`rolldown v${version}`);
608
- return;
609
- }
610
1033
  showHelp();
611
1034
  }
612
1035
  main().catch((err) => {
613
1036
  logger.error(err);
614
1037
  process$1.exit(1);
615
1038
  });
616
-
617
1039
  //#endregion
618
- export { };
1040
+ export {};