@rollipop/rolldown 1.0.0-rc.1 → 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 (50) hide show
  1. package/bin/cli.mjs +0 -1
  2. package/dist/cli.mjs +705 -1102
  3. package/dist/config.d.mts +9 -5
  4. package/dist/config.mjs +4 -14
  5. package/dist/experimental-index.d.mts +189 -54
  6. package/dist/experimental-index.mjs +106 -22
  7. package/dist/experimental-runtime-types.d.ts +0 -5
  8. package/dist/filter-index.d.mts +1 -2
  9. package/dist/filter-index.mjs +25 -8
  10. package/dist/get-log-filter.d.mts +3 -7
  11. package/dist/get-log-filter.mjs +23 -3
  12. package/dist/index.d.mts +4 -4
  13. package/dist/index.mjs +6 -13
  14. package/dist/parallel-plugin-worker.mjs +4 -8
  15. package/dist/parallel-plugin.d.mts +3 -4
  16. package/dist/parallel-plugin.mjs +1 -2
  17. package/dist/parse-ast-index.d.mts +26 -2
  18. package/dist/parse-ast-index.mjs +60 -4
  19. package/dist/plugins-index.d.mts +8 -5
  20. package/dist/plugins-index.mjs +8 -8
  21. package/dist/shared/{binding-tNJoEqAa.mjs → binding-D_jQsHun.mjs} +41 -43
  22. package/dist/shared/binding-hSQGgsUz.d.mts +1877 -0
  23. package/dist/shared/{bindingify-input-options-CfhrNd_y.mjs → bindingify-input-options-DfXGy4QO.mjs} +127 -167
  24. package/dist/shared/{constructors-414MPkgB.mjs → constructors-B-HbV10G.mjs} +14 -7
  25. package/dist/shared/{constructors--k1uxZrh.d.mts → constructors-DMl58KN5.d.mts} +13 -4
  26. package/dist/shared/define-config-BSxBeCq6.d.mts +3810 -0
  27. package/dist/shared/{define-config-BVG4QvnP.mjs → define-config-DJOr6Iwt.mjs} +1 -2
  28. package/dist/shared/error-D5tMcn3l.mjs +85 -0
  29. package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
  30. package/dist/shared/{load-config-Qtd9pHJ5.mjs → load-config-CNjYgiQv.mjs} +11 -5
  31. package/dist/shared/{logging-wIy4zY9I.d.mts → logging-C6h4g8dA.d.mts} +6 -6
  32. package/dist/shared/{logs-NH298mHo.mjs → logs-D80CXhvg.mjs} +6 -9
  33. package/dist/shared/{misc-CCZIsXVO.mjs → misc-DJYbNKZX.mjs} +1 -2
  34. package/dist/shared/{normalize-string-or-regex-DeB7vQ75.mjs → normalize-string-or-regex-B8PEhdn1.mjs} +22 -17
  35. package/dist/shared/parse-iQx2ihYn.mjs +74 -0
  36. package/dist/shared/{prompt-tlfjalEt.mjs → prompt-BYQIwEjg.mjs} +4 -6
  37. package/dist/shared/resolve-tsconfig-CxoM-bno.mjs +113 -0
  38. package/dist/shared/{rolldown-BMzJcmQ7.mjs → rolldown-C0o3hS3w.mjs} +2 -4
  39. package/dist/shared/rolldown-build-80GULIOI.mjs +3326 -0
  40. package/dist/shared/transform-DY2pi3Qm.d.mts +149 -0
  41. package/dist/shared/{watch-HmN4U4B9.mjs → watch-C2am0Ahc.mjs} +73 -78
  42. package/dist/utils-index.d.mts +376 -0
  43. package/dist/utils-index.mjs +2414 -0
  44. package/package.json +23 -21
  45. package/dist/cli-setup.d.mts +0 -1
  46. package/dist/cli-setup.mjs +0 -17
  47. package/dist/shared/binding-B92Lq__Q.d.mts +0 -1687
  48. package/dist/shared/define-config-D8xP5iyL.d.mts +0 -3463
  49. package/dist/shared/parse-ast-index-BcP4Ts_P.mjs +0 -99
  50. package/dist/shared/rolldown-build-DWeKtJOy.mjs +0 -2371
@@ -0,0 +1,149 @@
1
+ import { a as RolldownLog } from "./logging-C6h4g8dA.mjs";
2
+ import { B as ParserOptions$1, I as MinifyOptions$1, K as TsconfigCache$1, L as MinifyResult$1, W as SourceMap, a as BindingEnhancedTransformOptions, b as BindingTsconfigResult, o as BindingEnhancedTransformResult, z as ParseResult$1 } from "./binding-hSQGgsUz.mjs";
3
+
4
+ //#region src/utils/resolve-tsconfig.d.ts
5
+ /**
6
+ * Cache for tsconfig resolution to avoid redundant file system operations.
7
+ *
8
+ * The cache stores resolved tsconfig configurations keyed by their file paths.
9
+ * When transforming multiple files in the same project, tsconfig lookups are
10
+ * deduplicated, improving performance.
11
+ *
12
+ * @category Utilities
13
+ * @experimental
14
+ */
15
+ declare class TsconfigCache extends TsconfigCache$1 {
16
+ constructor();
17
+ }
18
+ /** @hidden This is only expected to be used by Vite */
19
+ declare function resolveTsconfig(filename: string, cache?: TsconfigCache | null): BindingTsconfigResult | null;
20
+ //#endregion
21
+ //#region src/utils/parse.d.ts
22
+ /**
23
+ * Result of parsing a code
24
+ *
25
+ * @category Utilities
26
+ */
27
+ interface ParseResult extends ParseResult$1 {}
28
+ /**
29
+ * Options for parsing a code
30
+ *
31
+ * @category Utilities
32
+ */
33
+ interface ParserOptions extends ParserOptions$1 {}
34
+ /**
35
+ * Parse JS/TS source asynchronously on a separate thread.
36
+ *
37
+ * Note that not all of the workload can happen on a separate thread.
38
+ * Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
39
+ * has to happen on current thread. This synchronous deserialization work typically outweighs
40
+ * the asynchronous parsing by a factor of between 3 and 20.
41
+ *
42
+ * i.e. the majority of the workload cannot be parallelized by using this method.
43
+ *
44
+ * Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
45
+ * If you need to parallelize parsing multiple files, it is recommended to use worker threads.
46
+ *
47
+ * @category Utilities
48
+ */
49
+ declare function parse(filename: string, sourceText: string, options?: ParserOptions | null): Promise<ParseResult>;
50
+ /**
51
+ * Parse JS/TS source synchronously on current thread.
52
+ *
53
+ * This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
54
+ * of spawning a thread, and the majority of the workload cannot be parallelized anyway
55
+ * (see {@linkcode parse} documentation for details).
56
+ *
57
+ * If you need to parallelize parsing multiple files, it is recommended to use worker threads
58
+ * with {@linkcode parseSync} rather than using {@linkcode parse}.
59
+ *
60
+ * @category Utilities
61
+ */
62
+ declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | null): ParseResult;
63
+ //#endregion
64
+ //#region src/utils/minify.d.ts
65
+ /**
66
+ * Options for minification.
67
+ *
68
+ * @category Utilities
69
+ */
70
+ interface MinifyOptions extends MinifyOptions$1 {
71
+ inputMap?: SourceMap;
72
+ }
73
+ /**
74
+ * The result of minification.
75
+ *
76
+ * @category Utilities
77
+ */
78
+ interface MinifyResult extends MinifyResult$1 {}
79
+ /**
80
+ * Minify asynchronously.
81
+ *
82
+ * Note: This function can be slower than {@linkcode minifySync} due to the overhead of spawning a thread.
83
+ *
84
+ * @category Utilities
85
+ * @experimental
86
+ */
87
+ declare function minify(filename: string, sourceText: string, options?: MinifyOptions | null): Promise<MinifyResult>;
88
+ /**
89
+ * Minify synchronously.
90
+ *
91
+ * @category Utilities
92
+ * @experimental
93
+ */
94
+ declare function minifySync(filename: string, sourceText: string, options?: MinifyOptions | null): MinifyResult;
95
+ //#endregion
96
+ //#region src/utils/transform.d.ts
97
+ /**
98
+ * Options for transforming a code.
99
+ *
100
+ * @category Utilities
101
+ */
102
+ interface TransformOptions extends BindingEnhancedTransformOptions {}
103
+ /**
104
+ * Result of transforming a code.
105
+ *
106
+ * @category Utilities
107
+ */
108
+ type TransformResult = Omit<BindingEnhancedTransformResult, "errors" | "warnings"> & {
109
+ errors: Error[];
110
+ warnings: RolldownLog[];
111
+ };
112
+ /**
113
+ * Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
114
+ *
115
+ * Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
116
+ *
117
+ * @param filename The name of the file being transformed. If this is a
118
+ * relative path, consider setting the {@linkcode TransformOptions#cwd} option.
119
+ * @param sourceText The source code to transform.
120
+ * @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
121
+ * @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
122
+ * Only used when `options.tsconfig` is `true`.
123
+ *
124
+ * @returns a promise that resolves to an object containing the transformed code,
125
+ * source maps, and any errors that occurred during parsing or transformation.
126
+ *
127
+ * @category Utilities
128
+ * @experimental
129
+ */
130
+ declare function transform(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): Promise<TransformResult>;
131
+ /**
132
+ * Transpile a JavaScript or TypeScript into a target ECMAScript version.
133
+ *
134
+ * @param filename The name of the file being transformed. If this is a
135
+ * relative path, consider setting the {@linkcode TransformOptions#cwd} option.
136
+ * @param sourceText The source code to transform.
137
+ * @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
138
+ * @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
139
+ * Only used when `options.tsconfig` is `true`.
140
+ *
141
+ * @returns an object containing the transformed code, source maps, and any errors
142
+ * that occurred during parsing or transformation.
143
+ *
144
+ * @category Utilities
145
+ * @experimental
146
+ */
147
+ declare function transformSync(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): TransformResult;
148
+ //#endregion
149
+ export { MinifyOptions as a, minifySync as c, parse as d, parseSync as f, transformSync as i, ParseResult as l, resolveTsconfig as m, TransformResult as n, MinifyResult as o, TsconfigCache as p, transform as r, minify as s, TransformOptions as t, ParserOptions as u };
@@ -1,9 +1,9 @@
1
- import { n as __toESM, t as require_binding } from "./binding-tNJoEqAa.mjs";
2
- import { o as logMultiplyNotifyOption } from "./logs-NH298mHo.mjs";
3
- import { a as aggregateBindingErrorsIntoJsError, b as LOG_LEVEL_WARN } from "./bindingify-input-options-CfhrNd_y.mjs";
4
- import { t as arraify } from "./misc-CCZIsXVO.mjs";
5
- import { l as PluginDriver, n as createBundlerOptions } from "./rolldown-build-DWeKtJOy.mjs";
6
-
1
+ import { n as __toESM, t as require_binding } from "./binding-D_jQsHun.mjs";
2
+ import { o as logMultipleWatcherOption } from "./logs-D80CXhvg.mjs";
3
+ import { v as LOG_LEVEL_WARN } from "./bindingify-input-options-DfXGy4QO.mjs";
4
+ import { t as arraify } from "./misc-DJYbNKZX.mjs";
5
+ import { n as createBundlerOptions, u as PluginDriver } from "./rolldown-build-80GULIOI.mjs";
6
+ import { t as aggregateBindingErrorsIntoJsError } from "./error-D5tMcn3l.mjs";
7
7
  //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
8
8
  /**
9
9
  * This is not the set of all possible signals.
@@ -35,7 +35,6 @@ const signals = [];
35
35
  signals.push("SIGHUP", "SIGINT", "SIGTERM");
36
36
  if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
37
37
  if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
38
-
39
38
  //#endregion
40
39
  //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
41
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";
@@ -203,7 +202,6 @@ var SignalExit = class extends SignalExitBase {
203
202
  };
204
203
  const process$1 = globalThis.process;
205
204
  const { onExit: onExit$1, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
206
-
207
205
  //#endregion
208
206
  //#region src/utils/signal-exit.ts
209
207
  function onExit(...args) {
@@ -215,16 +213,10 @@ function onExit(...args) {
215
213
  }
216
214
  onExit$1(...args);
217
215
  }
218
-
219
216
  //#endregion
220
217
  //#region src/api/watch/watch-emitter.ts
221
- var import_binding = /* @__PURE__ */ __toESM(require_binding());
222
218
  var WatcherEmitter = class {
223
219
  listeners = /* @__PURE__ */ new Map();
224
- timer;
225
- constructor() {
226
- this.timer = setInterval(() => {}, 1e9);
227
- }
228
220
  on(event, listener) {
229
221
  const listeners = this.listeners.get(event);
230
222
  if (listeners) listeners.push(listener);
@@ -240,58 +232,56 @@ var WatcherEmitter = class {
240
232
  return this;
241
233
  }
242
234
  clear(event) {
243
- if (this.listeners.has(event)) this.listeners.delete(event);
235
+ this.listeners.delete(event);
244
236
  }
245
- async onEvent(event) {
246
- const listeners = this.listeners.get(event.eventKind());
247
- if (listeners) switch (event.eventKind()) {
248
- case "close":
249
- case "restart":
250
- for (const listener of listeners) await listener();
251
- break;
252
- case "event":
253
- for (const listener of listeners) {
254
- const code = event.bundleEventKind();
255
- switch (code) {
256
- case "BUNDLE_END":
257
- const { duration, output, result } = event.bundleEndData();
258
- await listener({
259
- code: "BUNDLE_END",
260
- duration,
261
- output: [output],
262
- result
263
- });
264
- break;
265
- case "ERROR":
266
- const data = event.bundleErrorData();
267
- await listener({
268
- code: "ERROR",
269
- error: aggregateBindingErrorsIntoJsError(data.error),
270
- result: data.result
271
- });
272
- break;
273
- default:
274
- await listener({ code });
275
- break;
276
- }
277
- }
278
- break;
279
- case "change":
280
- for (const listener of listeners) {
281
- const { path, kind } = event.watchChangeData();
282
- await listener(path, { event: kind });
283
- }
284
- break;
285
- default: throw new Error(`Unknown event: ${event}`);
286
- }
287
- }
288
- async close() {
289
- clearInterval(this.timer);
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);
290
242
  }
243
+ async close() {}
291
244
  };
292
-
293
245
  //#endregion
294
246
  //#region src/api/watch/watcher.ts
247
+ var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
248
+ function createEventCallback(emitter) {
249
+ return async (event) => {
250
+ switch (event.eventKind()) {
251
+ case "event": {
252
+ const code = event.bundleEventKind();
253
+ if (code === "BUNDLE_END") {
254
+ const { duration, output, result } = event.bundleEndData();
255
+ await emitter.emit("event", {
256
+ code: "BUNDLE_END",
257
+ duration,
258
+ output: [output],
259
+ result
260
+ });
261
+ } else if (code === "ERROR") {
262
+ const data = event.bundleErrorData();
263
+ await emitter.emit("event", {
264
+ code: "ERROR",
265
+ error: aggregateBindingErrorsIntoJsError(data.error),
266
+ result: data.result
267
+ });
268
+ } else await emitter.emit("event", { code });
269
+ break;
270
+ }
271
+ case "change": {
272
+ const { path, kind } = event.watchChangeData();
273
+ await emitter.emit("change", path, { event: kind });
274
+ break;
275
+ }
276
+ case "restart":
277
+ await emitter.emit("restart");
278
+ break;
279
+ case "close":
280
+ await emitter.emit("close");
281
+ break;
282
+ }
283
+ };
284
+ }
295
285
  var Watcher = class {
296
286
  closed;
297
287
  inner;
@@ -307,6 +297,7 @@ var Watcher = class {
307
297
  originClose();
308
298
  };
309
299
  this.stopWorkers = stopWorkers;
300
+ process.nextTick(() => this.run());
310
301
  }
311
302
  async close() {
312
303
  if (this.closed) return;
@@ -315,8 +306,9 @@ var Watcher = class {
315
306
  await this.inner.close();
316
307
  (0, import_binding.shutdownAsyncRuntime)();
317
308
  }
318
- start() {
319
- process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
309
+ async run() {
310
+ await this.inner.run();
311
+ this.inner.waitForClose();
320
312
  }
321
313
  };
322
314
  async function createWatcher(emitter, input) {
@@ -324,20 +316,24 @@ async function createWatcher(emitter, input) {
324
316
  const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
325
317
  return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
326
318
  })).flat());
327
- const notifyOptions = getValidNotifyOption(bundlerOptions);
328
- new Watcher(emitter, new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions), bundlerOptions.map((option) => option.stopWorkers)).start();
319
+ warnMultiplePollingOptions(bundlerOptions);
320
+ const callback = createEventCallback(emitter);
321
+ new Watcher(emitter, new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), callback), bundlerOptions.map((option) => option.stopWorkers));
329
322
  }
330
- function getValidNotifyOption(bundlerOptions) {
331
- let result;
332
- for (const option of bundlerOptions) if (option.inputOptions.watch) {
333
- const notifyOption = option.inputOptions.watch.notify;
334
- if (notifyOption) if (result) {
335
- option.onLog(LOG_LEVEL_WARN, logMultiplyNotifyOption());
336
- return result;
337
- } else result = notifyOption;
323
+ function warnMultiplePollingOptions(bundlerOptions) {
324
+ let found = false;
325
+ for (const option of bundlerOptions) {
326
+ const watch = option.inputOptions.watch;
327
+ const watcher = watch && typeof watch === "object" ? watch.watcher ?? watch.notify : void 0;
328
+ if (watcher && (watcher.usePolling != null || watcher.pollInterval != null)) {
329
+ if (found) {
330
+ option.onLog(LOG_LEVEL_WARN, logMultipleWatcherOption());
331
+ return;
332
+ }
333
+ found = true;
334
+ }
338
335
  }
339
336
  }
340
-
341
337
  //#endregion
342
338
  //#region src/api/watch/index.ts
343
339
  /**
@@ -369,11 +365,10 @@ function getValidNotifyOption(bundlerOptions) {
369
365
  * @experimental
370
366
  * @category Programmatic APIs
371
367
  */
372
- const watch = (input) => {
368
+ function watch(input) {
373
369
  const emitter = new WatcherEmitter();
374
370
  createWatcher(emitter, input);
375
371
  return emitter;
376
- };
377
-
372
+ }
378
373
  //#endregion
379
- export { onExit as n, watch as t };
374
+ export { onExit as n, watch as t };