@rolldown/browser 1.0.0-beta.34 → 1.0.0-beta.36

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 (51) hide show
  1. package/dist/cli.mjs +219 -230
  2. package/dist/config.d.mts +2 -2
  3. package/dist/config.mjs +4 -4
  4. package/dist/experimental-index.browser.mjs +22 -6
  5. package/dist/experimental-index.d.mts +16 -4
  6. package/dist/experimental-index.mjs +24 -8
  7. package/dist/filter-index.d.mts +2 -2
  8. package/dist/filter-index.mjs +1 -1
  9. package/dist/index.browser.mjs +1 -1
  10. package/dist/index.d.mts +2 -2
  11. package/dist/index.mjs +3 -3
  12. package/dist/parallel-plugin-worker.mjs +5 -6
  13. package/dist/parallel-plugin.d.mts +2 -2
  14. package/dist/parse-ast-index.d.mts +1 -1
  15. package/dist/parse-ast-index.mjs +1 -1
  16. package/dist/rolldown-binding.wasi-browser.js +4 -0
  17. package/dist/rolldown-binding.wasi.cjs +4 -0
  18. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  19. package/dist/shared/{binding-9k0egz6L.d.mts → binding-wK0CRIMb.d.mts} +1 -0
  20. package/dist/shared/{define-config-DzIQxNqU.d.mts → define-config-BcNhk996.d.mts} +30 -3
  21. package/dist/shared/{dist-ByKQkexh.mjs → dist-CHTC3-kR.mjs} +1 -1
  22. package/dist/shared/{load-config--VYNOtUY.mjs → load-config-M8Gvqt1X.mjs} +4 -6
  23. package/dist/shared/{parse-ast-index-C_CZT4St.mjs → parse-ast-index-C3TkGcEQ.mjs} +1 -1
  24. package/dist/shared/{prompt-C5jz26Zn.mjs → prompt-DuG2i9ud.mjs} +4 -7
  25. package/dist/shared/{src-B4V64IkU.mjs → src-Dc4fRARy.mjs} +143 -72
  26. package/dist/{src-Bl12Y5ab.js → src-Cl6h35QH.js} +141 -71
  27. package/package.json +10 -24
  28. package/dist/cli.cjs +0 -1766
  29. package/dist/cli.d.cts +0 -1
  30. package/dist/config.cjs +0 -12
  31. package/dist/config.d.cts +0 -10
  32. package/dist/experimental-index.cjs +0 -160
  33. package/dist/experimental-index.d.cts +0 -90
  34. package/dist/filter-index.cjs +0 -53
  35. package/dist/filter-index.d.cts +0 -4
  36. package/dist/index.cjs +0 -9
  37. package/dist/index.d.cts +0 -3
  38. package/dist/parallel-plugin-worker.cjs +0 -33
  39. package/dist/parallel-plugin-worker.d.cts +0 -1
  40. package/dist/parallel-plugin.cjs +0 -8
  41. package/dist/parallel-plugin.d.cts +0 -14
  42. package/dist/parse-ast-index.cjs +0 -4
  43. package/dist/parse-ast-index.d.cts +0 -8
  44. package/dist/shared/binding-D13M6Llu.d.cts +0 -1425
  45. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  46. package/dist/shared/define-config-D5AluabE.d.cts +0 -1394
  47. package/dist/shared/dist-CK0hotcm.cjs +0 -240
  48. package/dist/shared/load-config-DfHD1OI9.cjs +0 -125
  49. package/dist/shared/parse-ast-index-ChWj_C49.cjs +0 -326
  50. package/dist/shared/prompt-QNI93ne7.cjs +0 -854
  51. package/dist/shared/src-McCMqGpa.cjs +0 -4738
package/dist/cli.mjs CHANGED
@@ -1,13 +1,214 @@
1
- import { __commonJS, __toESM, ansis_default, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "./shared/src-B4V64IkU.mjs";
2
- import "./shared/parse-ast-index-C_CZT4St.mjs";
3
- import { arraify } from "./shared/dist-ByKQkexh.mjs";
4
- import { loadConfig } from "./shared/load-config--VYNOtUY.mjs";
1
+ import { __commonJS, __toESM, ansis_default, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "./shared/src-Dc4fRARy.mjs";
2
+ import "./shared/parse-ast-index-C3TkGcEQ.mjs";
3
+ import { arraify } from "./shared/dist-CHTC3-kR.mjs";
4
+ import { loadConfig } from "./shared/load-config-M8Gvqt1X.mjs";
5
5
  import path, { sep } from "node:path";
6
6
  import process$1 from "node:process";
7
7
  import { formatWithOptions, parseArgs } from "node:util";
8
8
  import * as tty from "node:tty";
9
9
  import { performance } from "node:perf_hooks";
10
10
 
11
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
12
+ /**
13
+ * This is not the set of all possible signals.
14
+ *
15
+ * It IS, however, the set of all signals that trigger
16
+ * an exit on either Linux or BSD systems. Linux is a
17
+ * superset of the signal names supported on BSD, and
18
+ * the unknown signals just fail to register, so we can
19
+ * catch that easily enough.
20
+ *
21
+ * Windows signals are a different set, since there are
22
+ * signals that terminate Windows processes, but don't
23
+ * terminate (or don't even exist) on Posix systems.
24
+ *
25
+ * Don't bother with SIGKILL. It's uncatchable, which
26
+ * means that we can't fire any callbacks anyway.
27
+ *
28
+ * If a user does happen to register a handler on a non-
29
+ * fatal signal like SIGWINCH or something, and then
30
+ * exit, it'll end up firing `process.emit('exit')`, so
31
+ * the handler will be fired anyway.
32
+ *
33
+ * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
34
+ * artificially, inherently leave the process in a
35
+ * state from which it is not safe to try and enter JS
36
+ * listeners.
37
+ */
38
+ const signals = [];
39
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
40
+ if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
41
+ if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
42
+
43
+ //#endregion
44
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
45
+ 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";
46
+ const kExitEmitter = Symbol.for("signal-exit emitter");
47
+ const global = globalThis;
48
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
49
+ var Emitter = class {
50
+ emitted = {
51
+ afterExit: false,
52
+ exit: false
53
+ };
54
+ listeners = {
55
+ afterExit: [],
56
+ exit: []
57
+ };
58
+ count = 0;
59
+ id = Math.random();
60
+ constructor() {
61
+ if (global[kExitEmitter]) return global[kExitEmitter];
62
+ ObjectDefineProperty(global, kExitEmitter, {
63
+ value: this,
64
+ writable: false,
65
+ enumerable: false,
66
+ configurable: false
67
+ });
68
+ }
69
+ on(ev, fn) {
70
+ this.listeners[ev].push(fn);
71
+ }
72
+ removeListener(ev, fn) {
73
+ const list = this.listeners[ev];
74
+ const i$1 = list.indexOf(fn);
75
+ /* c8 ignore start */
76
+ if (i$1 === -1) return;
77
+ /* c8 ignore stop */
78
+ if (i$1 === 0 && list.length === 1) list.length = 0;
79
+ else list.splice(i$1, 1);
80
+ }
81
+ emit(ev, code, signal) {
82
+ if (this.emitted[ev]) return false;
83
+ this.emitted[ev] = true;
84
+ let ret = false;
85
+ for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
86
+ if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
87
+ return ret;
88
+ }
89
+ };
90
+ var SignalExitBase = class {};
91
+ const signalExitWrap = (handler) => {
92
+ return {
93
+ onExit(cb, opts) {
94
+ return handler.onExit(cb, opts);
95
+ },
96
+ load() {
97
+ return handler.load();
98
+ },
99
+ unload() {
100
+ return handler.unload();
101
+ }
102
+ };
103
+ };
104
+ var SignalExitFallback = class extends SignalExitBase {
105
+ onExit() {
106
+ return () => {};
107
+ }
108
+ load() {}
109
+ unload() {}
110
+ };
111
+ var SignalExit = class extends SignalExitBase {
112
+ /* c8 ignore start */
113
+ #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
114
+ /* c8 ignore stop */
115
+ #emitter = new Emitter();
116
+ #process;
117
+ #originalProcessEmit;
118
+ #originalProcessReallyExit;
119
+ #sigListeners = {};
120
+ #loaded = false;
121
+ constructor(process$3) {
122
+ super();
123
+ this.#process = process$3;
124
+ this.#sigListeners = {};
125
+ for (const sig of signals) this.#sigListeners[sig] = () => {
126
+ const listeners = this.#process.listeners(sig);
127
+ let { count } = this.#emitter;
128
+ /* c8 ignore start */
129
+ const p = process$3;
130
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
131
+ /* c8 ignore stop */
132
+ if (listeners.length === count) {
133
+ this.unload();
134
+ const ret = this.#emitter.emit("exit", null, sig);
135
+ /* c8 ignore start */
136
+ const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
137
+ if (!ret) process$3.kill(process$3.pid, s$1);
138
+ }
139
+ };
140
+ this.#originalProcessReallyExit = process$3.reallyExit;
141
+ this.#originalProcessEmit = process$3.emit;
142
+ }
143
+ onExit(cb, opts) {
144
+ /* c8 ignore start */
145
+ if (!processOk(this.#process)) return () => {};
146
+ /* c8 ignore stop */
147
+ if (this.#loaded === false) this.load();
148
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
149
+ this.#emitter.on(ev, cb);
150
+ return () => {
151
+ this.#emitter.removeListener(ev, cb);
152
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
153
+ };
154
+ }
155
+ load() {
156
+ if (this.#loaded) return;
157
+ this.#loaded = true;
158
+ this.#emitter.count += 1;
159
+ for (const sig of signals) try {
160
+ const fn = this.#sigListeners[sig];
161
+ if (fn) this.#process.on(sig, fn);
162
+ } catch (_$1) {}
163
+ this.#process.emit = (ev, ...a$1) => {
164
+ return this.#processEmit(ev, ...a$1);
165
+ };
166
+ this.#process.reallyExit = (code) => {
167
+ return this.#processReallyExit(code);
168
+ };
169
+ }
170
+ unload() {
171
+ if (!this.#loaded) return;
172
+ this.#loaded = false;
173
+ signals.forEach((sig) => {
174
+ const listener = this.#sigListeners[sig];
175
+ /* c8 ignore start */
176
+ if (!listener) throw new Error("Listener not defined for signal: " + sig);
177
+ /* c8 ignore stop */
178
+ try {
179
+ this.#process.removeListener(sig, listener);
180
+ } catch (_$1) {}
181
+ /* c8 ignore stop */
182
+ });
183
+ this.#process.emit = this.#originalProcessEmit;
184
+ this.#process.reallyExit = this.#originalProcessReallyExit;
185
+ this.#emitter.count -= 1;
186
+ }
187
+ #processReallyExit(code) {
188
+ /* c8 ignore start */
189
+ if (!processOk(this.#process)) return 0;
190
+ this.#process.exitCode = code || 0;
191
+ /* c8 ignore stop */
192
+ this.#emitter.emit("exit", this.#process.exitCode, null);
193
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
194
+ }
195
+ #processEmit(ev, ...args) {
196
+ const og = this.#originalProcessEmit;
197
+ if (ev === "exit" && processOk(this.#process)) {
198
+ if (typeof args[0] === "number") this.#process.exitCode = args[0];
199
+ /* c8 ignore start */
200
+ const ret = og.call(this.#process, ev, ...args);
201
+ /* c8 ignore start */
202
+ this.#emitter.emit("exit", this.#process.exitCode, null);
203
+ /* c8 ignore stop */
204
+ return ret;
205
+ } else return og.call(this.#process, ev, ...args);
206
+ }
207
+ };
208
+ const process$2 = globalThis.process;
209
+ const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
210
+
211
+ //#endregion
11
212
  //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
12
213
  const LogLevels = {
13
214
  silent: Number.NEGATIVE_INFINITY,
@@ -397,12 +598,10 @@ function createConsola$1(options$1 = {}) {
397
598
  //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
398
599
  function parseStack(stack, message) {
399
600
  const cwd$1 = process.cwd() + sep;
400
- const lines = stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd$1, ""));
401
- return lines;
601
+ return stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd$1, ""));
402
602
  }
403
603
  function writeStream(data, stream) {
404
- const write = stream.__write || stream.write;
405
- return write.call(stream, data);
604
+ return (stream.__write || stream.write).call(stream, data);
406
605
  }
407
606
  const bracket = (x) => x ? `[${x}]` : "";
408
607
  var BasicReporter = class {
@@ -806,11 +1005,9 @@ function G() {
806
1005
  const e = F.find((s$1) => s$1[0]);
807
1006
  if (e) return { name: e[1] };
808
1007
  }
809
- const P = G();
810
- P?.name;
1008
+ G()?.name;
811
1009
  function ansiRegex({ onlyFirst = false } = {}) {
812
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
813
- 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("|");
1010
+ const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
814
1011
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
815
1012
  }
816
1013
  const regex = ansiRegex();
@@ -896,8 +1093,7 @@ const TYPE_ICONS = {
896
1093
  log: ""
897
1094
  };
898
1095
  function stringWidth(str) {
899
- const hasICU = typeof Intl === "object";
900
- if (!hasICU || !Intl.Segmenter) return stripAnsi(str).length;
1096
+ if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi(str).length;
901
1097
  return stringWidth$1(str);
902
1098
  }
903
1099
  var FancyReporter = class extends BasicReporter {
@@ -949,16 +1145,15 @@ function getBgColor(color = "bgWhite") {
949
1145
  function createConsola(options$1 = {}) {
950
1146
  let level = _getDefaultLogLevel();
951
1147
  if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
952
- const consola2 = createConsola$1({
1148
+ return createConsola$1({
953
1149
  level,
954
1150
  defaults: { level },
955
1151
  stdout: process.stdout,
956
1152
  stderr: process.stderr,
957
- prompt: (...args) => import("./shared/prompt-C5jz26Zn.mjs").then((m) => m.prompt(...args)),
1153
+ prompt: (...args) => import("./shared/prompt-DuG2i9ud.mjs").then((m) => m.prompt(...args)),
958
1154
  reporters: options$1.reporters || [options$1.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
959
1155
  ...options$1
960
1156
  });
961
- return consola2;
962
1157
  }
963
1158
  function _getDefaultLogLevel() {
964
1159
  if (g) return LogLevels.debug;
@@ -1114,8 +1309,7 @@ function normalizeCliOptions(cliOptions, positionals) {
1114
1309
  "watch"
1115
1310
  ];
1116
1311
  for (let [key, value] of Object.entries(options$1)) {
1117
- const keys = key.split(".");
1118
- const [primary] = keys;
1312
+ const [primary] = key.split(".");
1119
1313
  if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
1120
1314
  else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
1121
1315
  else if (!reservedKeys.includes(key)) {
@@ -1134,9 +1328,8 @@ const objectSchema = getJsonSchema();
1134
1328
  const flattenedSchema = flattenSchema(objectSchema.properties);
1135
1329
  const options = Object.fromEntries(Object.entries(flattenedSchema).filter(([_key, schema]) => getSchemaType(schema) !== "never").map(([key, schema]) => {
1136
1330
  const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
1137
- const type = getSchemaType(schema);
1138
1331
  const result = {
1139
- type: type === "boolean" ? "boolean" : "string",
1332
+ type: getSchemaType(schema) === "boolean" ? "boolean" : "string",
1140
1333
  description: schema?.description ?? config?.description ?? "",
1141
1334
  hint: config?.hint
1142
1335
  };
@@ -1220,207 +1413,6 @@ function parseCliArguments() {
1220
1413
  return normalizeCliOptions(values, positionals);
1221
1414
  }
1222
1415
 
1223
- //#endregion
1224
- //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
1225
- /**
1226
- * This is not the set of all possible signals.
1227
- *
1228
- * It IS, however, the set of all signals that trigger
1229
- * an exit on either Linux or BSD systems. Linux is a
1230
- * superset of the signal names supported on BSD, and
1231
- * the unknown signals just fail to register, so we can
1232
- * catch that easily enough.
1233
- *
1234
- * Windows signals are a different set, since there are
1235
- * signals that terminate Windows processes, but don't
1236
- * terminate (or don't even exist) on Posix systems.
1237
- *
1238
- * Don't bother with SIGKILL. It's uncatchable, which
1239
- * means that we can't fire any callbacks anyway.
1240
- *
1241
- * If a user does happen to register a handler on a non-
1242
- * fatal signal like SIGWINCH or something, and then
1243
- * exit, it'll end up firing `process.emit('exit')`, so
1244
- * the handler will be fired anyway.
1245
- *
1246
- * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
1247
- * artificially, inherently leave the process in a
1248
- * state from which it is not safe to try and enter JS
1249
- * listeners.
1250
- */
1251
- const signals = [];
1252
- signals.push("SIGHUP", "SIGINT", "SIGTERM");
1253
- if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
1254
- if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
1255
-
1256
- //#endregion
1257
- //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
1258
- 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";
1259
- const kExitEmitter = Symbol.for("signal-exit emitter");
1260
- const global = globalThis;
1261
- const ObjectDefineProperty = Object.defineProperty.bind(Object);
1262
- var Emitter = class {
1263
- emitted = {
1264
- afterExit: false,
1265
- exit: false
1266
- };
1267
- listeners = {
1268
- afterExit: [],
1269
- exit: []
1270
- };
1271
- count = 0;
1272
- id = Math.random();
1273
- constructor() {
1274
- if (global[kExitEmitter]) return global[kExitEmitter];
1275
- ObjectDefineProperty(global, kExitEmitter, {
1276
- value: this,
1277
- writable: false,
1278
- enumerable: false,
1279
- configurable: false
1280
- });
1281
- }
1282
- on(ev, fn) {
1283
- this.listeners[ev].push(fn);
1284
- }
1285
- removeListener(ev, fn) {
1286
- const list = this.listeners[ev];
1287
- const i$1 = list.indexOf(fn);
1288
- /* c8 ignore start */
1289
- if (i$1 === -1) return;
1290
- /* c8 ignore stop */
1291
- if (i$1 === 0 && list.length === 1) list.length = 0;
1292
- else list.splice(i$1, 1);
1293
- }
1294
- emit(ev, code, signal) {
1295
- if (this.emitted[ev]) return false;
1296
- this.emitted[ev] = true;
1297
- let ret = false;
1298
- for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
1299
- if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
1300
- return ret;
1301
- }
1302
- };
1303
- var SignalExitBase = class {};
1304
- const signalExitWrap = (handler) => {
1305
- return {
1306
- onExit(cb, opts) {
1307
- return handler.onExit(cb, opts);
1308
- },
1309
- load() {
1310
- return handler.load();
1311
- },
1312
- unload() {
1313
- return handler.unload();
1314
- }
1315
- };
1316
- };
1317
- var SignalExitFallback = class extends SignalExitBase {
1318
- onExit() {
1319
- return () => {};
1320
- }
1321
- load() {}
1322
- unload() {}
1323
- };
1324
- var SignalExit = class extends SignalExitBase {
1325
- /* c8 ignore start */
1326
- #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
1327
- /* c8 ignore stop */
1328
- #emitter = new Emitter();
1329
- #process;
1330
- #originalProcessEmit;
1331
- #originalProcessReallyExit;
1332
- #sigListeners = {};
1333
- #loaded = false;
1334
- constructor(process$3) {
1335
- super();
1336
- this.#process = process$3;
1337
- this.#sigListeners = {};
1338
- for (const sig of signals) this.#sigListeners[sig] = () => {
1339
- const listeners = this.#process.listeners(sig);
1340
- let { count } = this.#emitter;
1341
- /* c8 ignore start */
1342
- const p = process$3;
1343
- if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
1344
- /* c8 ignore stop */
1345
- if (listeners.length === count) {
1346
- this.unload();
1347
- const ret = this.#emitter.emit("exit", null, sig);
1348
- /* c8 ignore start */
1349
- const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
1350
- if (!ret) process$3.kill(process$3.pid, s$1);
1351
- }
1352
- };
1353
- this.#originalProcessReallyExit = process$3.reallyExit;
1354
- this.#originalProcessEmit = process$3.emit;
1355
- }
1356
- onExit(cb, opts) {
1357
- /* c8 ignore start */
1358
- if (!processOk(this.#process)) return () => {};
1359
- /* c8 ignore stop */
1360
- if (this.#loaded === false) this.load();
1361
- const ev = opts?.alwaysLast ? "afterExit" : "exit";
1362
- this.#emitter.on(ev, cb);
1363
- return () => {
1364
- this.#emitter.removeListener(ev, cb);
1365
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
1366
- };
1367
- }
1368
- load() {
1369
- if (this.#loaded) return;
1370
- this.#loaded = true;
1371
- this.#emitter.count += 1;
1372
- for (const sig of signals) try {
1373
- const fn = this.#sigListeners[sig];
1374
- if (fn) this.#process.on(sig, fn);
1375
- } catch (_$1) {}
1376
- this.#process.emit = (ev, ...a$1) => {
1377
- return this.#processEmit(ev, ...a$1);
1378
- };
1379
- this.#process.reallyExit = (code) => {
1380
- return this.#processReallyExit(code);
1381
- };
1382
- }
1383
- unload() {
1384
- if (!this.#loaded) return;
1385
- this.#loaded = false;
1386
- signals.forEach((sig) => {
1387
- const listener = this.#sigListeners[sig];
1388
- /* c8 ignore start */
1389
- if (!listener) throw new Error("Listener not defined for signal: " + sig);
1390
- /* c8 ignore stop */
1391
- try {
1392
- this.#process.removeListener(sig, listener);
1393
- } catch (_$1) {}
1394
- /* c8 ignore stop */
1395
- });
1396
- this.#process.emit = this.#originalProcessEmit;
1397
- this.#process.reallyExit = this.#originalProcessReallyExit;
1398
- this.#emitter.count -= 1;
1399
- }
1400
- #processReallyExit(code) {
1401
- /* c8 ignore start */
1402
- if (!processOk(this.#process)) return 0;
1403
- this.#process.exitCode = code || 0;
1404
- /* c8 ignore stop */
1405
- this.#emitter.emit("exit", this.#process.exitCode, null);
1406
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
1407
- }
1408
- #processEmit(ev, ...args) {
1409
- const og = this.#originalProcessEmit;
1410
- if (ev === "exit" && processOk(this.#process)) {
1411
- if (typeof args[0] === "number") this.#process.exitCode = args[0];
1412
- /* c8 ignore start */
1413
- const ret = og.call(this.#process, ev, ...args);
1414
- /* c8 ignore start */
1415
- this.#emitter.emit("exit", this.#process.exitCode, null);
1416
- /* c8 ignore stop */
1417
- return ret;
1418
- } else return og.call(this.#process, ev, ...args);
1419
- }
1420
- };
1421
- const process$2 = globalThis.process;
1422
- const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
1423
-
1424
1416
  //#endregion
1425
1417
  //#region src/utils/clear-screen.ts
1426
1418
  const CLEAR_SCREEN = "\x1Bc";
@@ -1433,8 +1425,8 @@ function getClearScreenFunction(options$1) {
1433
1425
  }
1434
1426
 
1435
1427
  //#endregion
1436
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.82.3/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
1437
- var require_usingCtx = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.82.3/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js": ((exports, module) => {
1428
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
1429
+ var require_usingCtx = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.87.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js": ((exports, module) => {
1438
1430
  function _usingCtx() {
1439
1431
  var r$1 = "function" == typeof SuppressedError ? SuppressedError : function(r$2, e$1) {
1440
1432
  var n$2 = Error();
@@ -1512,16 +1504,14 @@ async function bundleWithCliOptions(cliOptions) {
1512
1504
  try {
1513
1505
  var _usingCtx$1 = (0, import_usingCtx.default)();
1514
1506
  if (cliOptions.output.dir || cliOptions.output.file) {
1515
- const operation = cliOptions.watch ? watchInner : bundleInner;
1516
- await operation({}, cliOptions);
1507
+ await (cliOptions.watch ? watchInner : bundleInner)({}, cliOptions);
1517
1508
  return;
1518
1509
  }
1519
1510
  if (cliOptions.watch) {
1520
1511
  logger.error("You must specify `output.dir` to use watch mode");
1521
1512
  process.exit(1);
1522
1513
  }
1523
- const build = _usingCtx$1.a(await rolldown(cliOptions.input));
1524
- const { output: outputs } = await build.generate(cliOptions.output);
1514
+ const { output: outputs } = await _usingCtx$1.a(await rolldown(cliOptions.input)).generate(cliOptions.output);
1525
1515
  if (outputs.length === 0) {
1526
1516
  logger.error("No output generated");
1527
1517
  process.exit(1);
@@ -1604,8 +1594,7 @@ async function bundleInner(config, cliOptions) {
1604
1594
  }
1605
1595
  result.forEach(printBundleOutputPretty);
1606
1596
  logger.log(``);
1607
- const endTime = performance.now();
1608
- const duration = endTime - startTime;
1597
+ const duration = performance.now() - startTime;
1609
1598
  logger.success(`rolldown v${version} Finished in ${ansis_default.green(ms(duration))}`);
1610
1599
  }
1611
1600
  function printBundleOutputPretty(output) {
package/dist/config.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import "./shared/binding-9k0egz6L.mjs";
2
- import { ConfigExport, defineConfig } from "./shared/define-config-DzIQxNqU.mjs";
1
+ import "./shared/binding-wK0CRIMb.mjs";
2
+ import { ConfigExport, defineConfig } from "./shared/define-config-BcNhk996.mjs";
3
3
 
4
4
  //#region src/utils/load-config.d.ts
5
5
  declare function loadConfig(configPath: string): Promise<ConfigExport>;
package/dist/config.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { defineConfig, version } from "./shared/src-B4V64IkU.mjs";
2
- import "./shared/parse-ast-index-C_CZT4St.mjs";
3
- import "./shared/dist-ByKQkexh.mjs";
4
- import { loadConfig } from "./shared/load-config--VYNOtUY.mjs";
1
+ import { defineConfig, version } from "./shared/src-Dc4fRARy.mjs";
2
+ import "./shared/parse-ast-index-C3TkGcEQ.mjs";
3
+ import "./shared/dist-CHTC3-kR.mjs";
4
+ import { loadConfig } from "./shared/load-config-M8Gvqt1X.mjs";
5
5
 
6
6
  //#region src/config.ts
7
7
  const VERSION = version;
@@ -1,14 +1,21 @@
1
- import { BuiltinPlugin, PluginDriver, assetPlugin, buildImportAnalysisPlugin, createBundlerImpl, createBundlerOptions, dynamicImportVarsPlugin, esmExternalRequirePlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./src-Bl12Y5ab.js";
1
+ import { PluginDriver, assetPlugin, buildImportAnalysisPlugin, createBuiltinPlugin, createBundlerImpl, createBundlerOptions, dynamicImportVarsPlugin, esmExternalRequirePlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./src-Cl6h35QH.js";
2
2
  import { BindingBundler, BindingDevEngine, ResolverFactory, isolatedDeclaration, moduleRunnerTransform, transform } from "./rolldown-binding.wasi-browser.js";
3
3
 
4
4
  //#region src/api/dev/dev-engine.ts
5
5
  var DevEngine = class DevEngine {
6
6
  #inner;
7
7
  #cachedBuildFinishPromise = null;
8
- static async create(inputOptions, outputOptions) {
8
+ static async create(inputOptions, outputOptions = {}, devOptions = {}) {
9
9
  inputOptions = await PluginDriver.callOptionsHook(inputOptions);
10
10
  const options = await createBundlerOptions(inputOptions, outputOptions, false);
11
- const inner = new BindingDevEngine(options.bundlerOptions);
11
+ const bindingDevOptions = {
12
+ onHmrUpdates: devOptions.onHmrUpdates,
13
+ watch: devOptions.watch && {
14
+ usePolling: devOptions.watch.usePolling,
15
+ pollInterval: devOptions.watch.pollInterval
16
+ }
17
+ };
18
+ const inner = new BindingDevEngine(options.bundlerOptions, bindingDevOptions);
12
19
  return new DevEngine(inner);
13
20
  }
14
21
  constructor(inner) {
@@ -25,6 +32,12 @@ var DevEngine = class DevEngine {
25
32
  this.#cachedBuildFinishPromise = promise;
26
33
  return promise;
27
34
  }
35
+ async ensureLatestBuild() {
36
+ await this.#inner.ensureLatestBuild();
37
+ }
38
+ async invalidate(file, firstInvalidatedBy) {
39
+ return this.#inner.invalidate(file, firstInvalidatedBy);
40
+ }
28
41
  };
29
42
 
30
43
  //#endregion
@@ -55,7 +68,7 @@ function defineParallelPlugin(pluginPath) {
55
68
  //#endregion
56
69
  //#region src/builtin-plugin/alias-plugin.ts
57
70
  function aliasPlugin(config) {
58
- return new BuiltinPlugin("builtin:alias", config);
71
+ return createBuiltinPlugin("builtin:alias", config);
59
72
  }
60
73
 
61
74
  //#endregion
@@ -83,7 +96,10 @@ function aliasPlugin(config) {
83
96
  * ```
84
97
  */
85
98
  function replacePlugin(values = {}, options = {}) {
86
- return new BuiltinPlugin("builtin:replace", {
99
+ Object.keys(values).forEach((key) => {
100
+ values[key] = values[key].toString();
101
+ });
102
+ return createBuiltinPlugin("builtin:replace", {
87
103
  ...options,
88
104
  values
89
105
  });
@@ -99,7 +115,7 @@ function transformPlugin(config) {
99
115
  jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
100
116
  jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
101
117
  };
102
- return new BuiltinPlugin("builtin:transform", config);
118
+ return createBuiltinPlugin("builtin:transform", config);
103
119
  }
104
120
 
105
121
  //#endregion
@@ -1,13 +1,25 @@
1
- import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingDynamicImportVarsPluginConfig, BindingEsmExternalRequirePluginConfig, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWasmHelperPluginConfig, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform } from "./shared/binding-9k0egz6L.mjs";
2
- import { BuiltinPlugin, InputOptions, OutputOptions, StringOrRegExp, defineParallelPlugin } from "./shared/define-config-DzIQxNqU.mjs";
1
+ import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingDynamicImportVarsPluginConfig, BindingEsmExternalRequirePluginConfig, BindingHmrUpdate, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWasmHelperPluginConfig, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform } from "./shared/binding-wK0CRIMb.mjs";
2
+ import { BuiltinPlugin, InputOptions, OutputOptions, StringOrRegExp, defineParallelPlugin } from "./shared/define-config-BcNhk996.mjs";
3
3
 
4
+ //#region src/api/dev/dev-options.d.ts
5
+ interface DevWatchOptions {
6
+ usePolling?: boolean;
7
+ pollInterval?: number;
8
+ }
9
+ interface DevOptions {
10
+ onHmrUpdates?: (updates: BindingHmrUpdate[]) => void | Promise<void>;
11
+ watch?: DevWatchOptions;
12
+ }
13
+ //#endregion
4
14
  //#region src/api/dev/dev-engine.d.ts
5
15
  declare class DevEngine {
6
16
  #private;
7
- static create(inputOptions: InputOptions, outputOptions: OutputOptions): Promise<DevEngine>;
17
+ static create(inputOptions: InputOptions, outputOptions?: OutputOptions, devOptions?: DevOptions): Promise<DevEngine>;
8
18
  private constructor();
9
19
  run(): Promise<void>;
10
20
  ensureCurrentBuildFinish(): Promise<void>;
21
+ ensureLatestBuild(): Promise<void>;
22
+ invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrUpdate>;
11
23
  }
12
24
  //#endregion
13
25
  //#region src/api/dev/index.d.ts
@@ -87,4 +99,4 @@ type TransformPluginConfig = Omit<BindingTransformPluginConfig, "include" | "exc
87
99
  };
88
100
  declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
89
101
  //#endregion
90
- export { DevEngine, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
102
+ export { DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };