@rolldown/browser 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.10

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 (82) hide show
  1. package/dist/cli.mjs +961 -1551
  2. package/dist/config.d.mts +9 -6
  3. package/dist/config.mjs +9 -11
  4. package/dist/constructors-DsfxKD6A.js +68 -0
  5. package/dist/error-BeZaDkS8.js +157 -0
  6. package/dist/experimental-index.browser.mjs +278 -44
  7. package/dist/experimental-index.d.mts +228 -68
  8. package/dist/experimental-index.mjs +274 -55
  9. package/dist/experimental-runtime-types.d.ts +98 -0
  10. package/dist/filter-index.d.mts +104 -2
  11. package/dist/filter-index.mjs +144 -5
  12. package/dist/get-log-filter.d.mts +3 -0
  13. package/dist/get-log-filter.mjs +68 -0
  14. package/dist/index.browser.mjs +238 -3
  15. package/dist/index.d.mts +4 -3
  16. package/dist/index.mjs +53 -6
  17. package/dist/{shared/parse-ast-index-BHaE0ECV.cjs → normalize-string-or-regex-TtAGUp42.js} +74 -147
  18. package/dist/parallel-plugin-worker.mjs +27 -35
  19. package/dist/parallel-plugin.d.mts +7 -7
  20. package/dist/parallel-plugin.mjs +1 -2
  21. package/dist/parse-ast-index.d.mts +28 -5
  22. package/dist/parse-ast-index.mjs +60 -4
  23. package/dist/plugins-index.browser.mjs +40 -0
  24. package/dist/plugins-index.d.mts +33 -0
  25. package/dist/plugins-index.mjs +40 -0
  26. package/dist/resolve-tsconfig-DThkUPSZ.js +112 -0
  27. package/dist/rolldown-binding.wasi-browser.js +46 -24
  28. package/dist/rolldown-binding.wasi.cjs +67 -24
  29. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  30. package/dist/rolldown-build-Chx5S-TB.js +5349 -0
  31. package/dist/shared/bindingify-input-options-Czbczr8Z.mjs +2168 -0
  32. package/dist/shared/composable-filters-B2ByPP8y.mjs +224 -0
  33. package/dist/shared/constructors-BVnf_fH1.d.mts +37 -0
  34. package/dist/shared/constructors-CemeNi29.mjs +68 -0
  35. package/dist/shared/define-config-DJOr6Iwt.mjs +6 -0
  36. package/dist/shared/define-config-i6TWE2hm.d.mts +3855 -0
  37. package/dist/shared/error-CQ6njWsV.mjs +86 -0
  38. package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
  39. package/dist/shared/{load-config-D7UduHRZ.mjs → load-config-CxvL5JxT.mjs} +32 -36
  40. package/dist/shared/logging-C6h4g8dA.d.mts +50 -0
  41. package/dist/shared/{parse-ast-index-vu376yZ1.mjs → logs-D80CXhvg.mjs} +25 -123
  42. package/dist/shared/normalize-string-or-regex-CF3Uz6aU.mjs +57 -0
  43. package/dist/shared/parse-CRhjbrcT.mjs +73 -0
  44. package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-BYQIwEjg.mjs} +301 -310
  45. package/dist/shared/resolve-tsconfig-Cwoo4h_o.mjs +112 -0
  46. package/dist/shared/rolldown-C3wFxOwq.mjs +40 -0
  47. package/dist/shared/rolldown-build-ChZOz6BP.mjs +3318 -0
  48. package/dist/shared/transform-DEgNAQOQ.d.mts +149 -0
  49. package/dist/shared/types-Cx3HYorz.d.mts +1302 -0
  50. package/dist/shared/utils-6wxe_LMG.d.mts +22 -0
  51. package/dist/shared/watch-C1jC1oFT.mjs +373 -0
  52. package/dist/utils-index.browser.mjs +2414 -0
  53. package/dist/utils-index.d.mts +374 -0
  54. package/dist/utils-index.mjs +2415 -0
  55. package/package.json +33 -38
  56. package/dist/cli.cjs +0 -1748
  57. package/dist/cli.d.cts +0 -1
  58. package/dist/config.cjs +0 -12
  59. package/dist/config.d.cts +0 -11
  60. package/dist/experimental-index.cjs +0 -129
  61. package/dist/experimental-index.d.cts +0 -96
  62. package/dist/filter-index.cjs +0 -53
  63. package/dist/filter-index.d.cts +0 -3
  64. package/dist/index.cjs +0 -9
  65. package/dist/index.d.cts +0 -3
  66. package/dist/parallel-plugin-worker.cjs +0 -33
  67. package/dist/parallel-plugin-worker.d.cts +0 -1
  68. package/dist/parallel-plugin.cjs +0 -8
  69. package/dist/parallel-plugin.d.cts +0 -14
  70. package/dist/parse-ast-index.cjs +0 -4
  71. package/dist/parse-ast-index.d.cts +0 -9
  72. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  73. package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
  74. package/dist/shared/define-config.d-D4lKXE9V.d.cts +0 -1165
  75. package/dist/shared/define-config.d-Dm9iNdt9.d.mts +0 -1165
  76. package/dist/shared/dist-BMVjvV-v.cjs +0 -249
  77. package/dist/shared/dist-CAn6dxW6.mjs +0 -153
  78. package/dist/shared/load-config-CtKjQ8Mn.cjs +0 -125
  79. package/dist/shared/prompt-GFYxfPw7.mjs +0 -854
  80. package/dist/shared/src-D0nc44MQ.mjs +0 -4691
  81. package/dist/shared/src-s89s870G.cjs +0 -4647
  82. package/dist/src-CeWghjQt.js +0 -4329
@@ -0,0 +1,22 @@
1
+ import { BindingBuiltinPluginName } from "../binding.cjs";
2
+
3
+ //#region src/types/utils.d.ts
4
+ type MaybePromise<T> = T | Promise<T>;
5
+ /** @inline */
6
+ type NullValue<T = void> = T | undefined | null | void;
7
+ type PartialNull<T> = { [P in keyof T]: T[P] | null };
8
+ type MakeAsync<Function_> = Function_ extends ((this: infer This, ...parameters: infer Arguments) => infer Return) ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
9
+ type MaybeArray<T> = T | T[];
10
+ /** @inline */
11
+ type StringOrRegExp = string | RegExp;
12
+ //#endregion
13
+ //#region src/builtin-plugin/utils.d.ts
14
+ declare class BuiltinPlugin {
15
+ name: BindingBuiltinPluginName;
16
+ _options?: unknown;
17
+ /** Vite-specific option to control plugin ordering */
18
+ enforce?: "pre" | "post";
19
+ constructor(name: BindingBuiltinPluginName, _options?: unknown);
20
+ }
21
+ //#endregion
22
+ export { NullValue as a, MaybePromise as i, MakeAsync as n, PartialNull as o, MaybeArray as r, StringOrRegExp as s, BuiltinPlugin as t };
@@ -0,0 +1,373 @@
1
+ import { o as logMultipleWatcherOption } from "./logs-D80CXhvg.mjs";
2
+ import { v as LOG_LEVEL_WARN } from "./bindingify-input-options-Czbczr8Z.mjs";
3
+ import { h as arraify } from "./composable-filters-B2ByPP8y.mjs";
4
+ import { n as createBundlerOptions, u as PluginDriver } from "./rolldown-build-ChZOz6BP.mjs";
5
+ import { t as aggregateBindingErrorsIntoJsError } from "./error-CQ6njWsV.mjs";
6
+ import { BindingWatcher, shutdownAsyncRuntime } from "../rolldown-binding.wasi.cjs";
7
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
8
+ /**
9
+ * This is not the set of all possible signals.
10
+ *
11
+ * It IS, however, the set of all signals that trigger
12
+ * an exit on either Linux or BSD systems. Linux is a
13
+ * superset of the signal names supported on BSD, and
14
+ * the unknown signals just fail to register, so we can
15
+ * catch that easily enough.
16
+ *
17
+ * Windows signals are a different set, since there are
18
+ * signals that terminate Windows processes, but don't
19
+ * terminate (or don't even exist) on Posix systems.
20
+ *
21
+ * Don't bother with SIGKILL. It's uncatchable, which
22
+ * means that we can't fire any callbacks anyway.
23
+ *
24
+ * If a user does happen to register a handler on a non-
25
+ * fatal signal like SIGWINCH or something, and then
26
+ * exit, it'll end up firing `process.emit('exit')`, so
27
+ * the handler will be fired anyway.
28
+ *
29
+ * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
30
+ * artificially, inherently leave the process in a
31
+ * state from which it is not safe to try and enter JS
32
+ * listeners.
33
+ */
34
+ const signals = [];
35
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
36
+ if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
37
+ if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
38
+ //#endregion
39
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
40
+ const processOk = (process) => !!process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
41
+ const kExitEmitter = Symbol.for("signal-exit emitter");
42
+ const global = globalThis;
43
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
44
+ var Emitter = class {
45
+ emitted = {
46
+ afterExit: false,
47
+ exit: false
48
+ };
49
+ listeners = {
50
+ afterExit: [],
51
+ exit: []
52
+ };
53
+ count = 0;
54
+ id = Math.random();
55
+ constructor() {
56
+ if (global[kExitEmitter]) return global[kExitEmitter];
57
+ ObjectDefineProperty(global, kExitEmitter, {
58
+ value: this,
59
+ writable: false,
60
+ enumerable: false,
61
+ configurable: false
62
+ });
63
+ }
64
+ on(ev, fn) {
65
+ this.listeners[ev].push(fn);
66
+ }
67
+ removeListener(ev, fn) {
68
+ const list = this.listeners[ev];
69
+ const i = list.indexOf(fn);
70
+ /* c8 ignore start */
71
+ if (i === -1) return;
72
+ /* c8 ignore stop */
73
+ if (i === 0 && list.length === 1) list.length = 0;
74
+ else list.splice(i, 1);
75
+ }
76
+ emit(ev, code, signal) {
77
+ if (this.emitted[ev]) return false;
78
+ this.emitted[ev] = true;
79
+ let ret = false;
80
+ for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
81
+ if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
82
+ return ret;
83
+ }
84
+ };
85
+ var SignalExitBase = class {};
86
+ const signalExitWrap = (handler) => {
87
+ return {
88
+ onExit(cb, opts) {
89
+ return handler.onExit(cb, opts);
90
+ },
91
+ load() {
92
+ return handler.load();
93
+ },
94
+ unload() {
95
+ return handler.unload();
96
+ }
97
+ };
98
+ };
99
+ var SignalExitFallback = class extends SignalExitBase {
100
+ onExit() {
101
+ return () => {};
102
+ }
103
+ load() {}
104
+ unload() {}
105
+ };
106
+ var SignalExit = class extends SignalExitBase {
107
+ /* c8 ignore start */
108
+ #hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
109
+ /* c8 ignore stop */
110
+ #emitter = new Emitter();
111
+ #process;
112
+ #originalProcessEmit;
113
+ #originalProcessReallyExit;
114
+ #sigListeners = {};
115
+ #loaded = false;
116
+ constructor(process) {
117
+ super();
118
+ this.#process = process;
119
+ this.#sigListeners = {};
120
+ for (const sig of signals) this.#sigListeners[sig] = () => {
121
+ const listeners = this.#process.listeners(sig);
122
+ let { count } = this.#emitter;
123
+ /* c8 ignore start */
124
+ const p = process;
125
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
126
+ /* c8 ignore stop */
127
+ if (listeners.length === count) {
128
+ this.unload();
129
+ const ret = this.#emitter.emit("exit", null, sig);
130
+ /* c8 ignore start */
131
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
132
+ if (!ret) process.kill(process.pid, s);
133
+ }
134
+ };
135
+ this.#originalProcessReallyExit = process.reallyExit;
136
+ this.#originalProcessEmit = process.emit;
137
+ }
138
+ onExit(cb, opts) {
139
+ /* c8 ignore start */
140
+ if (!processOk(this.#process)) return () => {};
141
+ /* c8 ignore stop */
142
+ if (this.#loaded === false) this.load();
143
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
144
+ this.#emitter.on(ev, cb);
145
+ return () => {
146
+ this.#emitter.removeListener(ev, cb);
147
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
148
+ };
149
+ }
150
+ load() {
151
+ if (this.#loaded) return;
152
+ this.#loaded = true;
153
+ this.#emitter.count += 1;
154
+ for (const sig of signals) try {
155
+ const fn = this.#sigListeners[sig];
156
+ if (fn) this.#process.on(sig, fn);
157
+ } catch (_) {}
158
+ this.#process.emit = (ev, ...a) => {
159
+ return this.#processEmit(ev, ...a);
160
+ };
161
+ this.#process.reallyExit = (code) => {
162
+ return this.#processReallyExit(code);
163
+ };
164
+ }
165
+ unload() {
166
+ if (!this.#loaded) return;
167
+ this.#loaded = false;
168
+ signals.forEach((sig) => {
169
+ const listener = this.#sigListeners[sig];
170
+ /* c8 ignore start */
171
+ if (!listener) throw new Error("Listener not defined for signal: " + sig);
172
+ /* c8 ignore stop */
173
+ try {
174
+ this.#process.removeListener(sig, listener);
175
+ } catch (_) {}
176
+ /* c8 ignore stop */
177
+ });
178
+ this.#process.emit = this.#originalProcessEmit;
179
+ this.#process.reallyExit = this.#originalProcessReallyExit;
180
+ this.#emitter.count -= 1;
181
+ }
182
+ #processReallyExit(code) {
183
+ /* c8 ignore start */
184
+ if (!processOk(this.#process)) return 0;
185
+ this.#process.exitCode = code || 0;
186
+ /* c8 ignore stop */
187
+ this.#emitter.emit("exit", this.#process.exitCode, null);
188
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
189
+ }
190
+ #processEmit(ev, ...args) {
191
+ const og = this.#originalProcessEmit;
192
+ if (ev === "exit" && processOk(this.#process)) {
193
+ if (typeof args[0] === "number") this.#process.exitCode = args[0];
194
+ /* c8 ignore start */
195
+ const ret = og.call(this.#process, ev, ...args);
196
+ /* c8 ignore start */
197
+ this.#emitter.emit("exit", this.#process.exitCode, null);
198
+ /* c8 ignore stop */
199
+ return ret;
200
+ } else return og.call(this.#process, ev, ...args);
201
+ }
202
+ };
203
+ const process$1 = globalThis.process;
204
+ const { onExit: onExit$1, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
205
+ //#endregion
206
+ //#region src/utils/signal-exit.ts
207
+ function onExit(...args) {
208
+ if (typeof process === "object" && process.versions.webcontainer) {
209
+ process.on("exit", (code) => {
210
+ args[0](code, null);
211
+ });
212
+ return;
213
+ }
214
+ onExit$1(...args);
215
+ }
216
+ //#endregion
217
+ //#region src/api/watch/watch-emitter.ts
218
+ var WatcherEmitter = class {
219
+ listeners = /* @__PURE__ */ new Map();
220
+ on(event, listener) {
221
+ const listeners = this.listeners.get(event);
222
+ if (listeners) listeners.push(listener);
223
+ else this.listeners.set(event, [listener]);
224
+ return this;
225
+ }
226
+ off(event, listener) {
227
+ const listeners = this.listeners.get(event);
228
+ if (listeners) {
229
+ const index = listeners.indexOf(listener);
230
+ if (index !== -1) listeners.splice(index, 1);
231
+ }
232
+ return this;
233
+ }
234
+ clear(event) {
235
+ this.listeners.delete(event);
236
+ }
237
+ /** Async emit — sequential dispatch so side effects from earlier handlers
238
+ * (e.g. `event.result.close()` triggering `closeBundle`) are visible to later handlers. */
239
+ async emit(event, ...args) {
240
+ const handlers = this.listeners.get(event);
241
+ if (handlers?.length) for (const h of handlers) await h(...args);
242
+ }
243
+ async close() {}
244
+ };
245
+ //#endregion
246
+ //#region src/api/watch/watcher.ts
247
+ function createEventCallback(emitter) {
248
+ return async (event) => {
249
+ switch (event.eventKind()) {
250
+ case "event": {
251
+ const code = event.bundleEventKind();
252
+ if (code === "BUNDLE_END") {
253
+ const { duration, output, result } = event.bundleEndData();
254
+ await emitter.emit("event", {
255
+ code: "BUNDLE_END",
256
+ duration,
257
+ output: [output],
258
+ result
259
+ });
260
+ } else if (code === "ERROR") {
261
+ const data = event.bundleErrorData();
262
+ await emitter.emit("event", {
263
+ code: "ERROR",
264
+ error: aggregateBindingErrorsIntoJsError(data.error),
265
+ result: data.result
266
+ });
267
+ } else await emitter.emit("event", { code });
268
+ break;
269
+ }
270
+ case "change": {
271
+ const { path, kind } = event.watchChangeData();
272
+ await emitter.emit("change", path, { event: kind });
273
+ break;
274
+ }
275
+ case "restart":
276
+ await emitter.emit("restart");
277
+ break;
278
+ case "close":
279
+ await emitter.emit("close");
280
+ break;
281
+ }
282
+ };
283
+ }
284
+ var Watcher = class {
285
+ closed;
286
+ inner;
287
+ emitter;
288
+ stopWorkers;
289
+ constructor(emitter, inner, stopWorkers) {
290
+ this.closed = false;
291
+ this.inner = inner;
292
+ this.emitter = emitter;
293
+ const originClose = emitter.close.bind(emitter);
294
+ emitter.close = async () => {
295
+ await this.close();
296
+ originClose();
297
+ };
298
+ this.stopWorkers = stopWorkers;
299
+ process.nextTick(() => this.run());
300
+ }
301
+ async close() {
302
+ if (this.closed) return;
303
+ this.closed = true;
304
+ for (const stop of this.stopWorkers) await stop?.();
305
+ await this.inner.close();
306
+ shutdownAsyncRuntime();
307
+ }
308
+ async run() {
309
+ await this.inner.run();
310
+ this.inner.waitForClose();
311
+ }
312
+ };
313
+ async function createWatcher(emitter, input) {
314
+ const options = arraify(input);
315
+ const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
316
+ return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
317
+ })).flat());
318
+ warnMultiplePollingOptions(bundlerOptions);
319
+ const callback = createEventCallback(emitter);
320
+ new Watcher(emitter, new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), callback), bundlerOptions.map((option) => option.stopWorkers));
321
+ }
322
+ function warnMultiplePollingOptions(bundlerOptions) {
323
+ let found = false;
324
+ for (const option of bundlerOptions) {
325
+ const watch = option.inputOptions.watch;
326
+ const watcher = watch && typeof watch === "object" ? watch.watcher ?? watch.notify : void 0;
327
+ if (watcher && (watcher.usePolling != null || watcher.pollInterval != null)) {
328
+ if (found) {
329
+ option.onLog(LOG_LEVEL_WARN, logMultipleWatcherOption());
330
+ return;
331
+ }
332
+ found = true;
333
+ }
334
+ }
335
+ }
336
+ //#endregion
337
+ //#region src/api/watch/index.ts
338
+ /**
339
+ * The API compatible with Rollup's `watch` function.
340
+ *
341
+ * This function will rebuild the bundle when it detects that the individual modules have changed on disk.
342
+ *
343
+ * Note that when using this function, it is your responsibility to call `event.result.close()` in response to the `BUNDLE_END` event to avoid resource leaks.
344
+ *
345
+ * @param input The watch options object or the list of them.
346
+ * @returns A watcher object.
347
+ *
348
+ * @example
349
+ * ```js
350
+ * import { watch } from 'rolldown';
351
+ *
352
+ * const watcher = watch({ /* ... *\/ });
353
+ * watcher.on('event', (event) => {
354
+ * if (event.code === 'BUNDLE_END') {
355
+ * console.log(event.duration);
356
+ * event.result.close();
357
+ * }
358
+ * });
359
+ *
360
+ * // Stop watching
361
+ * watcher.close();
362
+ * ```
363
+ *
364
+ * @experimental
365
+ * @category Programmatic APIs
366
+ */
367
+ function watch(input) {
368
+ const emitter = new WatcherEmitter();
369
+ createWatcher(emitter, input);
370
+ return emitter;
371
+ }
372
+ //#endregion
373
+ export { onExit as n, watch as t };