@voidzero-dev/vite-plus-core 0.1.1 → 0.1.3

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 (90) hide show
  1. package/dist/rolldown/cli.mjs +11 -22
  2. package/dist/rolldown/config.d.mts +1 -2
  3. package/dist/rolldown/config.mjs +10 -11
  4. package/dist/rolldown/experimental-index.d.mts +20 -6
  5. package/dist/rolldown/experimental-index.mjs +24 -22
  6. package/dist/rolldown/filter-index.d.mts +1 -2
  7. package/dist/rolldown/filter-index.mjs +2 -8
  8. package/dist/rolldown/get-log-filter.mjs +1 -2
  9. package/dist/rolldown/index.d.mts +3 -3
  10. package/dist/rolldown/index.mjs +10 -13
  11. package/dist/rolldown/parallel-plugin-worker.mjs +7 -9
  12. package/dist/rolldown/parallel-plugin.d.mts +1 -2
  13. package/dist/rolldown/parallel-plugin.mjs +1 -2
  14. package/dist/rolldown/parse-ast-index.d.mts +1 -1
  15. package/dist/rolldown/parse-ast-index.mjs +4 -6
  16. package/dist/rolldown/plugins-index.d.mts +3 -3
  17. package/dist/rolldown/plugins-index.mjs +4 -6
  18. package/dist/rolldown/shared/{binding-C4ZlFAt6.d.mts → binding-BohGL_65.d.mts} +10 -5
  19. package/dist/rolldown/shared/{binding-Bd04_f8P.mjs → binding-COZdHtee.mjs} +7 -16
  20. package/dist/rolldown/shared/{bindingify-input-options-ffqkmT9z.mjs → bindingify-input-options-DdW_FOGG.mjs} +33 -56
  21. package/dist/rolldown/shared/{constructors-C5a55nbY.mjs → constructors-CQlws1EK.mjs} +2 -4
  22. package/dist/rolldown/shared/{constructors-cPsD1J5w.d.mts → constructors-ColrbLxz.d.mts} +2 -2
  23. package/dist/rolldown/shared/{define-config-DX_4SBzo.d.mts → define-config-BqZZMLjO.d.mts} +66 -30
  24. package/dist/rolldown/shared/{define-config-BMj_QknW.mjs → define-config-DJOr6Iwt.mjs} +1 -2
  25. package/dist/rolldown/shared/{error-BYPsvVEN.mjs → error-FTNambir.mjs} +3 -8
  26. package/dist/rolldown/shared/{load-config-Oj1-3DPg.mjs → load-config-DBRCgd9m.mjs} +2 -4
  27. package/dist/rolldown/shared/{logs-CCc_0vhs.mjs → logs-D80CXhvg.mjs} +5 -8
  28. package/dist/rolldown/shared/{misc-Xty885dB.mjs → misc-DJYbNKZX.mjs} +1 -2
  29. package/dist/rolldown/shared/{normalize-string-or-regex-DoNa0azR.mjs → normalize-string-or-regex-CJTjKt5t.mjs} +3 -6
  30. package/dist/rolldown/shared/{parse-Wj8OTS4w.mjs → parse-q7gzDQmi.mjs} +2 -5
  31. package/dist/rolldown/shared/{prompt-CmNr0AI-.mjs → prompt-DZIXsnf9.mjs} +1 -3
  32. package/dist/rolldown/shared/{rolldown-y9H0nYAD.mjs → rolldown-BJMdRJb1.mjs} +2 -4
  33. package/dist/rolldown/shared/{rolldown-build-DkOWV5Vu.mjs → rolldown-build-DKv2K096.mjs} +424 -473
  34. package/dist/rolldown/shared/{transform-DoG7c5_r.d.mts → transform-BoJxrM-e.d.mts} +1 -1
  35. package/dist/rolldown/shared/{transform-D55YcCvB.mjs → transform-CQppMqL8.mjs} +3 -6
  36. package/dist/rolldown/shared/{watch-Cn-znpX_.mjs → watch-BeMWbIuq.mjs} +71 -77
  37. package/dist/rolldown/utils-index.d.mts +2 -2
  38. package/dist/rolldown/utils-index.mjs +9 -18
  39. package/dist/tsdown/{build-BjQ7Rt90-tMPZTflz.js → build-TmLngPCw-CBoVPzkZ.js} +312 -324
  40. package/dist/tsdown/build-gOkJM1H9-D9ngUBpk.js +5 -0
  41. package/dist/tsdown/{chunk-CdeBBKNj.js → chunk-CSNpwdVU.js} +13 -23
  42. package/dist/tsdown/{debug-BUVkFfEZ-D3UMJnif.js → debug-tOJ_PtrM-C-Do1Twv.js} +4 -6
  43. package/dist/tsdown/{detect-CCATtVj7-DhvBg5EF.js → detect-DK-FDZQ9-CHuRhyUG.js} +2 -4
  44. package/dist/tsdown/{dist-CFTDWtv2.js → dist-Ba2DZx1w.js} +7 -7
  45. package/dist/tsdown/{dist-DNcnO8LL.js → dist-DCol2bGA.js} +503 -568
  46. package/dist/tsdown/{dist-kuoe97DJ.js → dist-_l70jCqI.js} +1 -2
  47. package/dist/tsdown/{filename-CPj0AKvV.js → filename-BDcjeHGl.js} +3 -5
  48. package/dist/tsdown/{index-node-ShM0x2b6-Bt7Chc0I.js → index-node-Djp92Gzb-B-AUHI4t.js} +2 -4
  49. package/dist/tsdown/index-types.d.ts +180 -29
  50. package/dist/tsdown/index.js +7 -9
  51. package/dist/tsdown/{main-B3qcLRNf.js → main-DYgM-9Cb.js} +71 -83
  52. package/dist/tsdown/{node-Ba_UB_xO.js → node-B3Gdtau1.js} +1 -4
  53. package/dist/tsdown/npm_cjs_chunk_chunk.cjs +6 -8
  54. package/dist/tsdown/npm_cjs_chunk_lt.cjs +28 -0
  55. package/dist/tsdown/npm_cjs_chunk_range.cjs +22 -49
  56. package/dist/tsdown/npm_cjs_chunk_semver.cjs +54 -66
  57. package/dist/tsdown/npm_entry_picomatch.cjs +18 -30
  58. package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +3 -7
  59. package/dist/tsdown/npm_entry_semver_functions_lt.cjs +5 -0
  60. package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +5 -7
  61. package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +5 -7
  62. package/dist/tsdown/npm_entry_tree-kill.cjs +2 -6
  63. package/dist/tsdown/{resolver-j7HY1N36-DHVsN9q6.js → resolver-CdD-yT15-3eaymYLw.js} +3 -5
  64. package/dist/tsdown/run.js +209 -74
  65. package/dist/tsdown/{tsc-CBjlgM2A.js → tsc-CberiTDq.js} +64 -71
  66. package/dist/tsdown/{tsc-context-D1h5oZB8.js → tsc-context-DiIjfXAG.js} +3 -5
  67. package/dist/vite/client/client.mjs +4 -19
  68. package/dist/vite/client/env.mjs +1 -2
  69. package/dist/vite/node/chunks/build.js +2 -3
  70. package/dist/vite/node/chunks/build2.js +91 -243
  71. package/dist/vite/node/chunks/chunk.js +7 -13
  72. package/dist/vite/node/chunks/config.js +2 -3
  73. package/dist/vite/node/chunks/dist.js +27 -61
  74. package/dist/vite/node/chunks/dist2.js +11 -95
  75. package/dist/vite/node/chunks/lib.js +1 -7
  76. package/dist/vite/node/chunks/logger.js +3 -8
  77. package/dist/vite/node/chunks/node.js +137 -428
  78. package/dist/vite/node/chunks/optimizer.js +2 -3
  79. package/dist/vite/node/chunks/postcss-import.js +1 -13
  80. package/dist/vite/node/chunks/preview.js +2 -3
  81. package/dist/vite/node/chunks/server.js +2 -3
  82. package/dist/vite/node/cli.js +1 -4
  83. package/dist/vite/node/index.d.ts +2 -2
  84. package/dist/vite/node/index.js +1 -2
  85. package/dist/vite/node/internal.js +1 -2
  86. package/dist/vite/node/module-runner.js +44 -3
  87. package/package.json +15 -11
  88. package/dist/rolldown/cli-setup.d.mts +0 -1
  89. package/dist/rolldown/cli-setup.mjs +0 -17
  90. package/dist/tsdown/build-2oRq4mfQ-YC_gzK3u.js +0 -6
@@ -1,13 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { S as dim, l as globalLogger, r as version, t as K } from "./main-B3qcLRNf.js";
3
- import "./node-Ba_UB_xO.js";
4
- import { t as enableDebug } from "./debug-BUVkFfEZ-D3UMJnif.js";
5
- import module from "node:module";
2
+ import { c as globalLogger, f as dim, g as yellow, r as version, t as K } from "./main-DYgM-9Cb.js";
3
+ import "./node-B3Gdtau1.js";
4
+ import { t as enableDebug } from "./debug-tOJ_PtrM-C-Do1Twv.js";
5
+ import module, { createRequire } from "node:module";
6
6
  import process$1 from "node:process";
7
7
  import { VERSION } from "@voidzero-dev/vite-plus-core/rolldown";
8
- import { EventEmitter } from "events";
9
-
10
- //#region ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
8
+ //#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
11
9
  function toArr(any) {
12
10
  return any == null ? [] : Array.isArray(any) ? any : [any];
13
11
  }
@@ -15,7 +13,7 @@ function toVal(out, key, val, opts) {
15
13
  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;
16
14
  out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
17
15
  }
18
- function mri2(args, opts) {
16
+ function lib_default(args, opts) {
19
17
  args = args || [];
20
18
  opts = opts || {};
21
19
  var k, arr, arg, name, val, out = { _: [] };
@@ -80,8 +78,10 @@ function mri2(args, opts) {
80
78
  }
81
79
  return out;
82
80
  }
83
- const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
84
- const findAllBrackets = (v) => {
81
+ function removeBrackets(v) {
82
+ return v.replace(/[<[].+/, "").trim();
83
+ }
84
+ function findAllBrackets(v) {
85
85
  const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
86
86
  const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
87
87
  const res = [];
@@ -103,8 +103,8 @@ const findAllBrackets = (v) => {
103
103
  let squareMatch;
104
104
  while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(squareMatch));
105
105
  return res;
106
- };
107
- const getMriOptions = (options) => {
106
+ }
107
+ function getMriOptions(options) {
108
108
  const result = {
109
109
  alias: {},
110
110
  boolean: []
@@ -118,62 +118,76 @@ const getMriOptions = (options) => {
118
118
  } else result.boolean.push(option.names[0]);
119
119
  }
120
120
  return result;
121
- };
122
- const findLongest = (arr) => {
121
+ }
122
+ function findLongest(arr) {
123
123
  return arr.sort((a, b) => {
124
124
  return a.length > b.length ? -1 : 1;
125
125
  })[0];
126
- };
127
- const padRight = (str, length) => {
126
+ }
127
+ function padRight(str, length) {
128
128
  return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
129
- };
130
- const camelcase = (input) => {
131
- return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
129
+ }
130
+ function camelcase(input) {
131
+ return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2) => {
132
132
  return p1 + p2.toUpperCase();
133
133
  });
134
- };
135
- const setDotProp = (obj, keys, val) => {
136
- let i = 0;
137
- let length = keys.length;
138
- let t = obj;
139
- let x;
140
- for (; i < length; ++i) {
141
- x = t[keys[i]];
142
- t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
134
+ }
135
+ function setDotProp(obj, keys, val) {
136
+ let current = obj;
137
+ for (let i = 0; i < keys.length; i++) {
138
+ const key = keys[i];
139
+ if (i === keys.length - 1) {
140
+ current[key] = val;
141
+ return;
142
+ }
143
+ if (current[key] == null) {
144
+ const nextKeyIsArrayIndex = +keys[i + 1] > -1;
145
+ current[key] = nextKeyIsArrayIndex ? [] : {};
146
+ }
147
+ current = current[key];
143
148
  }
144
- };
145
- const setByType = (obj, transforms) => {
149
+ }
150
+ function setByType(obj, transforms) {
146
151
  for (const key of Object.keys(transforms)) {
147
152
  const transform = transforms[key];
148
153
  if (transform.shouldTransform) {
149
- obj[key] = Array.prototype.concat.call([], obj[key]);
154
+ obj[key] = [obj[key]].flat();
150
155
  if (typeof transform.transformFunction === "function") obj[key] = obj[key].map(transform.transformFunction);
151
156
  }
152
157
  }
153
- };
154
- const getFileName = (input) => {
155
- const m = /([^\\\/]+)$/.exec(input);
158
+ }
159
+ function getFileName(input) {
160
+ const m = /([^\\/]+)$/.exec(input);
156
161
  return m ? m[1] : "";
157
- };
158
- const camelcaseOptionName = (name) => {
162
+ }
163
+ function camelcaseOptionName(name) {
159
164
  return name.split(".").map((v, i) => {
160
165
  return i === 0 ? camelcase(v) : v;
161
166
  }).join(".");
162
- };
167
+ }
163
168
  var CACError = class extends Error {
164
169
  constructor(message) {
165
170
  super(message);
166
- this.name = this.constructor.name;
167
- if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, this.constructor);
168
- else this.stack = new Error(message).stack;
171
+ this.name = "CACError";
172
+ if (typeof Error.captureStackTrace !== "function") this.stack = new Error(message).stack;
169
173
  }
170
174
  };
171
175
  var Option = class {
176
+ rawName;
177
+ description;
178
+ /** Option name */
179
+ name;
180
+ /** Option name and aliases */
181
+ names;
182
+ isBoolean;
183
+ required;
184
+ config;
185
+ negated;
172
186
  constructor(rawName, description, config) {
173
187
  this.rawName = rawName;
174
188
  this.description = description;
175
189
  this.config = Object.assign({}, config);
176
- rawName = rawName.replace(/\.\*/g, "");
190
+ rawName = rawName.replaceAll(".*", "");
177
191
  this.negated = false;
178
192
  this.names = removeBrackets(rawName).split(",").map((v) => {
179
193
  let name = v.trim().replace(/^-{1,2}/, "");
@@ -183,16 +197,39 @@ var Option = class {
183
197
  }
184
198
  return camelcaseOptionName(name);
185
199
  }).sort((a, b) => a.length > b.length ? 1 : -1);
186
- this.name = this.names[this.names.length - 1];
200
+ this.name = this.names.at(-1);
187
201
  if (this.negated && this.config.default == null) this.config.default = true;
188
202
  if (rawName.includes("<")) this.required = true;
189
203
  else if (rawName.includes("[")) this.required = false;
190
204
  else this.isBoolean = true;
191
205
  }
192
206
  };
193
- const processArgs = process.argv;
194
- const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
207
+ let runtimeProcessArgs;
208
+ let runtimeInfo;
209
+ if (typeof process !== "undefined") {
210
+ let runtimeName;
211
+ if (typeof Deno !== "undefined" && typeof Deno.version?.deno === "string") runtimeName = "deno";
212
+ else if (typeof Bun !== "undefined" && typeof Bun.version === "string") runtimeName = "bun";
213
+ else runtimeName = "node";
214
+ runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
215
+ runtimeProcessArgs = process.argv;
216
+ } else if (typeof navigator === "undefined") runtimeInfo = `unknown`;
217
+ else runtimeInfo = `${navigator.platform} ${navigator.userAgent}`;
195
218
  var Command = class {
219
+ rawName;
220
+ description;
221
+ config;
222
+ cli;
223
+ options;
224
+ aliasNames;
225
+ name;
226
+ args;
227
+ commandAction;
228
+ usageText;
229
+ versionNumber;
230
+ examples;
231
+ helpCallback;
232
+ globalCommand;
196
233
  constructor(rawName, description, config = {}, cli) {
197
234
  this.rawName = rawName;
198
235
  this.description = description;
@@ -225,6 +262,12 @@ var Command = class {
225
262
  this.examples.push(example);
226
263
  return this;
227
264
  }
265
+ /**
266
+ * Add a option for this command
267
+ * @param rawName Raw option name(s)
268
+ * @param description Option description
269
+ * @param config Option config
270
+ */
228
271
  option(rawName, description, config) {
229
272
  const option = new Option(rawName, description, config);
230
273
  this.options.push(option);
@@ -238,6 +281,10 @@ var Command = class {
238
281
  this.commandAction = callback;
239
282
  return this;
240
283
  }
284
+ /**
285
+ * Check if a command name is matched by this command
286
+ * @param name Command name
287
+ */
241
288
  isMatched(name) {
242
289
  return this.name === name || this.aliasNames.includes(name);
243
290
  }
@@ -247,6 +294,10 @@ var Command = class {
247
294
  get isGlobalCommand() {
248
295
  return this instanceof GlobalCommand;
249
296
  }
297
+ /**
298
+ * Check if an option is registered in this command
299
+ * @param name Option name
300
+ */
250
301
  hasOption(name) {
251
302
  name = name.split(".")[0];
252
303
  return this.options.find((option) => {
@@ -268,8 +319,7 @@ var Command = class {
268
319
  body: commands.map((command) => {
269
320
  return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
270
321
  }).join("\n")
271
- });
272
- sections.push({
322
+ }, {
273
323
  title: `For more info, run any command with the \`--help\` flag`,
274
324
  body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
275
325
  });
@@ -293,26 +343,33 @@ var Command = class {
293
343
  }).join("\n")
294
344
  });
295
345
  if (helpCallback) sections = helpCallback(sections) || sections;
296
- console.log(sections.map((section) => {
297
- return section.title ? `${section.title}:
298
- ${section.body}` : section.body;
346
+ console.info(sections.map((section) => {
347
+ return section.title ? `${section.title}:\n${section.body}` : section.body;
299
348
  }).join("\n\n"));
300
349
  }
301
350
  outputVersion() {
302
351
  const { name } = this.cli;
303
352
  const { versionNumber } = this.cli.globalCommand;
304
- if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
353
+ if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
305
354
  }
306
355
  checkRequiredArgs() {
307
356
  const minimalArgsCount = this.args.filter((arg) => arg.required).length;
308
357
  if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
309
358
  }
359
+ /**
360
+ * Check if the parsed options contain any unknown options
361
+ *
362
+ * Exit and output error when true
363
+ */
310
364
  checkUnknownOptions() {
311
365
  const { options, globalCommand } = this.cli;
312
366
  if (!this.config.allowUnknownOptions) {
313
367
  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}`}\``);
314
368
  }
315
369
  }
370
+ /**
371
+ * Check if the required string-type options exist
372
+ */
316
373
  checkOptionValue() {
317
374
  const { options: parsedOptions, globalCommand } = this.cli;
318
375
  const options = [...globalCommand.options, ...this.options];
@@ -324,14 +381,43 @@ ${section.body}` : section.body;
324
381
  }
325
382
  }
326
383
  }
384
+ /**
385
+ * Check if the number of args is more than expected
386
+ */
387
+ checkUnusedArgs() {
388
+ const maximumArgsCount = this.args.some((arg) => arg.variadic) ? Infinity : this.args.length;
389
+ if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg) => `\`${arg}\``).join(", ")}`);
390
+ }
327
391
  };
328
392
  var GlobalCommand = class extends Command {
329
393
  constructor(cli) {
330
394
  super("@@global@@", "", {}, cli);
331
395
  }
332
396
  };
333
- var __assign = Object.assign;
334
- var CAC = class extends EventEmitter {
397
+ var CAC = class extends EventTarget {
398
+ /** The program name to display in help and version message */
399
+ name;
400
+ commands;
401
+ globalCommand;
402
+ matchedCommand;
403
+ matchedCommandName;
404
+ /**
405
+ * Raw CLI arguments
406
+ */
407
+ rawArgs;
408
+ /**
409
+ * Parsed CLI arguments
410
+ */
411
+ args;
412
+ /**
413
+ * Parsed CLI options, camelCased
414
+ */
415
+ options;
416
+ showHelpOnExit;
417
+ showVersionOnExit;
418
+ /**
419
+ * @param name The program name to display in help and version message
420
+ */
335
421
  constructor(name = "") {
336
422
  super();
337
423
  this.name = name;
@@ -342,39 +428,75 @@ var CAC = class extends EventEmitter {
342
428
  this.globalCommand = new GlobalCommand(this);
343
429
  this.globalCommand.usage("<command> [options]");
344
430
  }
431
+ /**
432
+ * Add a global usage text.
433
+ *
434
+ * This is not used by sub-commands.
435
+ */
345
436
  usage(text) {
346
437
  this.globalCommand.usage(text);
347
438
  return this;
348
439
  }
440
+ /**
441
+ * Add a sub-command
442
+ */
349
443
  command(rawName, description, config) {
350
444
  const command = new Command(rawName, description || "", config, this);
351
445
  command.globalCommand = this.globalCommand;
352
446
  this.commands.push(command);
353
447
  return command;
354
448
  }
449
+ /**
450
+ * Add a global CLI option.
451
+ *
452
+ * Which is also applied to sub-commands.
453
+ */
355
454
  option(rawName, description, config) {
356
455
  this.globalCommand.option(rawName, description, config);
357
456
  return this;
358
457
  }
458
+ /**
459
+ * Show help message when `-h, --help` flags appear.
460
+ *
461
+ */
359
462
  help(callback) {
360
463
  this.globalCommand.option("-h, --help", "Display this message");
361
464
  this.globalCommand.helpCallback = callback;
362
465
  this.showHelpOnExit = true;
363
466
  return this;
364
467
  }
468
+ /**
469
+ * Show version number when `-v, --version` flags appear.
470
+ *
471
+ */
365
472
  version(version, customFlags = "-v, --version") {
366
473
  this.globalCommand.version(version, customFlags);
367
474
  this.showVersionOnExit = true;
368
475
  return this;
369
476
  }
477
+ /**
478
+ * Add a global example.
479
+ *
480
+ * This example added here will not be used by sub-commands.
481
+ */
370
482
  example(example) {
371
483
  this.globalCommand.example(example);
372
484
  return this;
373
485
  }
486
+ /**
487
+ * Output the corresponding help message
488
+ * When a sub-command is matched, output the help message for the command
489
+ * Otherwise output the global one.
490
+ *
491
+ */
374
492
  outputHelp() {
375
493
  if (this.matchedCommand) this.matchedCommand.outputHelp();
376
494
  else this.globalCommand.outputHelp();
377
495
  }
496
+ /**
497
+ * Output the version number.
498
+ *
499
+ */
378
500
  outputVersion() {
379
501
  this.globalCommand.outputVersion();
380
502
  }
@@ -389,7 +511,14 @@ var CAC = class extends EventEmitter {
389
511
  this.matchedCommand = void 0;
390
512
  this.matchedCommandName = void 0;
391
513
  }
392
- parse(argv = processArgs, { run = true } = {}) {
514
+ /**
515
+ * Parse argv
516
+ */
517
+ parse(argv, { run = true } = {}) {
518
+ if (!argv) {
519
+ if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
520
+ argv = runtimeProcessArgs;
521
+ }
393
522
  this.rawArgs = argv;
394
523
  if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
395
524
  let shouldParse = true;
@@ -398,17 +527,20 @@ var CAC = class extends EventEmitter {
398
527
  const commandName = parsed.args[0];
399
528
  if (command.isMatched(commandName)) {
400
529
  shouldParse = false;
401
- const parsedInfo = __assign(__assign({}, parsed), { args: parsed.args.slice(1) });
530
+ const parsedInfo = {
531
+ ...parsed,
532
+ args: parsed.args.slice(1)
533
+ };
402
534
  this.setParsedInfo(parsedInfo, command, commandName);
403
- this.emit(`command:${commandName}`, command);
535
+ this.dispatchEvent(new CustomEvent(`command:${commandName}`, { detail: command }));
404
536
  }
405
537
  }
406
538
  if (shouldParse) {
407
- for (const command of this.commands) if (command.name === "") {
539
+ for (const command of this.commands) if (command.isDefaultCommand) {
408
540
  shouldParse = false;
409
541
  const parsed = this.mri(argv.slice(2), command);
410
542
  this.setParsedInfo(parsed, command);
411
- this.emit(`command:!`, command);
543
+ this.dispatchEvent(new CustomEvent("command:!", { detail: command }));
412
544
  }
413
545
  }
414
546
  if (shouldParse) {
@@ -430,7 +562,7 @@ var CAC = class extends EventEmitter {
430
562
  options: this.options
431
563
  };
432
564
  if (run) this.runMatchedCommand();
433
- if (!this.matchedCommand && this.args[0]) this.emit("command:*");
565
+ if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] }));
434
566
  return parsedArgv;
435
567
  }
436
568
  mri(argv, command) {
@@ -438,26 +570,27 @@ var CAC = class extends EventEmitter {
438
570
  const mriOptions = getMriOptions(cliOptions);
439
571
  let argsAfterDoubleDashes = [];
440
572
  const doubleDashesIndex = argv.indexOf("--");
441
- if (doubleDashesIndex > -1) {
573
+ if (doubleDashesIndex !== -1) {
442
574
  argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
443
575
  argv = argv.slice(0, doubleDashesIndex);
444
576
  }
445
- let parsed = mri2(argv, mriOptions);
577
+ let parsed = lib_default(argv, mriOptions);
446
578
  parsed = Object.keys(parsed).reduce((res, name) => {
447
- return __assign(__assign({}, res), { [camelcaseOptionName(name)]: parsed[name] });
579
+ return {
580
+ ...res,
581
+ [camelcaseOptionName(name)]: parsed[name]
582
+ };
448
583
  }, { _: [] });
449
584
  const args = parsed._;
450
585
  const options = { "--": argsAfterDoubleDashes };
451
586
  const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
452
- let transforms = Object.create(null);
587
+ const transforms = Object.create(null);
453
588
  for (const cliOption of cliOptions) {
454
589
  if (!ignoreDefault && cliOption.config.default !== void 0) for (const name of cliOption.names) options[name] = cliOption.config.default;
455
- if (Array.isArray(cliOption.config.type)) {
456
- if (transforms[cliOption.name] === void 0) {
457
- transforms[cliOption.name] = Object.create(null);
458
- transforms[cliOption.name]["shouldTransform"] = true;
459
- transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
460
- }
590
+ if (Array.isArray(cliOption.config.type) && transforms[cliOption.name] === void 0) {
591
+ transforms[cliOption.name] = Object.create(null);
592
+ transforms[cliOption.name].shouldTransform = true;
593
+ transforms[cliOption.name].transformFunction = cliOption.config.type[0];
461
594
  }
462
595
  }
463
596
  for (const key of Object.keys(parsed)) if (key !== "_") {
@@ -475,6 +608,7 @@ var CAC = class extends EventEmitter {
475
608
  command.checkUnknownOptions();
476
609
  command.checkOptionValue();
477
610
  command.checkRequiredArgs();
611
+ command.checkUnusedArgs();
478
612
  const actionArgs = [];
479
613
  command.args.forEach((arg, index) => {
480
614
  if (arg.variadic) actionArgs.push(args.slice(index));
@@ -484,10 +618,11 @@ var CAC = class extends EventEmitter {
484
618
  return command.commandAction.apply(this, actionArgs);
485
619
  }
486
620
  };
621
+ /**
622
+ * @param name The program name to display in help and version message
623
+ */
487
624
  const cac = (name = "") => new CAC(name);
488
-
489
- //#endregion
490
- //#region ../../node_modules/.pnpm/tsdown@0.21.0-beta.2_@arethetypeswrong+core@0.18.2_@typescript+native-preview@7.0.0-dev_d0d0ed2124937ee9dd401a280008a3bf/node_modules/tsdown/dist/run.mjs
625
+ const lt = createRequire(import.meta.url)("./npm_entry_semver_functions_lt.cjs");
491
626
  const cli = cac("tsdown");
492
627
  cli.help().version(version);
493
628
  cli.command("[...files]", "Bundle files", {
@@ -496,7 +631,7 @@ cli.command("[...files]", "Bundle files", {
496
631
  }).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
497
632
  globalLogger.level = flags.logLevel || "info";
498
633
  globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
499
- const { build } = await import("./build-2oRq4mfQ-YC_gzK3u.js");
634
+ const { build } = await import("./build-gOkJM1H9-D9ngUBpk.js");
500
635
  if (input.length > 0) flags.entry = input;
501
636
  await build(flags);
502
637
  });
@@ -528,10 +663,10 @@ async function runCLI() {
528
663
  process$1.exit(1);
529
664
  }
530
665
  }
666
+ if (lt(process$1.version, "22.18.0")) console.warn(yellow`[tsdown] Node.js ${process$1.version} is deprecated. Support will be removed in the next minor release. Please upgrade to Node.js 22.18.0 or later.`);
531
667
  try {
532
668
  module.enableCompileCache?.();
533
669
  } catch {}
534
670
  runCLI();
535
-
536
671
  //#endregion
537
- export { };
672
+ export {};