rolldown 1.0.0-beta.2-commit.2666b23 → 1.0.0-beta.20

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