rolldown 1.0.0-beta.3-commit.72028a5 → 1.0.0-beta.31

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 (149) hide show
  1. package/bin/cli.mjs +2 -0
  2. package/dist/{cjs/cli.cjs → cli.cjs} +634 -619
  3. package/dist/cli.d.cts +1 -0
  4. package/dist/cli.d.mts +1 -0
  5. package/dist/{esm/cli.mjs → cli.mjs} +610 -592
  6. package/dist/config.cjs +12 -0
  7. package/dist/config.d.cts +10 -0
  8. package/dist/config.d.mts +10 -0
  9. package/dist/config.mjs +10 -0
  10. package/dist/experimental-index.cjs +105 -0
  11. package/dist/experimental-index.d.cts +58 -0
  12. package/dist/experimental-index.d.mts +58 -0
  13. package/dist/experimental-index.mjs +82 -0
  14. package/dist/experimental-runtime-types.d.ts +68 -0
  15. package/dist/filter-index.cjs +105 -0
  16. package/dist/filter-index.d.cts +4 -0
  17. package/dist/filter-index.d.mts +4 -0
  18. package/dist/filter-index.mjs +44 -0
  19. package/dist/index.cjs +9 -0
  20. package/dist/index.d.cts +3 -0
  21. package/dist/index.d.mts +3 -0
  22. package/dist/index.mjs +5 -0
  23. package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -15
  24. package/dist/parallel-plugin-worker.d.cts +1 -0
  25. package/dist/parallel-plugin-worker.d.mts +1 -0
  26. package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -13
  27. package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
  28. package/dist/parallel-plugin.d.cts +14 -0
  29. package/dist/parallel-plugin.d.mts +14 -0
  30. package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
  31. package/dist/parse-ast-index.cjs +4 -0
  32. package/dist/parse-ast-index.d.cts +8 -0
  33. package/dist/parse-ast-index.d.mts +8 -0
  34. package/dist/parse-ast-index.mjs +3 -0
  35. package/dist/shared/binding-B2f_h9DF.d.mts +1323 -0
  36. package/dist/shared/binding-CCkTRaSB.d.cts +1323 -0
  37. package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
  38. package/dist/shared/define-config-BSYGonXk.d.mts +1335 -0
  39. package/dist/shared/define-config-BzVT47Bj.d.cts +1335 -0
  40. package/dist/shared/load-config-BpWL-vMP.cjs +125 -0
  41. package/dist/shared/load-config-DL286H4s.mjs +119 -0
  42. package/dist/shared/misc-CQeo-AFx.mjs +22 -0
  43. package/dist/shared/misc-DksvspN4.cjs +58 -0
  44. package/dist/shared/parse-ast-index-B-b57oWx.mjs +656 -0
  45. package/dist/shared/parse-ast-index-CKLoWOY8.cjs +784 -0
  46. package/dist/shared/{prompt-CxK9euq3.mjs → prompt-C5jz26Zn.mjs} +241 -240
  47. package/dist/shared/{prompt-ZZScCEWI.cjs → prompt-QNI93ne7.cjs} +245 -245
  48. package/dist/shared/src-Cs-HV-Wp.mjs +4388 -0
  49. package/dist/shared/src-D5CeiA1y.cjs +4580 -0
  50. package/package.json +68 -68
  51. package/bin/cli.js +0 -2
  52. package/dist/cjs/experimental-index.cjs +0 -85
  53. package/dist/cjs/index.cjs +0 -8
  54. package/dist/cjs/parse-ast-index.cjs +0 -4
  55. package/dist/esm/experimental-index.mjs +0 -57
  56. package/dist/esm/index.mjs +0 -4
  57. package/dist/esm/parse-ast-index.mjs +0 -3
  58. package/dist/shared/parse-ast-index-DIxeQDpE.mjs +0 -674
  59. package/dist/shared/parse-ast-index-Dh_sWnMa.cjs +0 -719
  60. package/dist/shared/src-CMVXQY3z.mjs +0 -2826
  61. package/dist/shared/src-CmTdtdJj.cjs +0 -3007
  62. package/dist/types/api/build.d.ts +0 -18
  63. package/dist/types/api/experimental.d.ts +0 -7
  64. package/dist/types/api/rolldown/index.d.ts +0 -3
  65. package/dist/types/api/rolldown/rolldown-build.d.ts +0 -13
  66. package/dist/types/api/watch/index.d.ts +0 -3
  67. package/dist/types/api/watch/watch-emitter.d.ts +0 -31
  68. package/dist/types/api/watch/watcher.d.ts +0 -13
  69. package/dist/types/binding.d.ts +0 -1435
  70. package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
  71. package/dist/types/builtin-plugin/constructors.d.ts +0 -21
  72. package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
  73. package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
  74. package/dist/types/builtin-plugin/utils.d.ts +0 -8
  75. package/dist/types/cli/arguments/alias.d.ts +0 -16
  76. package/dist/types/cli/arguments/index.d.ts +0 -15
  77. package/dist/types/cli/arguments/normalize.d.ts +0 -12
  78. package/dist/types/cli/arguments/utils.d.ts +0 -8
  79. package/dist/types/cli/colors.d.ts +0 -11
  80. package/dist/types/cli/commands/bundle.d.ts +0 -3
  81. package/dist/types/cli/commands/help.d.ts +0 -1
  82. package/dist/types/cli/index.d.ts +0 -1
  83. package/dist/types/cli/load-config.d.ts +0 -5
  84. package/dist/types/cli/logger.d.ts +0 -5
  85. package/dist/types/constants/plugin-context.d.ts +0 -7
  86. package/dist/types/constants/plugin.d.ts +0 -45
  87. package/dist/types/experimental-index.d.ts +0 -9
  88. package/dist/types/index.d.ts +0 -30
  89. package/dist/types/log/log-handler.d.ts +0 -4
  90. package/dist/types/log/logger.d.ts +0 -6
  91. package/dist/types/log/logging.d.ts +0 -12
  92. package/dist/types/log/logs.d.ts +0 -18
  93. package/dist/types/options/input-options.d.ts +0 -181
  94. package/dist/types/options/normalized-input-options.d.ts +0 -18
  95. package/dist/types/options/normalized-output-options.d.ts +0 -70
  96. package/dist/types/options/output-options.d.ts +0 -182
  97. package/dist/types/options/watch-options.d.ts +0 -5
  98. package/dist/types/parallel-plugin-worker.d.ts +0 -1
  99. package/dist/types/parallel-plugin.d.ts +0 -1
  100. package/dist/types/parse-ast-index.d.ts +0 -5
  101. package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
  102. package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
  103. package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
  104. package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
  105. package/dist/types/plugin/bindingify-plugin.d.ts +0 -16
  106. package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
  107. package/dist/types/plugin/hook-filter.d.ts +0 -48
  108. package/dist/types/plugin/index.d.ts +0 -134
  109. package/dist/types/plugin/minimal-plugin-context.d.ts +0 -23
  110. package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
  111. package/dist/types/plugin/parallel-plugin.d.ts +0 -9
  112. package/dist/types/plugin/plugin-context-data.d.ts +0 -17
  113. package/dist/types/plugin/plugin-context.d.ts +0 -67
  114. package/dist/types/plugin/plugin-driver.d.ts +0 -8
  115. package/dist/types/plugin/transform-plugin-context.d.ts +0 -28
  116. package/dist/types/types/assert.d.ts +0 -14
  117. package/dist/types/types/config-export.d.ts +0 -5
  118. package/dist/types/types/misc.d.ts +0 -40
  119. package/dist/types/types/module-info.d.ts +0 -15
  120. package/dist/types/types/module-side-effects.d.ts +0 -12
  121. package/dist/types/types/output-bundle.d.ts +0 -4
  122. package/dist/types/types/rolldown-options.d.ts +0 -5
  123. package/dist/types/types/rolldown-output.d.ts +0 -66
  124. package/dist/types/types/schema.d.ts +0 -33
  125. package/dist/types/types/sourcemap.d.ts +0 -14
  126. package/dist/types/types/utils.d.ts +0 -13
  127. package/dist/types/utils/asset-source.d.ts +0 -4
  128. package/dist/types/utils/async-flatten.d.ts +0 -1
  129. package/dist/types/utils/bindingify-input-options.d.ts +0 -7
  130. package/dist/types/utils/bindingify-output-options.d.ts +0 -5
  131. package/dist/types/utils/code-frame.d.ts +0 -1
  132. package/dist/types/utils/compose-js-plugins.d.ts +0 -2
  133. package/dist/types/utils/create-bundler-option.d.ts +0 -11
  134. package/dist/types/utils/create-bundler.d.ts +0 -8
  135. package/dist/types/utils/define-config.d.ts +0 -5
  136. package/dist/types/utils/error.d.ts +0 -2
  137. package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
  138. package/dist/types/utils/misc.d.ts +0 -6
  139. package/dist/types/utils/normalize-hook.d.ts +0 -7
  140. package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
  141. package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
  142. package/dist/types/utils/plugin/index.d.ts +0 -2
  143. package/dist/types/utils/transform-module-info.d.ts +0 -4
  144. package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
  145. package/dist/types/utils/transform-rendered-module.d.ts +0 -3
  146. package/dist/types/utils/transform-side-effects.d.ts +0 -3
  147. package/dist/types/utils/transform-sourcemap.d.ts +0 -3
  148. package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
  149. package/dist/types/utils/validator.d.ts +0 -6
@@ -1,189 +1,16 @@
1
- "use strict";
2
- const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-CmTdtdJj.cjs');
4
- const require_parse_ast_index = require('../shared/parse-ast-index-Dh_sWnMa.cjs');
5
- const node_process = require_chunk.__toESM(require("node:process"));
1
+ const require_chunk = require('./shared/chunk-DDkG_k5U.cjs');
2
+ const require_src = require('./shared/src-D5CeiA1y.cjs');
3
+ require('./shared/parse-ast-index-CKLoWOY8.cjs');
4
+ const require_misc = require('./shared/misc-DksvspN4.cjs');
5
+ const require_load_config = require('./shared/load-config-BpWL-vMP.cjs');
6
6
  const node_path = require_chunk.__toESM(require("node:path"));
7
- const node_fs = require_chunk.__toESM(require("node:fs"));
8
- const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
7
+ const ansis = require_chunk.__toESM(require("ansis"));
8
+ const node_process = require_chunk.__toESM(require("node:process"));
9
9
  const node_util = require_chunk.__toESM(require("node:util"));
10
10
  const node_tty = require_chunk.__toESM(require("node:tty"));
11
- const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
12
- const node_url = require_chunk.__toESM(require("node:url"));
13
-
14
- //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
15
- const signals = [];
16
- signals.push("SIGHUP", "SIGINT", "SIGTERM");
17
- if (process.platform !== "win32") signals.push(
18
- "SIGALRM",
19
- "SIGABRT",
20
- "SIGVTALRM",
21
- "SIGXCPU",
22
- "SIGXFSZ",
23
- "SIGUSR2",
24
- "SIGTRAP",
25
- "SIGSYS",
26
- "SIGQUIT",
27
- "SIGIOT"
28
- // should detect profiler and enable/disable accordingly.
29
- // see #21
30
- // 'SIGPROF'
31
- );
32
- if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
33
-
34
- //#endregion
35
- //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
36
- const processOk = (process$3) => !!process$3 && typeof process$3 === "object" && typeof process$3.removeListener === "function" && typeof process$3.emit === "function" && typeof process$3.reallyExit === "function" && typeof process$3.listeners === "function" && typeof process$3.kill === "function" && typeof process$3.pid === "number" && typeof process$3.on === "function";
37
- const kExitEmitter = Symbol.for("signal-exit emitter");
38
- const global = globalThis;
39
- const ObjectDefineProperty = Object.defineProperty.bind(Object);
40
- var Emitter = class {
41
- emitted = {
42
- afterExit: false,
43
- exit: false
44
- };
45
- listeners = {
46
- afterExit: [],
47
- exit: []
48
- };
49
- count = 0;
50
- id = Math.random();
51
- constructor() {
52
- if (global[kExitEmitter]) return global[kExitEmitter];
53
- ObjectDefineProperty(global, kExitEmitter, {
54
- value: this,
55
- writable: false,
56
- enumerable: false,
57
- configurable: false
58
- });
59
- }
60
- on(ev, fn) {
61
- this.listeners[ev].push(fn);
62
- }
63
- removeListener(ev, fn) {
64
- const list = this.listeners[ev];
65
- const i$1 = list.indexOf(fn);
66
- if (i$1 === -1) return;
67
- if (i$1 === 0 && list.length === 1) list.length = 0;
68
- else list.splice(i$1, 1);
69
- }
70
- emit(ev, code, signal) {
71
- if (this.emitted[ev]) return false;
72
- this.emitted[ev] = true;
73
- let ret = false;
74
- for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
75
- if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
76
- return ret;
77
- }
78
- };
79
- var SignalExitBase = class {};
80
- const signalExitWrap = (handler) => {
81
- return {
82
- onExit(cb, opts) {
83
- return handler.onExit(cb, opts);
84
- },
85
- load() {
86
- return handler.load();
87
- },
88
- unload() {
89
- return handler.unload();
90
- }
91
- };
92
- };
93
- var SignalExitFallback = class extends SignalExitBase {
94
- onExit() {
95
- return () => {};
96
- }
97
- load() {}
98
- unload() {}
99
- };
100
- var SignalExit = class extends SignalExitBase {
101
- #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
102
- #emitter = new Emitter();
103
- #process;
104
- #originalProcessEmit;
105
- #originalProcessReallyExit;
106
- #sigListeners = {};
107
- #loaded = false;
108
- constructor(process$3) {
109
- super();
110
- this.#process = process$3;
111
- this.#sigListeners = {};
112
- for (const sig of signals) this.#sigListeners[sig] = () => {
113
- const listeners = this.#process.listeners(sig);
114
- let { count } = this.#emitter;
115
- const p$2 = process$3;
116
- if (typeof p$2.__signal_exit_emitter__ === "object" && typeof p$2.__signal_exit_emitter__.count === "number") count += p$2.__signal_exit_emitter__.count;
117
- if (listeners.length === count) {
118
- this.unload();
119
- const ret = this.#emitter.emit("exit", null, sig);
120
- const s$2 = sig === "SIGHUP" ? this.#hupSig : sig;
121
- if (!ret) process$3.kill(process$3.pid, s$2);
122
- }
123
- };
124
- this.#originalProcessReallyExit = process$3.reallyExit;
125
- this.#originalProcessEmit = process$3.emit;
126
- }
127
- onExit(cb, opts) {
128
- if (!processOk(this.#process)) return () => {};
129
- if (this.#loaded === false) this.load();
130
- const ev = opts?.alwaysLast ? "afterExit" : "exit";
131
- this.#emitter.on(ev, cb);
132
- return () => {
133
- this.#emitter.removeListener(ev, cb);
134
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
135
- };
136
- }
137
- load() {
138
- if (this.#loaded) return;
139
- this.#loaded = true;
140
- this.#emitter.count += 1;
141
- for (const sig of signals) try {
142
- const fn = this.#sigListeners[sig];
143
- if (fn) this.#process.on(sig, fn);
144
- } catch (_$1) {}
145
- this.#process.emit = (ev, ...a$1) => {
146
- return this.#processEmit(ev, ...a$1);
147
- };
148
- this.#process.reallyExit = (code) => {
149
- return this.#processReallyExit(code);
150
- };
151
- }
152
- unload() {
153
- if (!this.#loaded) return;
154
- this.#loaded = false;
155
- signals.forEach((sig) => {
156
- const listener = this.#sigListeners[sig];
157
- if (!listener) throw new Error("Listener not defined for signal: " + sig);
158
- try {
159
- this.#process.removeListener(sig, listener);
160
- } catch (_$1) {}
161
- });
162
- this.#process.emit = this.#originalProcessEmit;
163
- this.#process.reallyExit = this.#originalProcessReallyExit;
164
- this.#emitter.count -= 1;
165
- }
166
- #processReallyExit(code) {
167
- if (!processOk(this.#process)) return 0;
168
- this.#process.exitCode = code || 0;
169
- this.#emitter.emit("exit", this.#process.exitCode, null);
170
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
171
- }
172
- #processEmit(ev, ...args) {
173
- const og = this.#originalProcessEmit;
174
- if (ev === "exit" && processOk(this.#process)) {
175
- if (typeof args[0] === "number") this.#process.exitCode = args[0];
176
- const ret = og.call(this.#process, ev, ...args);
177
- this.#emitter.emit("exit", this.#process.exitCode, null);
178
- return ret;
179
- } else return og.call(this.#process, ev, ...args);
180
- }
181
- };
182
- const process$2 = globalThis.process;
183
- const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
11
+ const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
184
12
 
185
- //#endregion
186
- //#region ../../node_modules/.pnpm/consola@3.4.0/node_modules/consola/dist/core.mjs
13
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
187
14
  const LogLevels = {
188
15
  silent: Number.NEGATIVE_INFINITY,
189
16
  fatal: 0,
@@ -239,7 +66,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
239
66
  return object;
240
67
  }
241
68
  function createDefu(merger) {
242
- return (...arguments_) => arguments_.reduce((p$2, c$1) => _defu(p$2, c$1, "", merger), {});
69
+ return (...arguments_) => arguments_.reduce((p, c$1) => _defu(p, c$1, "", merger), {});
243
70
  }
244
71
  const defu = createDefu();
245
72
  function isPlainObject(obj) {
@@ -569,10 +396,10 @@ function createConsola$1(options$1 = {}) {
569
396
  }
570
397
 
571
398
  //#endregion
572
- //#region ../../node_modules/.pnpm/consola@3.4.0/node_modules/consola/dist/shared/consola.Cs5FdtHD.mjs
573
- function parseStack(stack) {
574
- const cwd$1 = process.cwd() + node_path.sep;
575
- const lines = stack.split("\n").splice(1).map((l$1) => l$1.trim().replace("file://", "").replace(cwd$1, ""));
399
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
400
+ function parseStack(stack, message) {
401
+ const cwd = process.cwd() + node_path.sep;
402
+ const lines = stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd, ""));
576
403
  return lines;
577
404
  }
578
405
  function writeStream(data, stream) {
@@ -581,14 +408,14 @@ function writeStream(data, stream) {
581
408
  }
582
409
  const bracket = (x) => x ? `[${x}]` : "";
583
410
  var BasicReporter = class {
584
- formatStack(stack, opts) {
411
+ formatStack(stack, message, opts) {
585
412
  const indent = " ".repeat((opts?.errorLevel || 0) + 1);
586
- return indent + parseStack(stack).join(`
413
+ return indent + parseStack(stack, message).join(`
587
414
  ${indent}`);
588
415
  }
589
416
  formatError(err, opts) {
590
417
  const message = err.message ?? (0, node_util.formatWithOptions)(opts, err);
591
- const stack = err.stack ? this.formatStack(err.stack, opts) : "";
418
+ const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
592
419
  const level = opts?.errorLevel || 0;
593
420
  const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
594
421
  const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
@@ -633,7 +460,7 @@ ${indent}`);
633
460
  };
634
461
 
635
462
  //#endregion
636
- //#region ../../node_modules/.pnpm/consola@3.4.0/node_modules/consola/dist/shared/consola.lX6kr4n8.mjs
463
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
637
464
  const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
638
465
  const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
639
466
  const isForced = "FORCE_COLOR" in env || argv.includes("--color");
@@ -700,12 +527,12 @@ const colorDefs = {
700
527
  function createColors(useColor = isColorSupported) {
701
528
  return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
702
529
  }
703
- const colors$1 = createColors();
530
+ const colors$2 = createColors();
704
531
  function getColor$1(color, fallback = "reset") {
705
- return colors$1[color] || colors$1[fallback];
532
+ return colors$2[color] || colors$2[fallback];
706
533
  }
707
534
  const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
708
- function stripAnsi$1(text) {
535
+ function stripAnsi(text) {
709
536
  return text.replace(new RegExp(ansiRegex$1, "g"), "");
710
537
  }
711
538
  const boxStylePresets = {
@@ -798,14 +625,14 @@ function box(text, _opts = {}) {
798
625
  if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
799
626
  const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
800
627
  const height = textLines.length + paddingOffset;
801
- const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length)) + paddingOffset;
628
+ const width = Math.max(...textLines.map((line) => stripAnsi(line).length), opts.title ? stripAnsi(opts.title).length : 0) + paddingOffset;
802
629
  const widthOffset = width + paddingOffset;
803
630
  const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
804
631
  if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
805
632
  if (opts.title) {
806
633
  const title = _color ? _color(opts.title) : opts.title;
807
- const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
808
- const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
634
+ const left = borderStyle.h.repeat(Math.floor((width - stripAnsi(opts.title).length) / 2));
635
+ const right = borderStyle.h.repeat(width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset);
809
636
  boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
810
637
  } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
811
638
  const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
@@ -813,7 +640,7 @@ function box(text, _opts = {}) {
813
640
  else {
814
641
  const line = textLines[i$1 - valignOffset];
815
642
  const left = " ".repeat(paddingOffset);
816
- const right = " ".repeat(width - stripAnsi$1(line).length);
643
+ const right = " ".repeat(width - stripAnsi(line).length);
817
644
  boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
818
645
  }
819
646
  boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
@@ -822,29 +649,29 @@ function box(text, _opts = {}) {
822
649
  }
823
650
 
824
651
  //#endregion
825
- //#region ../../node_modules/.pnpm/consola@3.4.0/node_modules/consola/dist/index.mjs
826
- const r = Object.create(null), i = (e) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), s$1 = new Proxy(r, {
827
- get(e, o) {
828
- return i()[o] ?? r[o];
652
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
653
+ const r = Object.create(null), i = (e) => globalThis.process?.env || {}.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
654
+ get(e, s$1) {
655
+ return i()[s$1] ?? r[s$1];
829
656
  },
830
- has(e, o) {
657
+ has(e, s$1) {
831
658
  const E = i();
832
- return o in E || o in r;
659
+ return s$1 in E || s$1 in r;
833
660
  },
834
- set(e, o, E) {
835
- const b = i(true);
836
- return b[o] = E, true;
661
+ set(e, s$1, E) {
662
+ const B = i(true);
663
+ return B[s$1] = E, true;
837
664
  },
838
- deleteProperty(e, o) {
839
- if (!o) return false;
665
+ deleteProperty(e, s$1) {
666
+ if (!s$1) return false;
840
667
  const E = i(true);
841
- return delete E[o], true;
668
+ return delete E[s$1], true;
842
669
  },
843
670
  ownKeys() {
844
671
  const e = i(true);
845
672
  return Object.keys(e);
846
673
  }
847
- }), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", B = [
674
+ }), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
848
675
  ["APPVEYOR"],
849
676
  [
850
677
  "AWS_AMPLIFY",
@@ -912,6 +739,11 @@ const r = Object.create(null), i = (e) => globalThis.process?.env || globalThis.
912
739
  "CODESANDBOX_SSE",
913
740
  { ci: false }
914
741
  ],
742
+ [
743
+ "CODESANDBOX",
744
+ "CODESANDBOX_HOST",
745
+ { ci: false }
746
+ ],
915
747
  ["STACKBLITZ"],
916
748
  ["STORMKIT"],
917
749
  ["CLEAVR"],
@@ -930,10 +762,10 @@ const r = Object.create(null), i = (e) => globalThis.process?.env || globalThis.
930
762
  { ci: true }
931
763
  ]
932
764
  ];
933
- function p() {
934
- if (globalThis.process?.env) for (const e of B) {
935
- const o = e[1] || e[0];
936
- if (globalThis.process?.env[o]) return {
765
+ function b() {
766
+ if (globalThis.process?.env) for (const e of f) {
767
+ const s$1 = e[1] || e[0];
768
+ if (globalThis.process?.env[s$1]) return {
937
769
  name: e[0].toLowerCase(),
938
770
  ...e[2]
939
771
  };
@@ -946,45 +778,45 @@ function p() {
946
778
  ci: false
947
779
  };
948
780
  }
949
- const l = p();
781
+ const l = b();
950
782
  l.name;
951
783
  function n(e) {
952
784
  return e ? e !== "false" : false;
953
785
  }
954
- const I = globalThis.process?.platform || "", T = n(s$1.CI) || l.ci !== false, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), U = n(s$1.DEBUG), A = t === "test" || n(s$1.TEST);
955
- n(s$1.MINIMAL);
956
- const _ = /^win/i.test(I);
957
- !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM);
786
+ const I = globalThis.process?.platform || "", T = n(o.CI) || l.ci !== false, a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), g = n(o.DEBUG), R = t === "test" || n(o.TEST);
787
+ n(o.MINIMAL);
788
+ const A = /^win/i.test(I);
789
+ !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
958
790
  const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
959
791
  Number(C?.split(".")[0]);
960
- const y = globalThis.process || Object.create(null), c = { versions: {} };
961
- new Proxy(y, { get(e, o) {
962
- if (o === "env") return s$1;
963
- if (o in e) return e[o];
964
- if (o in c) return c[o];
792
+ const y = globalThis.process || Object.create(null), _ = { versions: {} };
793
+ new Proxy(y, { get(e, s$1) {
794
+ if (s$1 === "env") return o;
795
+ if (s$1 in e) return e[s$1];
796
+ if (s$1 in _) return _[s$1];
965
797
  } });
966
- const L = globalThis.process?.release?.name === "node", a = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, O = !!globalThis.fastly, S = !!globalThis.Netlify, N = !!globalThis.EdgeRuntime, P = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
798
+ const c = globalThis.process?.release?.name === "node", O = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
967
799
  [S, "netlify"],
968
- [N, "edge-light"],
969
- [P, "workerd"],
970
- [O, "fastly"],
800
+ [u, "edge-light"],
801
+ [N, "workerd"],
802
+ [L, "fastly"],
971
803
  [D, "deno"],
972
- [a, "bun"],
973
- [L, "node"]
804
+ [O, "bun"],
805
+ [c, "node"]
974
806
  ];
975
807
  function G() {
976
- const e = F.find((o) => o[0]);
808
+ const e = F.find((s$1) => s$1[0]);
977
809
  if (e) return { name: e[1] };
978
810
  }
979
- const u = G();
980
- u?.name;
811
+ const P = G();
812
+ P?.name;
981
813
  function ansiRegex({ onlyFirst = false } = {}) {
982
814
  const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
983
815
  const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
984
816
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
985
817
  }
986
818
  const regex = ansiRegex();
987
- function stripAnsi(string) {
819
+ function stripAnsi$1(string) {
988
820
  if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
989
821
  return string.replace(regex, "");
990
822
  }
@@ -1013,7 +845,7 @@ const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
1013
845
  function stringWidth$1(string, options$1 = {}) {
1014
846
  if (typeof string !== "string" || string.length === 0) return 0;
1015
847
  const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options$1;
1016
- if (!countAnsiEscapeCodes) string = stripAnsi(string);
848
+ if (!countAnsiEscapeCodes) string = stripAnsi$1(string);
1017
849
  if (string.length === 0) return 0;
1018
850
  let width = 0;
1019
851
  const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
@@ -1067,19 +899,19 @@ const TYPE_ICONS = {
1067
899
  };
1068
900
  function stringWidth(str) {
1069
901
  const hasICU = typeof Intl === "object";
1070
- if (!hasICU || !Intl.Segmenter) return stripAnsi$1(str).length;
902
+ if (!hasICU || !Intl.Segmenter) return stripAnsi(str).length;
1071
903
  return stringWidth$1(str);
1072
904
  }
1073
905
  var FancyReporter = class extends BasicReporter {
1074
- formatStack(stack, opts) {
906
+ formatStack(stack, message, opts) {
1075
907
  const indent = " ".repeat((opts?.errorLevel || 0) + 1);
1076
908
  return `
1077
- ${indent}` + parseStack(stack).map((line) => " " + line.replace(/^at +/, (m) => colors$1.gray(m)).replace(/\((.+)\)/, (_$1, m) => `(${colors$1.cyan(m)})`)).join(`
909
+ ${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors$2.gray(m)).replace(/\((.+)\)/, (_$1, m) => `(${colors$2.cyan(m)})`)).join(`
1078
910
  ${indent}`);
1079
911
  }
1080
912
  formatType(logObj, isBadge, opts) {
1081
913
  const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
1082
- if (isBadge) return getBgColor(typeColor)(colors$1.black(` ${logObj.type.toUpperCase()} `));
914
+ if (isBadge) return getBgColor(typeColor)(colors$2.black(` ${logObj.type.toUpperCase()} `));
1083
915
  const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
1084
916
  return _type ? getColor(typeColor)(_type) : "";
1085
917
  }
@@ -1090,31 +922,31 @@ ${indent}`);
1090
922
  style: logObj.style
1091
923
  });
1092
924
  const date = this.formatDate(logObj.date, opts);
1093
- const coloredDate = date && colors$1.gray(date);
925
+ const coloredDate = date && colors$2.gray(date);
1094
926
  const isBadge = logObj.badge ?? logObj.level < 2;
1095
927
  const type = this.formatType(logObj, isBadge, opts);
1096
- const tag = logObj.tag ? colors$1.gray(logObj.tag) : "";
928
+ const tag = logObj.tag ? colors$2.gray(logObj.tag) : "";
1097
929
  let line;
1098
930
  const left = this.filterAndJoin([type, characterFormat(message)]);
1099
931
  const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
1100
932
  const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
1101
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors$1.gray(`[${right}]`)} ` : "") + left;
933
+ line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors$2.gray(`[${right}]`)} ` : "") + left;
1102
934
  line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
1103
935
  if (logObj.type === "trace") {
1104
- const _err = new Error("Trace: " + logObj.message);
1105
- line += this.formatStack(_err.stack || "");
936
+ const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
937
+ line += this.formatStack(_err.stack || "", _err.message);
1106
938
  }
1107
939
  return isBadge ? "\n" + line + "\n" : line;
1108
940
  }
1109
941
  };
1110
942
  function characterFormat(str) {
1111
- return str.replace(/`([^`]+)`/gm, (_$1, m) => colors$1.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_$1, m) => ` ${colors$1.underline(m)} `);
943
+ return str.replace(/`([^`]+)`/gm, (_$1, m) => colors$2.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_$1, m) => ` ${colors$2.underline(m)} `);
1112
944
  }
1113
945
  function getColor(color = "white") {
1114
- return colors$1[color] || colors$1.white;
946
+ return colors$2[color] || colors$2.white;
1115
947
  }
1116
948
  function getBgColor(color = "bgWhite") {
1117
- return colors$1[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors$1.bgWhite;
949
+ return colors$2[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors$2.bgWhite;
1118
950
  }
1119
951
  function createConsola(options$1 = {}) {
1120
952
  let level = _getDefaultLogLevel();
@@ -1124,23 +956,24 @@ function createConsola(options$1 = {}) {
1124
956
  defaults: { level },
1125
957
  stdout: process.stdout,
1126
958
  stderr: process.stderr,
1127
- prompt: (...args) => Promise.resolve().then(function() {
1128
- return require("../shared/prompt-ZZScCEWI.cjs");
1129
- }).then((m) => m.prompt(...args)),
1130
- reporters: options$1.reporters || [options$1.fancy ?? !(T || A) ? new FancyReporter() : new BasicReporter()],
959
+ prompt: (...args) => Promise.resolve().then(() => require("./shared/prompt-QNI93ne7.cjs")).then((m) => m.prompt(...args)),
960
+ reporters: options$1.reporters || [options$1.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
1131
961
  ...options$1
1132
962
  });
1133
963
  return consola2;
1134
964
  }
1135
965
  function _getDefaultLogLevel() {
1136
- if (U) return LogLevels.debug;
1137
- if (A) return LogLevels.warn;
966
+ if (g) return LogLevels.debug;
967
+ if (R) return LogLevels.warn;
1138
968
  return LogLevels.info;
1139
969
  }
1140
970
  const consola = createConsola();
1141
971
 
1142
972
  //#endregion
1143
973
  //#region src/cli/logger.ts
974
+ /**
975
+ * Console logger
976
+ */
1144
977
  const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
1145
978
  function createTestingLogger() {
1146
979
  const types = [
@@ -1165,158 +998,552 @@ function createTestingLogger() {
1165
998
  }
1166
999
 
1167
1000
  //#endregion
1168
- //#region src/cli/load-config.ts
1169
- async function bundleTsConfig(configFile, isEsm) {
1170
- const dirnameVarName = "injected_original_dirname";
1171
- const filenameVarName = "injected_original_filename";
1172
- const importMetaUrlVarName = "injected_original_import_meta_url";
1173
- const bundle = await require_src.rolldown({
1174
- input: configFile,
1175
- platform: "node",
1176
- resolve: { mainFields: ["main"] },
1177
- define: {
1178
- __dirname: dirnameVarName,
1179
- __filename: filenameVarName,
1180
- "import.meta.url": importMetaUrlVarName,
1181
- "import.meta.dirname": dirnameVarName,
1182
- "import.meta.filename": filenameVarName
1183
- },
1184
- treeshake: false,
1185
- external: [/^[\w@][^:]/],
1186
- plugins: [{
1187
- name: "inject-file-scope-variables",
1188
- transform: {
1189
- filter: { id: /\.[cm]?[jt]s$/ },
1190
- async handler(code, id) {
1191
- const injectValues = `const ${dirnameVarName} = ${JSON.stringify(node_path.default.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify((0, node_url.pathToFileURL)(id).href)};`;
1192
- return {
1193
- code: injectValues + code,
1194
- map: null
1195
- };
1196
- }
1197
- }
1198
- }]
1199
- });
1200
- const outputDir = node_path.default.dirname(configFile);
1201
- const result = await bundle.write({
1202
- dir: outputDir,
1203
- format: isEsm ? "esm" : "cjs",
1204
- sourcemap: "inline",
1205
- entryFileNames: `rolldown.config.[hash]${node_path.default.extname(configFile).replace("ts", "js")}`
1206
- });
1207
- const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
1208
- return node_path.default.join(outputDir, fileName);
1209
- }
1210
- const SUPPORTED_JS_CONFIG_FORMATS = [
1211
- ".js",
1212
- ".mjs",
1213
- ".cjs"
1214
- ];
1215
- const SUPPORTED_TS_CONFIG_FORMATS = [
1216
- ".ts",
1217
- ".mts",
1218
- ".cts"
1001
+ //#region src/cli/arguments/alias.ts
1002
+ const alias = {
1003
+ config: {
1004
+ abbreviation: "c",
1005
+ hint: "filename"
1006
+ },
1007
+ help: { abbreviation: "h" },
1008
+ version: { abbreviation: "v" },
1009
+ watch: { abbreviation: "w" },
1010
+ dir: { abbreviation: "d" },
1011
+ file: { abbreviation: "o" },
1012
+ external: { abbreviation: "e" },
1013
+ format: { abbreviation: "f" },
1014
+ name: { abbreviation: "n" },
1015
+ globals: { abbreviation: "g" },
1016
+ sourcemap: {
1017
+ abbreviation: "s",
1018
+ default: true
1019
+ },
1020
+ minify: { abbreviation: "m" },
1021
+ platform: { abbreviation: "p" },
1022
+ assetFileNames: { hint: "name" },
1023
+ chunkFileNames: { hint: "name" },
1024
+ entryFileNames: { hint: "name" },
1025
+ externalLiveBindings: {
1026
+ default: true,
1027
+ reverse: true
1028
+ },
1029
+ treeshake: {
1030
+ default: true,
1031
+ reverse: true
1032
+ },
1033
+ preserveEntrySignatures: {
1034
+ default: "strict",
1035
+ reverse: true
1036
+ },
1037
+ moduleTypes: { hint: "types" }
1038
+ };
1039
+
1040
+ //#endregion
1041
+ //#region src/cli/arguments/utils.ts
1042
+ const priority = [
1043
+ "object",
1044
+ "array",
1045
+ "string",
1046
+ "number",
1047
+ "boolean"
1219
1048
  ];
1220
- const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
1221
- const DEFAULT_CONFIG_BASE = "rolldown.config";
1222
- async function findConfigFileNameInCwd() {
1223
- const filesInWorkingDirectory = new Set(await (0, node_fs_promises.readdir)((0, node_process.cwd)()));
1224
- for (const extension of SUPPORTED_CONFIG_FORMATS) {
1225
- const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
1226
- if (filesInWorkingDirectory.has(fileName)) return fileName;
1227
- }
1228
- throw new Error("No `rolldown.config` configuration file found.");
1229
- }
1230
- async function loadTsConfig(configFile) {
1231
- const isEsm = isFilePathESM(configFile);
1232
- const file = await bundleTsConfig(configFile, isEsm);
1233
- try {
1234
- return (await import((0, node_url.pathToFileURL)(file).href)).default;
1235
- } finally {
1236
- node_fs.default.unlink(file, () => {});
1049
+ function getSchemaType(schema) {
1050
+ if ("anyOf" in schema) {
1051
+ const types = schema.anyOf.map(getSchemaType);
1052
+ let result = priority.find((type) => types.includes(type));
1053
+ if (result) return result;
1237
1054
  }
1055
+ if ("type" in schema) return schema.type;
1056
+ if ("const" in schema) return typeof schema.const;
1057
+ return "never";
1238
1058
  }
1239
- function isFilePathESM(filePath) {
1240
- if (/\.m[jt]s$/.test(filePath)) return true;
1241
- else if (/\.c[jt]s$/.test(filePath)) return false;
1242
- else {
1243
- const pkg = findNearestPackageData(node_path.default.dirname(filePath));
1244
- if (pkg) return pkg.type === "module";
1245
- return false;
1059
+ function flattenSchema(schema, base = {}, parent = "") {
1060
+ if (schema === void 0) return base;
1061
+ for (const [k, value] of Object.entries(schema)) {
1062
+ const key = parent ? `${parent}.${k}` : k;
1063
+ if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
1064
+ else base[key] = value;
1065
+ else base[key] = value;
1246
1066
  }
1067
+ return base;
1247
1068
  }
1248
- function findNearestPackageData(basedir) {
1249
- while (basedir) {
1250
- const pkgPath = node_path.default.join(basedir, "package.json");
1251
- if (tryStatSync(pkgPath)?.isFile()) try {
1252
- return JSON.parse(node_fs.default.readFileSync(pkgPath, "utf-8"));
1253
- } catch {}
1254
- const nextBasedir = node_path.default.dirname(basedir);
1255
- if (nextBasedir === basedir) break;
1256
- basedir = nextBasedir;
1069
+ function setNestedProperty(obj, path$1, value) {
1070
+ const keys = path$1.split(".");
1071
+ let current = obj;
1072
+ for (let i$1 = 0; i$1 < keys.length - 1; i$1++) {
1073
+ if (!current[keys[i$1]]) current[keys[i$1]] = {};
1074
+ current = current[keys[i$1]];
1257
1075
  }
1258
- return null;
1076
+ const finalKey = keys[keys.length - 1];
1077
+ Object.defineProperty(current, finalKey, {
1078
+ value,
1079
+ writable: true,
1080
+ enumerable: true,
1081
+ configurable: true
1082
+ });
1259
1083
  }
1260
- function tryStatSync(file) {
1261
- try {
1262
- return node_fs.default.statSync(file, { throwIfNoEntry: false });
1263
- } catch {}
1084
+ function camelCaseToKebabCase(str) {
1085
+ return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
1264
1086
  }
1265
- async function loadConfig(configPath) {
1266
- const ext = node_path.default.extname(configPath = configPath || await findConfigFileNameInCwd());
1267
- try {
1268
- if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import((0, node_url.pathToFileURL)(configPath).href)).default;
1269
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
1270
- const rawConfigPath = node_path.default.resolve(configPath);
1271
- return await loadTsConfig(rawConfigPath);
1272
- } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
1273
- } catch (err) {
1274
- throw new Error("Error happened while loading config.", { cause: err });
1275
- }
1087
+ function kebabCaseToCamelCase(str) {
1088
+ return str.replace(/-./g, (match) => match[1].toUpperCase());
1276
1089
  }
1277
1090
 
1278
1091
  //#endregion
1279
- //#region src/cli/commands/bundle.ts
1280
- async function bundleWithConfig(configPath, cliOptions) {
1281
- const config = await loadConfig(configPath);
1282
- if (!config) {
1283
- logger.error(`No configuration found at ${config}`);
1284
- process.exit(1);
1092
+ //#region src/cli/arguments/normalize.ts
1093
+ function normalizeCliOptions(cliOptions, positionals) {
1094
+ const [data, errors] = require_src.validateCliOptions(cliOptions);
1095
+ if (errors?.length) {
1096
+ errors.forEach((error) => {
1097
+ logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
1098
+ });
1099
+ process.exit(1);
1100
+ }
1101
+ const options$1 = data ?? {};
1102
+ const result = {
1103
+ input: {},
1104
+ output: {},
1105
+ help: options$1.help ?? false,
1106
+ version: options$1.version ?? false,
1107
+ watch: options$1.watch ?? false
1108
+ };
1109
+ if (typeof options$1.config === "string") result.config = options$1.config;
1110
+ const keysOfInput = require_src.getInputCliKeys();
1111
+ const keysOfOutput = require_src.getOutputCliKeys();
1112
+ const reservedKeys = [
1113
+ "help",
1114
+ "version",
1115
+ "config",
1116
+ "watch"
1117
+ ];
1118
+ for (let [key, value] of Object.entries(options$1)) {
1119
+ const keys = key.split(".");
1120
+ const [primary] = keys;
1121
+ if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
1122
+ else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
1123
+ else if (!reservedKeys.includes(key)) {
1124
+ logger.error(`Unknown option: ${key}`);
1125
+ process.exit(1);
1126
+ }
1127
+ }
1128
+ if (!result.config && positionals.length > 0) if (Array.isArray(result.input.input)) result.input.input.push(...positionals);
1129
+ else result.input.input = positionals;
1130
+ return result;
1131
+ }
1132
+
1133
+ //#endregion
1134
+ //#region src/cli/arguments/index.ts
1135
+ const objectSchema = require_src.getJsonSchema();
1136
+ const flattenedSchema = flattenSchema(objectSchema.properties);
1137
+ const options = Object.fromEntries(Object.entries(flattenedSchema).filter(([_key, schema]) => getSchemaType(schema) !== "never").map(([key, schema]) => {
1138
+ const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
1139
+ const type = getSchemaType(schema);
1140
+ const result = {
1141
+ type: type === "boolean" ? "boolean" : "string",
1142
+ description: schema?.description ?? config?.description ?? "",
1143
+ hint: config?.hint
1144
+ };
1145
+ if (config && config?.abbreviation) result.short = config?.abbreviation;
1146
+ if (config && config.reverse) {
1147
+ if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
1148
+ else if (!result.description.startsWith("Avoid")) result.description = `disable ${result.description}`;
1149
+ }
1150
+ key = camelCaseToKebabCase(key);
1151
+ return [config?.reverse ? `no-${key}` : key, result];
1152
+ }));
1153
+ function parseCliArguments() {
1154
+ const { values, tokens, positionals } = (0, node_util.parseArgs)({
1155
+ options,
1156
+ tokens: true,
1157
+ allowPositionals: true,
1158
+ strict: false
1159
+ });
1160
+ tokens.filter((token) => token.kind === "option").forEach((option) => {
1161
+ let negative = false;
1162
+ if (option.name.startsWith("no-")) {
1163
+ const name = kebabCaseToCamelCase(option.name.substring(3));
1164
+ if (name in flattenedSchema) {
1165
+ delete values[option.name];
1166
+ option.name = name;
1167
+ negative = true;
1168
+ }
1169
+ }
1170
+ delete values[option.name];
1171
+ option.name = kebabCaseToCamelCase(option.name);
1172
+ let originalType = flattenedSchema[option.name];
1173
+ if (!originalType) {
1174
+ logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
1175
+ process.exit(1);
1176
+ }
1177
+ let type = getSchemaType(originalType);
1178
+ if (type === "string" && typeof option.value !== "string") {
1179
+ let opt = option;
1180
+ let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
1181
+ Object.defineProperty(values, opt.name, {
1182
+ value: defaultValue.default ?? "",
1183
+ enumerable: true,
1184
+ configurable: true,
1185
+ writable: true
1186
+ });
1187
+ } else if (type === "object" && typeof option.value === "string") {
1188
+ const [key, value] = option.value.split(",").map((x) => x.split("="))[0];
1189
+ if (!values[option.name]) Object.defineProperty(values, option.name, {
1190
+ value: {},
1191
+ enumerable: true,
1192
+ configurable: true,
1193
+ writable: true
1194
+ });
1195
+ if (key && value) Object.defineProperty(values[option.name], key, {
1196
+ value,
1197
+ enumerable: true,
1198
+ configurable: true,
1199
+ writable: true
1200
+ });
1201
+ } else if (type === "array" && typeof option.value === "string") {
1202
+ if (!values[option.name]) Object.defineProperty(values, option.name, {
1203
+ value: [],
1204
+ enumerable: true,
1205
+ configurable: true,
1206
+ writable: true
1207
+ });
1208
+ values[option.name].push(option.value);
1209
+ } else if (type === "boolean") Object.defineProperty(values, option.name, {
1210
+ value: !negative,
1211
+ enumerable: true,
1212
+ configurable: true,
1213
+ writable: true
1214
+ });
1215
+ else Object.defineProperty(values, option.name, {
1216
+ value: option.value ?? "",
1217
+ enumerable: true,
1218
+ configurable: true,
1219
+ writable: true
1220
+ });
1221
+ });
1222
+ return normalizeCliOptions(values, positionals);
1223
+ }
1224
+
1225
+ //#endregion
1226
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
1227
+ /**
1228
+ * This is not the set of all possible signals.
1229
+ *
1230
+ * It IS, however, the set of all signals that trigger
1231
+ * an exit on either Linux or BSD systems. Linux is a
1232
+ * superset of the signal names supported on BSD, and
1233
+ * the unknown signals just fail to register, so we can
1234
+ * catch that easily enough.
1235
+ *
1236
+ * Windows signals are a different set, since there are
1237
+ * signals that terminate Windows processes, but don't
1238
+ * terminate (or don't even exist) on Posix systems.
1239
+ *
1240
+ * Don't bother with SIGKILL. It's uncatchable, which
1241
+ * means that we can't fire any callbacks anyway.
1242
+ *
1243
+ * If a user does happen to register a handler on a non-
1244
+ * fatal signal like SIGWINCH or something, and then
1245
+ * exit, it'll end up firing `process.emit('exit')`, so
1246
+ * the handler will be fired anyway.
1247
+ *
1248
+ * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
1249
+ * artificially, inherently leave the process in a
1250
+ * state from which it is not safe to try and enter JS
1251
+ * listeners.
1252
+ */
1253
+ const signals = [];
1254
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
1255
+ if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
1256
+ if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
1257
+
1258
+ //#endregion
1259
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
1260
+ const processOk = (process$3) => !!process$3 && typeof process$3 === "object" && typeof process$3.removeListener === "function" && typeof process$3.emit === "function" && typeof process$3.reallyExit === "function" && typeof process$3.listeners === "function" && typeof process$3.kill === "function" && typeof process$3.pid === "number" && typeof process$3.on === "function";
1261
+ const kExitEmitter = Symbol.for("signal-exit emitter");
1262
+ const global = globalThis;
1263
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
1264
+ var Emitter = class {
1265
+ emitted = {
1266
+ afterExit: false,
1267
+ exit: false
1268
+ };
1269
+ listeners = {
1270
+ afterExit: [],
1271
+ exit: []
1272
+ };
1273
+ count = 0;
1274
+ id = Math.random();
1275
+ constructor() {
1276
+ if (global[kExitEmitter]) return global[kExitEmitter];
1277
+ ObjectDefineProperty(global, kExitEmitter, {
1278
+ value: this,
1279
+ writable: false,
1280
+ enumerable: false,
1281
+ configurable: false
1282
+ });
1283
+ }
1284
+ on(ev, fn) {
1285
+ this.listeners[ev].push(fn);
1286
+ }
1287
+ removeListener(ev, fn) {
1288
+ const list = this.listeners[ev];
1289
+ const i$1 = list.indexOf(fn);
1290
+ /* c8 ignore start */
1291
+ if (i$1 === -1) return;
1292
+ /* c8 ignore stop */
1293
+ if (i$1 === 0 && list.length === 1) list.length = 0;
1294
+ else list.splice(i$1, 1);
1295
+ }
1296
+ emit(ev, code, signal) {
1297
+ if (this.emitted[ev]) return false;
1298
+ this.emitted[ev] = true;
1299
+ let ret = false;
1300
+ for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
1301
+ if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
1302
+ return ret;
1303
+ }
1304
+ };
1305
+ var SignalExitBase = class {};
1306
+ const signalExitWrap = (handler) => {
1307
+ return {
1308
+ onExit(cb, opts) {
1309
+ return handler.onExit(cb, opts);
1310
+ },
1311
+ load() {
1312
+ return handler.load();
1313
+ },
1314
+ unload() {
1315
+ return handler.unload();
1316
+ }
1317
+ };
1318
+ };
1319
+ var SignalExitFallback = class extends SignalExitBase {
1320
+ onExit() {
1321
+ return () => {};
1322
+ }
1323
+ load() {}
1324
+ unload() {}
1325
+ };
1326
+ var SignalExit = class extends SignalExitBase {
1327
+ /* c8 ignore start */
1328
+ #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
1329
+ /* c8 ignore stop */
1330
+ #emitter = new Emitter();
1331
+ #process;
1332
+ #originalProcessEmit;
1333
+ #originalProcessReallyExit;
1334
+ #sigListeners = {};
1335
+ #loaded = false;
1336
+ constructor(process$3) {
1337
+ super();
1338
+ this.#process = process$3;
1339
+ this.#sigListeners = {};
1340
+ for (const sig of signals) this.#sigListeners[sig] = () => {
1341
+ const listeners = this.#process.listeners(sig);
1342
+ let { count } = this.#emitter;
1343
+ /* c8 ignore start */
1344
+ const p = process$3;
1345
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
1346
+ /* c8 ignore stop */
1347
+ if (listeners.length === count) {
1348
+ this.unload();
1349
+ const ret = this.#emitter.emit("exit", null, sig);
1350
+ /* c8 ignore start */
1351
+ const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
1352
+ if (!ret) process$3.kill(process$3.pid, s$1);
1353
+ }
1354
+ };
1355
+ this.#originalProcessReallyExit = process$3.reallyExit;
1356
+ this.#originalProcessEmit = process$3.emit;
1357
+ }
1358
+ onExit(cb, opts) {
1359
+ /* c8 ignore start */
1360
+ if (!processOk(this.#process)) return () => {};
1361
+ /* c8 ignore stop */
1362
+ if (this.#loaded === false) this.load();
1363
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
1364
+ this.#emitter.on(ev, cb);
1365
+ return () => {
1366
+ this.#emitter.removeListener(ev, cb);
1367
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
1368
+ };
1369
+ }
1370
+ load() {
1371
+ if (this.#loaded) return;
1372
+ this.#loaded = true;
1373
+ this.#emitter.count += 1;
1374
+ for (const sig of signals) try {
1375
+ const fn = this.#sigListeners[sig];
1376
+ if (fn) this.#process.on(sig, fn);
1377
+ } catch (_$1) {}
1378
+ this.#process.emit = (ev, ...a$1) => {
1379
+ return this.#processEmit(ev, ...a$1);
1380
+ };
1381
+ this.#process.reallyExit = (code) => {
1382
+ return this.#processReallyExit(code);
1383
+ };
1384
+ }
1385
+ unload() {
1386
+ if (!this.#loaded) return;
1387
+ this.#loaded = false;
1388
+ signals.forEach((sig) => {
1389
+ const listener = this.#sigListeners[sig];
1390
+ /* c8 ignore start */
1391
+ if (!listener) throw new Error("Listener not defined for signal: " + sig);
1392
+ /* c8 ignore stop */
1393
+ try {
1394
+ this.#process.removeListener(sig, listener);
1395
+ } catch (_$1) {}
1396
+ /* c8 ignore stop */
1397
+ });
1398
+ this.#process.emit = this.#originalProcessEmit;
1399
+ this.#process.reallyExit = this.#originalProcessReallyExit;
1400
+ this.#emitter.count -= 1;
1401
+ }
1402
+ #processReallyExit(code) {
1403
+ /* c8 ignore start */
1404
+ if (!processOk(this.#process)) return 0;
1405
+ this.#process.exitCode = code || 0;
1406
+ /* c8 ignore stop */
1407
+ this.#emitter.emit("exit", this.#process.exitCode, null);
1408
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
1285
1409
  }
1286
- if (cliOptions.watch) await watchInner(config, cliOptions);
1287
- else await bundleInner(config, cliOptions);
1410
+ #processEmit(ev, ...args) {
1411
+ const og = this.#originalProcessEmit;
1412
+ if (ev === "exit" && processOk(this.#process)) {
1413
+ if (typeof args[0] === "number") this.#process.exitCode = args[0];
1414
+ /* c8 ignore start */
1415
+ const ret = og.call(this.#process, ev, ...args);
1416
+ /* c8 ignore start */
1417
+ this.#emitter.emit("exit", this.#process.exitCode, null);
1418
+ /* c8 ignore stop */
1419
+ return ret;
1420
+ } else return og.call(this.#process, ev, ...args);
1421
+ }
1422
+ };
1423
+ const process$2 = globalThis.process;
1424
+ const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
1425
+
1426
+ //#endregion
1427
+ //#region src/utils/clear-screen.ts
1428
+ const CLEAR_SCREEN = "\x1Bc";
1429
+ function getClearScreenFunction(options$1) {
1430
+ const isTTY = process.stdout.isTTY;
1431
+ const isAnyOptionNotAllowingClearScreen = require_misc.arraify(options$1).some(({ watch: watch$1 }) => watch$1 === false || watch$1?.clearScreen === false);
1432
+ if (isTTY && !isAnyOptionNotAllowingClearScreen) return () => {
1433
+ process.stdout.write(CLEAR_SCREEN);
1434
+ };
1288
1435
  }
1289
- async function bundleWithCliOptions(cliOptions) {
1290
- if (cliOptions.output.dir || cliOptions.output.file) {
1291
- const operation = cliOptions.watch ? watchInner : bundleInner;
1292
- await operation({}, cliOptions);
1293
- return;
1436
+
1437
+ //#endregion
1438
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
1439
+ var require_usingCtx = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.80.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js": ((exports, module) => {
1440
+ function _usingCtx() {
1441
+ var r$1 = "function" == typeof SuppressedError ? SuppressedError : function(r$2, e$1) {
1442
+ var n$2 = Error();
1443
+ return n$2.name = "SuppressedError", n$2.error = r$2, n$2.suppressed = e$1, n$2;
1444
+ }, e = {}, n$1 = [];
1445
+ function using(r$2, e$1) {
1446
+ if (null != e$1) {
1447
+ if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
1448
+ if (r$2) var o$1 = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
1449
+ if (void 0 === o$1 && (o$1 = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$2)) var t$1 = o$1;
1450
+ if ("function" != typeof o$1) throw new TypeError("Object is not disposable.");
1451
+ t$1 && (o$1 = function o$2() {
1452
+ try {
1453
+ t$1.call(e$1);
1454
+ } catch (r$3) {
1455
+ return Promise.reject(r$3);
1456
+ }
1457
+ }), n$1.push({
1458
+ v: e$1,
1459
+ d: o$1,
1460
+ a: r$2
1461
+ });
1462
+ } else r$2 && n$1.push({
1463
+ d: e$1,
1464
+ a: r$2
1465
+ });
1466
+ return e$1;
1467
+ }
1468
+ return {
1469
+ e,
1470
+ u: using.bind(null, !1),
1471
+ a: using.bind(null, !0),
1472
+ d: function d() {
1473
+ var o$1, t$1 = this.e, s$1 = 0;
1474
+ function next() {
1475
+ for (; o$1 = n$1.pop();) try {
1476
+ if (!o$1.a && 1 === s$1) return s$1 = 0, n$1.push(o$1), Promise.resolve().then(next);
1477
+ if (o$1.d) {
1478
+ var r$2 = o$1.d.call(o$1.v);
1479
+ if (o$1.a) return s$1 |= 2, Promise.resolve(r$2).then(next, err);
1480
+ } else s$1 |= 1;
1481
+ } catch (r$3) {
1482
+ return err(r$3);
1483
+ }
1484
+ if (1 === s$1) return t$1 !== e ? Promise.reject(t$1) : Promise.resolve();
1485
+ if (t$1 !== e) throw t$1;
1486
+ }
1487
+ function err(n$2) {
1488
+ return t$1 = t$1 !== e ? new r$1(n$2, t$1) : n$2, next();
1489
+ }
1490
+ return next();
1491
+ }
1492
+ };
1294
1493
  }
1494
+ module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
1495
+ }) });
1496
+
1497
+ //#endregion
1498
+ //#region src/cli/commands/bundle.ts
1499
+ var import_usingCtx = /* @__PURE__ */ require_chunk.__toESM(require_usingCtx(), 1);
1500
+ async function bundleWithConfig(configPath, cliOptions) {
1295
1501
  if (cliOptions.watch) {
1296
- logger.error("You must specify `output.dir` to use watch mode");
1502
+ process.env.ROLLUP_WATCH = "true";
1503
+ process.env.ROLLDOWN_WATCH = "true";
1504
+ }
1505
+ const config = await require_load_config.loadConfig(configPath);
1506
+ if (!config) {
1507
+ logger.error(`No configuration found at ${config}`);
1297
1508
  process.exit(1);
1298
1509
  }
1299
- const build = await require_src.rolldown(cliOptions.input);
1510
+ if (cliOptions.watch) await watchInner(config, cliOptions);
1511
+ else await bundleInner(config, cliOptions);
1512
+ }
1513
+ async function bundleWithCliOptions(cliOptions) {
1300
1514
  try {
1515
+ var _usingCtx$1 = (0, import_usingCtx.default)();
1516
+ if (cliOptions.output.dir || cliOptions.output.file) {
1517
+ const operation = cliOptions.watch ? watchInner : bundleInner;
1518
+ await operation({}, cliOptions);
1519
+ return;
1520
+ }
1521
+ if (cliOptions.watch) {
1522
+ logger.error("You must specify `output.dir` to use watch mode");
1523
+ process.exit(1);
1524
+ }
1525
+ const build = _usingCtx$1.a(await require_src.rolldown(cliOptions.input));
1301
1526
  const { output: outputs } = await build.generate(cliOptions.output);
1302
1527
  if (outputs.length === 0) {
1303
1528
  logger.error("No output generated");
1304
1529
  process.exit(1);
1305
1530
  }
1306
1531
  for (const file of outputs) {
1307
- if (outputs.length > 1) logger.log(`\n${require_parse_ast_index.colors.cyan(require_parse_ast_index.colors.bold(`|→ ${file.fileName}:`))}\n`);
1532
+ if (outputs.length > 1) logger.log(`\n${ansis.default.cyan(ansis.default.bold(`|→ ${file.fileName}:`))}\n`);
1308
1533
  console.log(file.type === "asset" ? file.source : file.code);
1309
1534
  }
1535
+ } catch (_$1) {
1536
+ _usingCtx$1.e = _$1;
1310
1537
  } finally {
1311
- await build.close();
1538
+ await _usingCtx$1.d();
1312
1539
  }
1313
1540
  }
1314
1541
  async function watchInner(config, cliOptions) {
1315
- let normalizedConfig = require_src.arraify(config).map((option) => {
1542
+ let normalizedConfig = require_misc.arraify(config).map((option) => {
1316
1543
  return {
1317
1544
  ...option,
1318
1545
  ...cliOptions.input,
1319
- output: require_src.arraify(option.output || {}).map((output) => {
1546
+ output: require_misc.arraify(option.output || {}).map((output) => {
1320
1547
  return {
1321
1548
  ...output,
1322
1549
  ...cliOptions.output
@@ -1324,7 +1551,7 @@ async function watchInner(config, cliOptions) {
1324
1551
  })
1325
1552
  };
1326
1553
  });
1327
- const watcher = await require_src.watch(normalizedConfig);
1554
+ const watcher = require_src.watch(normalizedConfig);
1328
1555
  onExit((code) => {
1329
1556
  Promise.resolve(watcher.close()).finally(() => {
1330
1557
  process.exit(typeof code === "number" ? code : 0);
@@ -1335,16 +1562,22 @@ async function watchInner(config, cliOptions) {
1335
1562
  watcher.on("change", (id, event) => {
1336
1563
  if (event.event === "update") changedFile.push(id);
1337
1564
  });
1338
- watcher.on("event", (event) => {
1565
+ const clearScreen = getClearScreenFunction(normalizedConfig);
1566
+ watcher.on("event", async (event) => {
1339
1567
  switch (event.code) {
1568
+ case "START":
1569
+ clearScreen?.();
1570
+ break;
1340
1571
  case "BUNDLE_START":
1341
- if (changedFile.length > 0) logger.log(`Found ${require_parse_ast_index.colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
1572
+ if (changedFile.length > 0) logger.log(`Found ${ansis.default.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
1342
1573
  changedFile.length = 0;
1343
1574
  break;
1344
1575
  case "BUNDLE_END":
1345
- logger.success(`Rebuilt ${require_parse_ast_index.colors.bold(relativeId(event.output[0]))} in ${require_parse_ast_index.colors.bold(ms(event.duration))}.`);
1576
+ await event.result.close();
1577
+ logger.success(`Rebuilt ${ansis.default.bold(relativeId(event.output[0]))} in ${ansis.default.green(ms(event.duration))}.`);
1346
1578
  break;
1347
1579
  case "ERROR":
1580
+ await event.result.close();
1348
1581
  logger.error(event.error);
1349
1582
  break;
1350
1583
  default: break;
@@ -1355,9 +1588,9 @@ async function watchInner(config, cliOptions) {
1355
1588
  async function bundleInner(config, cliOptions) {
1356
1589
  const startTime = node_perf_hooks.performance.now();
1357
1590
  const result = [];
1358
- const configList = require_src.arraify(config);
1591
+ const configList = require_misc.arraify(config);
1359
1592
  for (const config$1 of configList) {
1360
- const outputList = require_src.arraify(config$1.output || {});
1593
+ const outputList = require_misc.arraify(config$1.output || {});
1361
1594
  const build = await require_src.rolldown({
1362
1595
  ...config$1,
1363
1596
  ...cliOptions.input
@@ -1375,7 +1608,7 @@ async function bundleInner(config, cliOptions) {
1375
1608
  logger.log(``);
1376
1609
  const endTime = node_perf_hooks.performance.now();
1377
1610
  const duration = endTime - startTime;
1378
- logger.success(`Finished in ${require_parse_ast_index.colors.bold(ms(duration))}`);
1611
+ logger.success(`rolldown v${require_src.version} Finished in ${ansis.default.green(ms(duration))}`);
1379
1612
  }
1380
1613
  function printBundleOutputPretty(output) {
1381
1614
  const outputEntries = collectOutputEntries(output.output);
@@ -1386,7 +1619,7 @@ function collectOutputEntries(output) {
1386
1619
  return output.map((chunk) => ({
1387
1620
  type: chunk.type,
1388
1621
  fileName: chunk.fileName,
1389
- size: chunk.type === "chunk" ? chunk.code.length : chunk.source.length
1622
+ size: chunk.type === "chunk" ? Buffer.byteLength(chunk.code) : Buffer.byteLength(chunk.source)
1390
1623
  }));
1391
1624
  }
1392
1625
  function collectOutputLayoutAdjustmentSizes(entries) {
@@ -1422,17 +1655,17 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
1422
1655
  const filtered = entries.filter((e) => e.type === group.type);
1423
1656
  if (!filtered.length) continue;
1424
1657
  for (const entry of filtered.sort((a$1, z) => a$1.size - z.size)) {
1425
- let log = require_parse_ast_index.colors.dim(withTrailingSlash(distPath));
1426
- log += require_parse_ast_index.colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
1427
- log += require_parse_ast_index.colors.dim(entry.type);
1428
- log += require_parse_ast_index.colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
1658
+ let log = ansis.default.dim(withTrailingSlash(distPath));
1659
+ log += ansis.default[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
1660
+ log += ansis.default.dim(entry.type);
1661
+ log += ansis.default.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
1429
1662
  logger.log(log);
1430
1663
  }
1431
1664
  }
1432
1665
  }
1433
- function withTrailingSlash(path$2) {
1434
- if (path$2[path$2.length - 1] !== "/") return `${path$2}/`;
1435
- return path$2;
1666
+ function withTrailingSlash(path$1) {
1667
+ if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
1668
+ return path$1;
1436
1669
  }
1437
1670
  function ms(duration) {
1438
1671
  return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
@@ -1442,229 +1675,11 @@ function relativeId(id) {
1442
1675
  return node_path.default.relative(node_path.default.resolve(), id);
1443
1676
  }
1444
1677
 
1445
- //#endregion
1446
- //#region src/cli/arguments/alias.ts
1447
- const alias = {
1448
- config: {
1449
- abbreviation: "c",
1450
- hint: "filename"
1451
- },
1452
- help: { abbreviation: "h" },
1453
- version: { abbreviation: "v" },
1454
- watch: { abbreviation: "w" },
1455
- dir: { abbreviation: "d" },
1456
- file: { abbreviation: "o" },
1457
- external: { abbreviation: "e" },
1458
- format: { abbreviation: "f" },
1459
- name: { abbreviation: "n" },
1460
- globals: { abbreviation: "g" },
1461
- sourcemap: {
1462
- abbreviation: "s",
1463
- default: true
1464
- },
1465
- minify: { abbreviation: "m" },
1466
- platform: { abbreviation: "p" },
1467
- assetFileNames: { hint: "name" },
1468
- chunkFileNames: { hint: "name" },
1469
- entryFileNames: { hint: "name" },
1470
- externalLiveBindings: {
1471
- default: true,
1472
- reverse: true
1473
- },
1474
- treeshake: {
1475
- default: true,
1476
- reverse: true
1477
- },
1478
- moduleTypes: { hint: "types" }
1479
- };
1480
-
1481
- //#endregion
1482
- //#region src/cli/arguments/utils.ts
1483
- const priority = [
1484
- "object",
1485
- "array",
1486
- "string",
1487
- "number",
1488
- "boolean"
1489
- ];
1490
- function getSchemaType(schema) {
1491
- if ("anyOf" in schema) {
1492
- const types = schema.anyOf.map(getSchemaType);
1493
- let result = priority.find((type) => types.includes(type));
1494
- if (result) return result;
1495
- }
1496
- if ("type" in schema) return schema.type;
1497
- if ("const" in schema) return typeof schema.const;
1498
- return "object";
1499
- }
1500
- function flattenSchema(schema, base = {}, parent = "") {
1501
- if (schema === void 0) return base;
1502
- for (const [k, value] of Object.entries(schema)) {
1503
- const key = parent ? `${parent}.${k}` : k;
1504
- if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
1505
- else base[key] = value;
1506
- else base[key] = value;
1507
- }
1508
- return base;
1509
- }
1510
- function setNestedProperty(obj, path$2, value) {
1511
- const keys = path$2.split(".");
1512
- let current = obj;
1513
- for (let i$1 = 0; i$1 < keys.length - 1; i$1++) {
1514
- if (!current[keys[i$1]]) current[keys[i$1]] = {};
1515
- current = current[keys[i$1]];
1516
- }
1517
- const finalKey = keys[keys.length - 1];
1518
- Object.defineProperty(current, finalKey, {
1519
- value,
1520
- writable: true,
1521
- enumerable: true,
1522
- configurable: true
1523
- });
1524
- }
1525
- function camelCaseToKebabCase(str) {
1526
- return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
1527
- }
1528
- function kebabCaseToCamelCase(str) {
1529
- return str.replace(/-./g, (match) => match[1].toUpperCase());
1530
- }
1531
-
1532
- //#endregion
1533
- //#region src/cli/arguments/normalize.ts
1534
- function normalizeCliOptions(cliOptions, positionals) {
1535
- const [data, errors] = require_src.validateCliOptions(cliOptions);
1536
- if (errors?.length) {
1537
- errors.forEach((error) => {
1538
- logger.error(`Invalid value for option ${error}. You can use \`rolldown -h\` to see the help.`);
1539
- });
1540
- process.exit(1);
1541
- }
1542
- const options$1 = data ?? {};
1543
- const result = {
1544
- input: {},
1545
- output: {},
1546
- help: options$1.help ?? false,
1547
- version: options$1.version ?? false,
1548
- watch: options$1.watch ?? false
1549
- };
1550
- if (typeof options$1.config === "string") result.config = options$1.config;
1551
- const keysOfInput = require_src.getInputCliKeys();
1552
- const keysOfOutput = require_src.getOutputCliKeys();
1553
- const reservedKeys = [
1554
- "help",
1555
- "version",
1556
- "config",
1557
- "watch"
1558
- ];
1559
- for (let [key, value] of Object.entries(options$1)) {
1560
- const keys = key.split(".");
1561
- const [primary] = keys;
1562
- if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
1563
- else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
1564
- else if (!reservedKeys.includes(key)) {
1565
- logger.error(`Unknown option: ${key}`);
1566
- process.exit(1);
1567
- }
1568
- }
1569
- if (!result.config && positionals.length > 0) result.input.input = positionals;
1570
- return result;
1571
- }
1572
-
1573
- //#endregion
1574
- //#region src/cli/arguments/index.ts
1575
- const objectSchema = require_src.getJsonSchema();
1576
- const flattenedSchema = flattenSchema(objectSchema.properties);
1577
- const options = Object.fromEntries(Object.entries(flattenedSchema).map(([key, schema]) => {
1578
- const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
1579
- const type = getSchemaType(schema);
1580
- const result = {
1581
- type: type === "boolean" ? "boolean" : "string",
1582
- description: schema?.description ?? config?.description ?? "",
1583
- hint: config?.hint
1584
- };
1585
- if (config && config?.abbreviation) result.short = config?.abbreviation;
1586
- if (config && config.reverse) if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
1587
- else result.description = `disable ${result.description}`;
1588
- key = camelCaseToKebabCase(key);
1589
- return [config?.reverse ? `no-${key}` : key, result];
1590
- }));
1591
- function parseCliArguments() {
1592
- const { values, tokens, positionals } = (0, node_util.parseArgs)({
1593
- options,
1594
- tokens: true,
1595
- allowPositionals: true,
1596
- strict: false
1597
- });
1598
- tokens.filter((token) => token.kind === "option").forEach((option) => {
1599
- let negative = false;
1600
- if (option.name.startsWith("no-")) {
1601
- const name = kebabCaseToCamelCase(option.name.substring(3));
1602
- if (name in flattenedSchema) {
1603
- delete values[option.name];
1604
- option.name = name;
1605
- negative = true;
1606
- }
1607
- }
1608
- delete values[option.name];
1609
- option.name = kebabCaseToCamelCase(option.name);
1610
- let originalType = flattenedSchema[option.name];
1611
- if (!originalType) {
1612
- logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
1613
- process.exit(1);
1614
- }
1615
- let type = getSchemaType(originalType);
1616
- if (type === "string" && typeof option.value !== "string") {
1617
- let opt = option;
1618
- let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
1619
- Object.defineProperty(values, opt.name, {
1620
- value: defaultValue.default ?? "",
1621
- enumerable: true,
1622
- configurable: true,
1623
- writable: true
1624
- });
1625
- } else if (type === "object" && typeof option.value === "string") {
1626
- const [key, value] = option.value.split(",").map((x) => x.split("="))[0];
1627
- if (!values[option.name]) Object.defineProperty(values, option.name, {
1628
- value: {},
1629
- enumerable: true,
1630
- configurable: true,
1631
- writable: true
1632
- });
1633
- if (key && value) Object.defineProperty(values[option.name], key, {
1634
- value,
1635
- enumerable: true,
1636
- configurable: true,
1637
- writable: true
1638
- });
1639
- } else if (type === "array" && typeof option.value === "string") {
1640
- if (!values[option.name]) Object.defineProperty(values, option.name, {
1641
- value: [],
1642
- enumerable: true,
1643
- configurable: true,
1644
- writable: true
1645
- });
1646
- values[option.name].push(option.value);
1647
- } else if (type === "boolean") Object.defineProperty(values, option.name, {
1648
- value: !negative,
1649
- enumerable: true,
1650
- configurable: true,
1651
- writable: true
1652
- });
1653
- else Object.defineProperty(values, option.name, {
1654
- value: option.value ?? "",
1655
- enumerable: true,
1656
- configurable: true,
1657
- writable: true
1658
- });
1659
- });
1660
- return normalizeCliOptions(values, positionals);
1661
- }
1662
-
1663
1678
  //#endregion
1664
1679
  //#region src/cli/commands/help.ts
1665
- const introduction = `${require_parse_ast_index.colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
1680
+ const introduction = `${ansis.default.gray(`${require_src.description} (rolldown v${require_src.version})`)}
1666
1681
 
1667
- ${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("USAGE"))} ${require_parse_ast_index.colors.cyan("rolldown -c <config>")} or ${require_parse_ast_index.colors.cyan("rolldown <input> <options>")}`;
1682
+ ${ansis.default.bold(ansis.default.underline("USAGE"))} ${ansis.default.cyan("rolldown -c <config>")} or ${ansis.default.cyan("rolldown <input> <options>")}`;
1668
1683
  const examples = [
1669
1684
  {
1670
1685
  title: "Bundle with a config file `rolldown.config.mjs`",
@@ -1696,33 +1711,33 @@ const notes = [
1696
1711
  function showHelp() {
1697
1712
  logger.log(introduction);
1698
1713
  logger.log("");
1699
- logger.log(`${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("OPTIONS"))}`);
1714
+ logger.log(`${ansis.default.bold(ansis.default.underline("OPTIONS"))}`);
1700
1715
  logger.log("");
1701
- logger.log(Object.entries(options).sort(([a$1], [b]) => {
1702
- if (options[a$1].short && !options[b].short) return -1;
1703
- if (!options[a$1].short && options[b].short) return 1;
1704
- if (options[a$1].short && options[b].short) return options[a$1].short.localeCompare(options[b].short);
1705
- return a$1.localeCompare(b);
1716
+ logger.log(Object.entries(options).sort(([a$1], [b$1]) => {
1717
+ if (options[a$1].short && !options[b$1].short) return -1;
1718
+ if (!options[a$1].short && options[b$1].short) return 1;
1719
+ if (options[a$1].short && options[b$1].short) return options[a$1].short.localeCompare(options[b$1].short);
1720
+ return a$1.localeCompare(b$1);
1706
1721
  }).map(([option, { type, short, hint, description: description$1 }]) => {
1707
1722
  let optionStr = ` --${option} `;
1708
1723
  option = camelCaseToKebabCase(option);
1709
1724
  if (short) optionStr += `-${short}, `;
1710
1725
  if (type === "string") optionStr += `<${hint ?? option}>`;
1711
1726
  if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
1712
- return require_parse_ast_index.colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
1727
+ return ansis.default.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
1713
1728
  }).join("\n"));
1714
1729
  logger.log("");
1715
- logger.log(`${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("EXAMPLES"))}`);
1730
+ logger.log(`${ansis.default.bold(ansis.default.underline("EXAMPLES"))}`);
1716
1731
  logger.log("");
1717
1732
  examples.forEach(({ title, command }, ord) => {
1718
1733
  logger.log(` ${ord + 1}. ${title}:`);
1719
- logger.log(` ${require_parse_ast_index.colors.cyan(command)}`);
1734
+ logger.log(` ${ansis.default.cyan(command)}`);
1720
1735
  logger.log("");
1721
1736
  });
1722
- logger.log(`${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("NOTES"))}`);
1737
+ logger.log(`${ansis.default.bold(ansis.default.underline("NOTES"))}`);
1723
1738
  logger.log("");
1724
1739
  notes.forEach((note) => {
1725
- logger.log(` * ${require_parse_ast_index.colors.gray(note)}`);
1740
+ logger.log(` * ${ansis.default.gray(note)}`);
1726
1741
  });
1727
1742
  }
1728
1743