rolldown 1.0.0-beta.36 → 1.0.0-beta.38

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.
@@ -1,33 +1,234 @@
1
- import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingChunkModuleOrderBy, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, BindingWatcher, ParallelJsPluginRegistry, augmentCodeLocation, error, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, shutdownAsyncRuntime, startAsyncRuntime } from "./parse-ast-index-CkDFQ-07.mjs";
1
+ import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingChunkModuleOrderBy, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, BindingWatcher, ParallelJsPluginRegistry, augmentCodeLocation, error, initTraceSubscriber, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, shutdownAsyncRuntime, startAsyncRuntime } from "./parse-ast-index-BL17IImH.mjs";
2
2
  import { arraify, noop, unimplemented, unreachable, unsupported } from "./misc-CQeo-AFx.mjs";
3
- import { Worker } from "node:worker_threads";
3
+ import { Worker, isMainThread } from "node:worker_threads";
4
4
  import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
5
  import colors from "ansis";
7
6
  import * as filter from "@rolldown/pluginutils";
8
7
  import fsp from "node:fs/promises";
9
8
  import os from "node:os";
10
9
 
10
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
11
+ /**
12
+ * This is not the set of all possible signals.
13
+ *
14
+ * It IS, however, the set of all signals that trigger
15
+ * an exit on either Linux or BSD systems. Linux is a
16
+ * superset of the signal names supported on BSD, and
17
+ * the unknown signals just fail to register, so we can
18
+ * catch that easily enough.
19
+ *
20
+ * Windows signals are a different set, since there are
21
+ * signals that terminate Windows processes, but don't
22
+ * terminate (or don't even exist) on Posix systems.
23
+ *
24
+ * Don't bother with SIGKILL. It's uncatchable, which
25
+ * means that we can't fire any callbacks anyway.
26
+ *
27
+ * If a user does happen to register a handler on a non-
28
+ * fatal signal like SIGWINCH or something, and then
29
+ * exit, it'll end up firing `process.emit('exit')`, so
30
+ * the handler will be fired anyway.
31
+ *
32
+ * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
33
+ * artificially, inherently leave the process in a
34
+ * state from which it is not safe to try and enter JS
35
+ * listeners.
36
+ */
37
+ const signals = [];
38
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
39
+ if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
40
+ if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
41
+
42
+ //#endregion
43
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
44
+ const processOk = (process$2) => !!process$2 && typeof process$2 === "object" && typeof process$2.removeListener === "function" && typeof process$2.emit === "function" && typeof process$2.reallyExit === "function" && typeof process$2.listeners === "function" && typeof process$2.kill === "function" && typeof process$2.pid === "number" && typeof process$2.on === "function";
45
+ const kExitEmitter = Symbol.for("signal-exit emitter");
46
+ const global = globalThis;
47
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
48
+ var Emitter = class {
49
+ emitted = {
50
+ afterExit: false,
51
+ exit: false
52
+ };
53
+ listeners = {
54
+ afterExit: [],
55
+ exit: []
56
+ };
57
+ count = 0;
58
+ id = Math.random();
59
+ constructor() {
60
+ if (global[kExitEmitter]) return global[kExitEmitter];
61
+ ObjectDefineProperty(global, kExitEmitter, {
62
+ value: this,
63
+ writable: false,
64
+ enumerable: false,
65
+ configurable: false
66
+ });
67
+ }
68
+ on(ev, fn) {
69
+ this.listeners[ev].push(fn);
70
+ }
71
+ removeListener(ev, fn) {
72
+ const list = this.listeners[ev];
73
+ const i = list.indexOf(fn);
74
+ /* c8 ignore start */
75
+ if (i === -1) return;
76
+ /* c8 ignore stop */
77
+ if (i === 0 && list.length === 1) list.length = 0;
78
+ else list.splice(i, 1);
79
+ }
80
+ emit(ev, code, signal) {
81
+ if (this.emitted[ev]) return false;
82
+ this.emitted[ev] = true;
83
+ let ret = false;
84
+ for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
85
+ if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
86
+ return ret;
87
+ }
88
+ };
89
+ var SignalExitBase = class {};
90
+ const signalExitWrap = (handler) => {
91
+ return {
92
+ onExit(cb, opts) {
93
+ return handler.onExit(cb, opts);
94
+ },
95
+ load() {
96
+ return handler.load();
97
+ },
98
+ unload() {
99
+ return handler.unload();
100
+ }
101
+ };
102
+ };
103
+ var SignalExitFallback = class extends SignalExitBase {
104
+ onExit() {
105
+ return () => {};
106
+ }
107
+ load() {}
108
+ unload() {}
109
+ };
110
+ var SignalExit = class extends SignalExitBase {
111
+ /* c8 ignore start */
112
+ #hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
113
+ /* c8 ignore stop */
114
+ #emitter = new Emitter();
115
+ #process;
116
+ #originalProcessEmit;
117
+ #originalProcessReallyExit;
118
+ #sigListeners = {};
119
+ #loaded = false;
120
+ constructor(process$2) {
121
+ super();
122
+ this.#process = process$2;
123
+ this.#sigListeners = {};
124
+ for (const sig of signals) this.#sigListeners[sig] = () => {
125
+ const listeners = this.#process.listeners(sig);
126
+ let { count } = this.#emitter;
127
+ /* c8 ignore start */
128
+ const p = process$2;
129
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
130
+ /* c8 ignore stop */
131
+ if (listeners.length === count) {
132
+ this.unload();
133
+ const ret = this.#emitter.emit("exit", null, sig);
134
+ /* c8 ignore start */
135
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
136
+ if (!ret) process$2.kill(process$2.pid, s);
137
+ }
138
+ };
139
+ this.#originalProcessReallyExit = process$2.reallyExit;
140
+ this.#originalProcessEmit = process$2.emit;
141
+ }
142
+ onExit(cb, opts) {
143
+ /* c8 ignore start */
144
+ if (!processOk(this.#process)) return () => {};
145
+ /* c8 ignore stop */
146
+ if (this.#loaded === false) this.load();
147
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
148
+ this.#emitter.on(ev, cb);
149
+ return () => {
150
+ this.#emitter.removeListener(ev, cb);
151
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
152
+ };
153
+ }
154
+ load() {
155
+ if (this.#loaded) return;
156
+ this.#loaded = true;
157
+ this.#emitter.count += 1;
158
+ for (const sig of signals) try {
159
+ const fn = this.#sigListeners[sig];
160
+ if (fn) this.#process.on(sig, fn);
161
+ } catch (_) {}
162
+ this.#process.emit = (ev, ...a) => {
163
+ return this.#processEmit(ev, ...a);
164
+ };
165
+ this.#process.reallyExit = (code) => {
166
+ return this.#processReallyExit(code);
167
+ };
168
+ }
169
+ unload() {
170
+ if (!this.#loaded) return;
171
+ this.#loaded = false;
172
+ signals.forEach((sig) => {
173
+ const listener = this.#sigListeners[sig];
174
+ /* c8 ignore start */
175
+ if (!listener) throw new Error("Listener not defined for signal: " + sig);
176
+ /* c8 ignore stop */
177
+ try {
178
+ this.#process.removeListener(sig, listener);
179
+ } catch (_) {}
180
+ /* c8 ignore stop */
181
+ });
182
+ this.#process.emit = this.#originalProcessEmit;
183
+ this.#process.reallyExit = this.#originalProcessReallyExit;
184
+ this.#emitter.count -= 1;
185
+ }
186
+ #processReallyExit(code) {
187
+ /* c8 ignore start */
188
+ if (!processOk(this.#process)) return 0;
189
+ this.#process.exitCode = code || 0;
190
+ /* c8 ignore stop */
191
+ this.#emitter.emit("exit", this.#process.exitCode, null);
192
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
193
+ }
194
+ #processEmit(ev, ...args$1) {
195
+ const og = this.#originalProcessEmit;
196
+ if (ev === "exit" && processOk(this.#process)) {
197
+ if (typeof args$1[0] === "number") this.#process.exitCode = args$1[0];
198
+ /* c8 ignore start */
199
+ const ret = og.call(this.#process, ev, ...args$1);
200
+ /* c8 ignore start */
201
+ this.#emitter.emit("exit", this.#process.exitCode, null);
202
+ /* c8 ignore stop */
203
+ return ret;
204
+ } else return og.call(this.#process, ev, ...args$1);
205
+ }
206
+ };
207
+ const process$1 = globalThis.process;
208
+ const { onExit, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
209
+
210
+ //#endregion
211
+ //#region src/setup.ts
212
+ if (isMainThread) {
213
+ const subscriberGuard = initTraceSubscriber();
214
+ onExit(() => {
215
+ subscriberGuard?.close();
216
+ });
217
+ }
218
+
219
+ //#endregion
11
220
  //#region package.json
12
- var version = "1.0.0-beta.36";
221
+ var version = "1.0.0-beta.38";
13
222
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
14
223
 
15
224
  //#endregion
16
225
  //#region src/builtin-plugin/utils.ts
17
- const BuiltinClassSymbol = Symbol.for("__RolldownBuiltinPlugin__");
18
226
  var BuiltinPlugin = class {
19
227
  constructor(name, _options) {
20
228
  this.name = name;
21
229
  this._options = _options;
22
- this[BuiltinClassSymbol] = true;
23
230
  }
24
231
  };
25
- function isBuiltinPlugin(obj) {
26
- return obj && obj[BuiltinClassSymbol] === true;
27
- }
28
- function createBuiltinPlugin(name, options) {
29
- return new BuiltinPlugin(name, options);
30
- }
31
232
  function makeBuiltinPluginCallable(plugin) {
32
233
  let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
33
234
  const wrappedPlugin = plugin;
@@ -173,75 +374,6 @@ function normalizeHook(hook) {
173
374
  unreachable("Invalid hook type");
174
375
  }
175
376
 
176
- //#endregion
177
- //#region src/utils/normalize-string-or-regex.ts
178
- function normalizedStringOrRegex(pattern) {
179
- if (!pattern) return;
180
- if (!isReadonlyArray(pattern)) return [pattern];
181
- return pattern;
182
- }
183
- function isReadonlyArray(input) {
184
- return Array.isArray(input);
185
- }
186
-
187
- //#endregion
188
- //#region src/builtin-plugin/constructors.ts
189
- function modulePreloadPolyfillPlugin(config) {
190
- return createBuiltinPlugin("builtin:module-preload-polyfill", config);
191
- }
192
- function dynamicImportVarsPlugin(config) {
193
- if (config) {
194
- config.include = normalizedStringOrRegex(config.include);
195
- config.exclude = normalizedStringOrRegex(config.exclude);
196
- }
197
- return createBuiltinPlugin("builtin:dynamic-import-vars", config);
198
- }
199
- function importGlobPlugin(config) {
200
- return createBuiltinPlugin("builtin:import-glob", config);
201
- }
202
- function reporterPlugin(config) {
203
- return createBuiltinPlugin("builtin:reporter", config);
204
- }
205
- function manifestPlugin(config) {
206
- return createBuiltinPlugin("builtin:manifest", config);
207
- }
208
- function wasmHelperPlugin(config) {
209
- return createBuiltinPlugin("builtin:wasm-helper", config);
210
- }
211
- function wasmFallbackPlugin() {
212
- const builtinPlugin = createBuiltinPlugin("builtin:wasm-fallback");
213
- return makeBuiltinPluginCallable(builtinPlugin);
214
- }
215
- function loadFallbackPlugin() {
216
- return createBuiltinPlugin("builtin:load-fallback");
217
- }
218
- function jsonPlugin(config) {
219
- const builtinPlugin = createBuiltinPlugin("builtin:json", config);
220
- return makeBuiltinPluginCallable(builtinPlugin);
221
- }
222
- function buildImportAnalysisPlugin(config) {
223
- return createBuiltinPlugin("builtin:build-import-analysis", config);
224
- }
225
- function viteResolvePlugin(config) {
226
- const builtinPlugin = createBuiltinPlugin("builtin:vite-resolve", config);
227
- return makeBuiltinPluginCallable(builtinPlugin);
228
- }
229
- function isolatedDeclarationPlugin(config) {
230
- return createBuiltinPlugin("builtin:isolated-declaration", config);
231
- }
232
- function assetPlugin(config) {
233
- return createBuiltinPlugin("builtin:asset", config);
234
- }
235
- function webWorkerPostPlugin() {
236
- return createBuiltinPlugin("builtin:web-worker-post");
237
- }
238
- function oxcRuntimePlugin(config) {
239
- return createBuiltinPlugin("builtin:oxc-runtime", config);
240
- }
241
- function esmExternalRequirePlugin(config) {
242
- return createBuiltinPlugin("builtin:esm-external-require", config);
243
- }
244
-
245
377
  //#endregion
246
378
  //#region src/constants/plugin.ts
247
379
  const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
@@ -333,14 +465,13 @@ function checkOutputPluginOption(plugins, onLog) {
333
465
  function normalizePlugins(plugins, anonymousPrefix) {
334
466
  for (const [index, plugin] of plugins.entries()) {
335
467
  if ("_parallel" in plugin) continue;
336
- if (isBuiltinPlugin(plugin)) continue;
468
+ if (plugin instanceof BuiltinPlugin) continue;
337
469
  if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
338
470
  }
339
471
  return plugins;
340
472
  }
341
473
  const ANONYMOUS_PLUGIN_PREFIX = "at position ";
342
474
  const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
343
- const BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
344
475
 
345
476
  //#endregion
346
477
  //#region src/plugin/minimal-plugin-context.ts
@@ -402,7 +533,7 @@ function getObjectPlugins(plugins) {
402
533
  return plugins.filter((plugin) => {
403
534
  if (!plugin) return;
404
535
  if ("_parallel" in plugin) return;
405
- if (isBuiltinPlugin(plugin)) return;
536
+ if (plugin instanceof BuiltinPlugin) return;
406
537
  return plugin;
407
538
  });
408
539
  }
@@ -435,14 +566,14 @@ function getSortedPlugins(hookName, plugins) {
435
566
 
436
567
  //#endregion
437
568
  //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.9.2/node_modules/valibot/dist/index.js
438
- var store$1;
569
+ var store;
439
570
  /* @__NO_SIDE_EFFECTS__ */
440
571
  function getGlobalConfig(config2) {
441
572
  return {
442
- lang: config2?.lang ?? store$1?.lang,
573
+ lang: config2?.lang ?? store?.lang,
443
574
  message: config2?.message,
444
- abortEarly: config2?.abortEarly ?? store$1?.abortEarly,
445
- abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
575
+ abortEarly: config2?.abortEarly ?? store?.abortEarly,
576
+ abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
446
577
  };
447
578
  }
448
579
  var store2;
@@ -1423,395 +1554,68 @@ function safeParse(schema, input, config2) {
1423
1554
  }
1424
1555
 
1425
1556
  //#endregion
1426
- //#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.3.0_valibot@1.1.0_typescript@5.9.2_/node_modules/@valibot/to-json-schema/dist/index.js
1427
- /**
1428
- * Adds an error message to the errors array.
1429
- *
1430
- * @param errors The array of error messages.
1431
- * @param message The error message to add.
1432
- *
1433
- * @returns The new errors.
1434
- */
1435
- function addError(errors, message) {
1436
- if (errors) {
1437
- errors.push(message);
1438
- return errors;
1439
- }
1440
- return [message];
1441
- }
1442
- /**
1443
- * Throws an error or logs a warning based on the configuration.
1444
- *
1445
- * @param message The message to throw or log.
1446
- * @param config The conversion configuration.
1447
- */
1448
- function handleError(message, config) {
1449
- switch (config?.errorMode) {
1450
- case "ignore": break;
1451
- case "warn":
1452
- console.warn(message);
1453
- break;
1454
- default: throw new Error(message);
1455
- }
1456
- }
1457
- /**
1458
- * Converts any supported Valibot action to the JSON Schema format.
1459
- *
1460
- * @param jsonSchema The JSON Schema object.
1461
- * @param valibotAction The Valibot action object.
1462
- * @param config The conversion configuration.
1463
- *
1464
- * @returns The converted JSON Schema.
1465
- */
1466
- function convertAction(jsonSchema, valibotAction, config) {
1467
- if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
1468
- let errors;
1469
- switch (valibotAction.type) {
1470
- case "base64":
1471
- jsonSchema.contentEncoding = "base64";
1472
- break;
1473
- case "bic":
1474
- case "cuid2":
1475
- case "decimal":
1476
- case "digits":
1477
- case "emoji":
1478
- case "hexadecimal":
1479
- case "hex_color":
1480
- case "nanoid":
1481
- case "octal":
1482
- case "ulid":
1483
- jsonSchema.pattern = valibotAction.requirement.source;
1484
- break;
1485
- case "description":
1486
- jsonSchema.description = valibotAction.description;
1487
- break;
1488
- case "email":
1489
- jsonSchema.format = "email";
1490
- break;
1491
- case "empty":
1492
- if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
1493
- else {
1494
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1495
- jsonSchema.maxLength = 0;
1496
- }
1497
- break;
1498
- case "entries":
1499
- jsonSchema.minProperties = valibotAction.requirement;
1500
- jsonSchema.maxProperties = valibotAction.requirement;
1501
- break;
1502
- case "integer":
1503
- jsonSchema.type = "integer";
1504
- break;
1505
- case "ipv4":
1506
- jsonSchema.format = "ipv4";
1507
- break;
1508
- case "ipv6":
1509
- jsonSchema.format = "ipv6";
1510
- break;
1511
- case "iso_date":
1512
- jsonSchema.format = "date";
1513
- break;
1514
- case "iso_date_time":
1515
- case "iso_timestamp":
1516
- jsonSchema.format = "date-time";
1517
- break;
1518
- case "iso_time":
1519
- jsonSchema.format = "time";
1520
- break;
1521
- case "length":
1522
- if (jsonSchema.type === "array") {
1523
- jsonSchema.minItems = valibotAction.requirement;
1524
- jsonSchema.maxItems = valibotAction.requirement;
1525
- } else {
1526
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1527
- jsonSchema.minLength = valibotAction.requirement;
1528
- jsonSchema.maxLength = valibotAction.requirement;
1529
- }
1530
- break;
1531
- case "max_entries":
1532
- jsonSchema.maxProperties = valibotAction.requirement;
1533
- break;
1534
- case "max_length":
1535
- if (jsonSchema.type === "array") jsonSchema.maxItems = valibotAction.requirement;
1536
- else {
1537
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1538
- jsonSchema.maxLength = valibotAction.requirement;
1539
- }
1540
- break;
1541
- case "max_value":
1542
- if (jsonSchema.type !== "number") errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
1543
- jsonSchema.maximum = valibotAction.requirement;
1544
- break;
1545
- case "metadata":
1546
- if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
1547
- if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
1548
- if (Array.isArray(valibotAction.metadata.examples)) jsonSchema.examples = valibotAction.metadata.examples;
1549
- break;
1550
- case "min_entries":
1551
- jsonSchema.minProperties = valibotAction.requirement;
1552
- break;
1553
- case "min_length":
1554
- if (jsonSchema.type === "array") jsonSchema.minItems = valibotAction.requirement;
1555
- else {
1556
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1557
- jsonSchema.minLength = valibotAction.requirement;
1558
- }
1559
- break;
1560
- case "min_value":
1561
- if (jsonSchema.type !== "number") errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
1562
- jsonSchema.minimum = valibotAction.requirement;
1563
- break;
1564
- case "multiple_of":
1565
- jsonSchema.multipleOf = valibotAction.requirement;
1566
- break;
1567
- case "non_empty":
1568
- if (jsonSchema.type === "array") jsonSchema.minItems = 1;
1569
- else {
1570
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1571
- jsonSchema.minLength = 1;
1572
- }
1573
- break;
1574
- case "regex":
1575
- if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
1576
- jsonSchema.pattern = valibotAction.requirement.source;
1577
- break;
1578
- case "title":
1579
- jsonSchema.title = valibotAction.title;
1580
- break;
1581
- case "url":
1582
- jsonSchema.format = "uri";
1583
- break;
1584
- case "uuid":
1585
- jsonSchema.format = "uuid";
1586
- break;
1587
- case "value":
1588
- jsonSchema.const = valibotAction.requirement;
1589
- break;
1590
- default: errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
1591
- }
1592
- if (config?.overrideAction) {
1593
- const actionOverride = config.overrideAction({
1594
- valibotAction,
1595
- jsonSchema,
1596
- errors
1597
- });
1598
- if (actionOverride) return { ...actionOverride };
1599
- }
1600
- if (errors) for (const message of errors) handleError(message, config);
1601
- return jsonSchema;
1602
- }
1603
- /**
1604
- * Flattens a Valibot pipe by recursively expanding nested pipes.
1605
- *
1606
- * @param pipe The pipeline to flatten.
1607
- *
1608
- * @returns A flat pipeline.
1609
- */
1610
- function flattenPipe(pipe$1) {
1611
- return pipe$1.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1612
- }
1613
- let refCount = 0;
1614
- /**
1615
- * Converts any supported Valibot schema to the JSON Schema format.
1616
- *
1617
- * @param jsonSchema The JSON Schema object.
1618
- * @param valibotSchema The Valibot schema object.
1619
- * @param config The conversion configuration.
1620
- * @param context The conversion context.
1621
- * @param skipRef Whether to skip using a reference.
1622
- *
1623
- * @returns The converted JSON Schema.
1624
- */
1625
- function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1626
- if (!skipRef) {
1627
- const referenceId = context.referenceMap.get(valibotSchema);
1628
- if (referenceId) {
1629
- jsonSchema.$ref = `#/$defs/${referenceId}`;
1630
- if (config?.overrideRef) {
1631
- const refOverride = config.overrideRef({
1632
- ...context,
1633
- referenceId,
1634
- valibotSchema,
1635
- jsonSchema
1636
- });
1637
- if (refOverride) jsonSchema.$ref = refOverride;
1638
- }
1639
- return jsonSchema;
1640
- }
1641
- }
1642
- if ("pipe" in valibotSchema) {
1643
- const flatPipe = flattenPipe(valibotSchema.pipe);
1644
- let startIndex = 0;
1645
- let stopIndex = flatPipe.length - 1;
1646
- if (config?.typeMode === "input") {
1647
- const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "transform"));
1648
- if (inputStopIndex !== -1) stopIndex = inputStopIndex;
1649
- } else if (config?.typeMode === "output") {
1650
- const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
1651
- if (outputStartIndex !== -1) startIndex = outputStartIndex;
1652
- }
1653
- for (let index = startIndex; index <= stopIndex; index++) {
1654
- const valibotPipeItem = flatPipe[index];
1655
- if (valibotPipeItem.kind === "schema") {
1656
- if (index > startIndex) handleError("Set the \"typeMode\" config to \"input\" or \"output\" to convert pipelines with multiple schemas.", config);
1657
- jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1658
- } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1659
- }
1660
- return jsonSchema;
1661
- }
1662
- let errors;
1663
- switch (valibotSchema.type) {
1664
- case "boolean":
1665
- jsonSchema.type = "boolean";
1666
- break;
1667
- case "null":
1668
- jsonSchema.type = "null";
1669
- break;
1670
- case "number":
1671
- jsonSchema.type = "number";
1672
- break;
1673
- case "string":
1674
- jsonSchema.type = "string";
1675
- break;
1676
- case "array":
1677
- jsonSchema.type = "array";
1678
- jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
1679
- break;
1680
- case "tuple":
1681
- case "tuple_with_rest":
1682
- case "loose_tuple":
1683
- case "strict_tuple":
1684
- jsonSchema.type = "array";
1685
- jsonSchema.items = [];
1686
- jsonSchema.minItems = valibotSchema.items.length;
1687
- for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
1688
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
1689
- else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
1690
- break;
1557
+ //#region src/utils/flatten-valibot-schema.ts
1558
+ function unwrapSchema(schema) {
1559
+ if (!schema) return schema;
1560
+ if (schema.type === "optional" && schema.wrapped) return unwrapSchema(schema.wrapped);
1561
+ if (schema.type === "nullable" && schema.wrapped) return unwrapSchema(schema.wrapped);
1562
+ if (schema.type === "nullish" && schema.wrapped) return unwrapSchema(schema.wrapped);
1563
+ return schema;
1564
+ }
1565
+ function getValibotSchemaType(schema) {
1566
+ if (!schema) return "any";
1567
+ if (schema.type) switch (schema.type) {
1568
+ case "string": return "string";
1569
+ case "number": return "number";
1570
+ case "boolean": return "boolean";
1571
+ case "array": return "array";
1691
1572
  case "object":
1692
- case "object_with_rest":
1693
- case "loose_object":
1694
1573
  case "strict_object":
1695
- jsonSchema.type = "object";
1696
- jsonSchema.properties = {};
1697
- jsonSchema.required = [];
1698
- for (const key in valibotSchema.entries) {
1699
- const entry = valibotSchema.entries[key];
1700
- jsonSchema.properties[key] = convertSchema({}, entry, config, context);
1701
- if (entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
1702
- }
1703
- if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
1704
- else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
1705
- break;
1706
- case "record":
1707
- if ("pipe" in valibotSchema.key) errors = addError(errors, "The \"record\" schema with a schema for the key that contains a \"pipe\" cannot be converted to JSON Schema.");
1708
- if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
1709
- jsonSchema.type = "object";
1710
- jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
1711
- break;
1712
- case "any":
1713
- case "unknown": break;
1714
- case "nullable":
1715
- case "nullish":
1716
- jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
1717
- if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
1718
- break;
1719
- case "exact_optional":
1720
- case "optional":
1721
- case "undefinedable":
1722
- jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
1723
- if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
1724
- break;
1725
- case "literal":
1726
- if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") errors = addError(errors, "The value of the \"literal\" schema is not JSON compatible.");
1727
- jsonSchema.const = valibotSchema.literal;
1728
- break;
1729
- case "enum":
1730
- jsonSchema.enum = valibotSchema.options;
1731
- break;
1732
- case "picklist":
1733
- if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) errors = addError(errors, "An option of the \"picklist\" schema is not JSON compatible.");
1734
- jsonSchema.enum = valibotSchema.options;
1735
- break;
1736
- case "union":
1737
- case "variant":
1738
- jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1739
- break;
1740
- case "intersect":
1741
- jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1742
- break;
1743
- case "lazy": {
1744
- let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
1745
- if (!wrappedValibotSchema) {
1746
- wrappedValibotSchema = valibotSchema.getter(void 0);
1747
- context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
1748
- }
1749
- let referenceId = context.referenceMap.get(wrappedValibotSchema);
1750
- if (!referenceId) {
1751
- referenceId = `${refCount++}`;
1752
- context.referenceMap.set(wrappedValibotSchema, referenceId);
1753
- context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
1754
- }
1755
- jsonSchema.$ref = `#/$defs/${referenceId}`;
1756
- if (config?.overrideRef) {
1757
- const refOverride = config.overrideRef({
1758
- ...context,
1759
- referenceId,
1760
- valibotSchema: wrappedValibotSchema,
1761
- jsonSchema
1762
- });
1763
- if (refOverride) jsonSchema.$ref = refOverride;
1764
- }
1765
- break;
1574
+ case "loose_object": return "object";
1575
+ case "union": return "union";
1576
+ case "literal": return typeof schema.literal;
1577
+ case "record": return "object";
1578
+ case "optional": return getValibotSchemaType(schema.wrapped);
1579
+ case "nullable": return getValibotSchemaType(schema.wrapped);
1580
+ case "nullish": return getValibotSchemaType(schema.wrapped);
1581
+ case "never": return "never";
1582
+ case "any": return "any";
1583
+ case "custom": return "any";
1584
+ case "function": return "never";
1585
+ case "instance": return "object";
1586
+ default: return "any";
1587
+ }
1588
+ return "any";
1589
+ }
1590
+ function getValibotDescription(schema) {
1591
+ if (!schema) return void 0;
1592
+ if (schema.pipe && Array.isArray(schema.pipe)) {
1593
+ for (const action of schema.pipe) if (action.type === "description" && action.description) return action.description;
1594
+ }
1595
+ if (schema.type === "optional" && schema.wrapped) return getValibotDescription(schema.wrapped);
1596
+ }
1597
+ function flattenValibotSchema(schema, result = {}, prefix = "") {
1598
+ if (!schema || typeof schema !== "object") return result;
1599
+ if (schema.type === "strict_object" || schema.type === "object" || schema.type === "loose_object") {
1600
+ if (schema.entries && typeof schema.entries === "object") for (const [key, value] of Object.entries(schema.entries)) {
1601
+ const fullKey = prefix ? `${prefix}.${key}` : key;
1602
+ const valueSchema = value;
1603
+ const type = getValibotSchemaType(valueSchema);
1604
+ const description$2 = getValibotDescription(valueSchema);
1605
+ if (type === "object") {
1606
+ const unwrappedSchema = unwrapSchema(valueSchema);
1607
+ if (unwrappedSchema && unwrappedSchema.entries) flattenValibotSchema(unwrappedSchema, result, fullKey);
1608
+ else result[fullKey] = {
1609
+ type,
1610
+ description: description$2
1611
+ };
1612
+ } else result[fullKey] = {
1613
+ type,
1614
+ description: description$2
1615
+ };
1766
1616
  }
1767
- default: errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
1768
- }
1769
- if (config?.overrideSchema) {
1770
- const schemaOverride = config.overrideSchema({
1771
- ...context,
1772
- referenceId: context.referenceMap.get(valibotSchema),
1773
- valibotSchema,
1774
- jsonSchema,
1775
- errors
1776
- });
1777
- if (schemaOverride) return { ...schemaOverride };
1778
1617
  }
1779
- if (errors) for (const message of errors) handleError(message, config);
1780
- return jsonSchema;
1781
- }
1782
- let store;
1783
- /**
1784
- * Returns the current global schema definitions.
1785
- *
1786
- * @returns The schema definitions.
1787
- *
1788
- * @beta
1789
- */
1790
- function getGlobalDefs() {
1791
- return store;
1792
- }
1793
- /**
1794
- * Converts a Valibot schema to the JSON Schema format.
1795
- *
1796
- * @param schema The Valibot schema object.
1797
- * @param config The JSON Schema configuration.
1798
- *
1799
- * @returns The converted JSON Schema.
1800
- */
1801
- function toJsonSchema(schema, config) {
1802
- const context = {
1803
- definitions: {},
1804
- referenceMap: /* @__PURE__ */ new Map(),
1805
- getterMap: /* @__PURE__ */ new Map()
1806
- };
1807
- const definitions = config?.definitions ?? getGlobalDefs();
1808
- if (definitions) {
1809
- for (const key in definitions) context.referenceMap.set(definitions[key], key);
1810
- for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
1811
- }
1812
- const jsonSchema = convertSchema({ $schema: "http://json-schema.org/draft-07/schema#" }, schema, config, context);
1813
- if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
1814
- return jsonSchema;
1618
+ return result;
1815
1619
  }
1816
1620
 
1817
1621
  //#endregion
@@ -1860,7 +1664,7 @@ const JsxOptionsSchema = strictObject({
1860
1664
  throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
1861
1665
  importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
1862
1666
  pragma: pipe(optional(string()), description("Jsx element transformation")),
1863
- pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
1667
+ pragmaFrag: pipe(optional(string()), description("Jsx fragment transformation")),
1864
1668
  refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
1865
1669
  });
1866
1670
  const RollupJsxOptionsSchema = strictObject({
@@ -1979,7 +1783,11 @@ const MinifyOptionsSchema = strictObject({
1979
1783
  codegen: optional(union([boolean(), CodegenOptionsSchema]))
1980
1784
  });
1981
1785
  const ResolveOptionsSchema = strictObject({
1982
- alias: optional(record(string(), union([string(), array(string())]))),
1786
+ alias: optional(record(string(), union([
1787
+ literal(false),
1788
+ string(),
1789
+ array(string())
1790
+ ]))),
1983
1791
  aliasFields: optional(array(array(string()))),
1984
1792
  conditionNames: optional(array(string())),
1985
1793
  extensionAlias: optional(record(string(), array(string()))),
@@ -2097,7 +1905,7 @@ const InputCliOverrideSchema = strictObject({
2097
1905
  literal("react-jsx"),
2098
1906
  literal("preserve")
2099
1907
  ])), description("Jsx options preset")),
2100
- preserveEntrySignatures: pipe(optional(union([literal(false)])), description("Avoid facade chunks for entry points")),
1908
+ preserveEntrySignatures: pipe(optional(literal(false)), description("Avoid facade chunks for entry points")),
2101
1909
  context: pipe(optional(string()), description("The entity top-level `this` represents."))
2102
1910
  });
2103
1911
  const InputCliOptionsSchema = omit(strictObject({
@@ -2287,8 +2095,8 @@ function getInputCliKeys() {
2287
2095
  function getOutputCliKeys() {
2288
2096
  return keyof(OutputCliOptionsSchema).options;
2289
2097
  }
2290
- function getJsonSchema() {
2291
- return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2098
+ function getCliSchemaInfo() {
2099
+ return flattenValibotSchema(CliOptionsSchema);
2292
2100
  }
2293
2101
 
2294
2102
  //#endregion
@@ -2398,7 +2206,7 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
2398
2206
  }
2399
2207
 
2400
2208
  //#endregion
2401
- //#region ../../node_modules/.pnpm/remeda@2.30.0/node_modules/remeda/dist/lazyDataLastImpl-BDhrIOwR.js
2209
+ //#region ../../node_modules/.pnpm/remeda@2.31.1/node_modules/remeda/dist/lazyDataLastImpl-BDhrIOwR.js
2402
2210
  function e(e$1, t$2, n$1) {
2403
2211
  let r = (n$2) => e$1(n$2, ...t$2);
2404
2212
  return n$1 === void 0 ? r : Object.assign(r, {
@@ -2408,7 +2216,7 @@ function e(e$1, t$2, n$1) {
2408
2216
  }
2409
2217
 
2410
2218
  //#endregion
2411
- //#region ../../node_modules/.pnpm/remeda@2.30.0/node_modules/remeda/dist/purry-DH9cw9sy.js
2219
+ //#region ../../node_modules/.pnpm/remeda@2.31.1/node_modules/remeda/dist/purry-DH9cw9sy.js
2412
2220
  function t(t$2, n$1, r) {
2413
2221
  let i = t$2.length - n$1.length;
2414
2222
  if (i === 0) return t$2(...n$1);
@@ -2417,7 +2225,7 @@ function t(t$2, n$1, r) {
2417
2225
  }
2418
2226
 
2419
2227
  //#endregion
2420
- //#region ../../node_modules/.pnpm/remeda@2.30.0/node_modules/remeda/dist/partition-BJYkp-a7.js
2228
+ //#region ../../node_modules/.pnpm/remeda@2.31.1/node_modules/remeda/dist/partition-DAu403JQ.js
2421
2229
  function t$1(...t$2) {
2422
2230
  return t(n, t$2);
2423
2231
  }
@@ -3381,7 +3189,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
3381
3189
  const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args$1);
3382
3190
  const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args$1);
3383
3191
  const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args$1);
3384
- const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
3192
+ const { plugin: load$1, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
3385
3193
  const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args$1);
3386
3194
  const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args$1);
3387
3195
  const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args$1);
@@ -3412,7 +3220,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
3412
3220
  transformFilter,
3413
3221
  moduleParsed,
3414
3222
  moduleParsedMeta,
3415
- load,
3223
+ load: load$1,
3416
3224
  loadMeta,
3417
3225
  loadFilter,
3418
3226
  renderChunk,
@@ -3861,13 +3669,24 @@ var PluginContextData = class {
3861
3669
  }
3862
3670
  };
3863
3671
 
3672
+ //#endregion
3673
+ //#region src/utils/normalize-string-or-regex.ts
3674
+ function normalizedStringOrRegex(pattern) {
3675
+ if (!pattern) return;
3676
+ if (!isReadonlyArray(pattern)) return [pattern];
3677
+ return pattern;
3678
+ }
3679
+ function isReadonlyArray(input) {
3680
+ return Array.isArray(input);
3681
+ }
3682
+
3864
3683
  //#endregion
3865
3684
  //#region src/utils/bindingify-input-options.ts
3866
3685
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3867
3686
  const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3868
3687
  const plugins = rawPlugins.map((plugin) => {
3869
3688
  if ("_parallel" in plugin) return;
3870
- if (isBuiltinPlugin(plugin)) return bindingifyBuiltInPlugin(plugin);
3689
+ if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
3871
3690
  return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
3872
3691
  });
3873
3692
  const { jsx, transform } = bindingifyJsx(onLog, inputOptions.jsx, inputOptions.transform);
@@ -3933,13 +3752,7 @@ function bindingifyExternal(external) {
3933
3752
  if (id.startsWith("\0")) return false;
3934
3753
  return external(id, importer, isResolved) ?? false;
3935
3754
  };
3936
- const externalArr = arraify(external);
3937
- return (id, _importer, _isResolved) => {
3938
- return externalArr.some((pat) => {
3939
- if (pat instanceof RegExp) return pat.test(id);
3940
- return id === pat;
3941
- });
3942
- };
3755
+ return arraify(external);
3943
3756
  }
3944
3757
  }
3945
3758
  function bindingifyExperimental(experimental) {
@@ -3973,7 +3786,7 @@ function bindingifyResolve(resolve) {
3973
3786
  return {
3974
3787
  alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
3975
3788
  find: name,
3976
- replacements: arraify(replacement)
3789
+ replacements: replacement === false ? [void 0] : arraify(replacement)
3977
3790
  })) : void 0,
3978
3791
  extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
3979
3792
  target: name,
@@ -4204,11 +4017,7 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4204
4017
  const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
4205
4018
  outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
4206
4019
  const normalizedOutputPlugins = await normalizePluginOption(outputOptions.plugins);
4207
- let plugins = [
4208
- ...BUILTIN_PLUGINS,
4209
- ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4210
- ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4211
- ];
4020
+ let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
4212
4021
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4213
4022
  try {
4214
4023
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -4229,27 +4038,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4229
4038
  }
4230
4039
  }
4231
4040
 
4232
- //#endregion
4233
- //#region src/utils/create-bundler.ts
4234
- let asyncRuntimeShutdown = false;
4235
- async function createBundlerImpl(bundler, inputOptions, outputOptions) {
4236
- const option = await createBundlerOptions(inputOptions, outputOptions, false);
4237
- if (asyncRuntimeShutdown) startAsyncRuntime();
4238
- try {
4239
- return {
4240
- impl: bundler.createImpl(option.bundlerOptions),
4241
- stopWorkers: option.stopWorkers,
4242
- shutdown: () => {
4243
- shutdownAsyncRuntime();
4244
- asyncRuntimeShutdown = true;
4245
- }
4246
- };
4247
- } catch (e$1) {
4248
- await option.stopWorkers?.();
4249
- throw e$1;
4250
- }
4251
- }
4252
-
4253
4041
  //#endregion
4254
4042
  //#region src/utils/transform-hmr-patch-output.ts
4255
4043
  function transformHmrPatchOutput(output) {
@@ -4265,10 +4053,11 @@ function handleHmrPatchOutputErrors(output) {
4265
4053
  //#endregion
4266
4054
  //#region src/api/rolldown/rolldown-build.ts
4267
4055
  Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4268
- var RolldownBuild = class {
4056
+ var RolldownBuild = class RolldownBuild {
4269
4057
  #inputOptions;
4270
4058
  #bundler;
4271
4059
  #bundlerImpl;
4060
+ static asyncRuntimeShutdown = false;
4272
4061
  constructor(inputOptions) {
4273
4062
  this.#inputOptions = inputOptions;
4274
4063
  this.#bundler = new BindingBundler();
@@ -4278,7 +4067,26 @@ var RolldownBuild = class {
4278
4067
  }
4279
4068
  async #getBundlerWithStopWorker(outputOptions) {
4280
4069
  if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4281
- return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions);
4070
+ const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
4071
+ if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
4072
+ try {
4073
+ return this.#bundlerImpl = {
4074
+ impl: this.#bundler.createImpl(option.bundlerOptions),
4075
+ stopWorkers: option.stopWorkers,
4076
+ shutdown: () => {
4077
+ shutdownAsyncRuntime();
4078
+ RolldownBuild.asyncRuntimeShutdown = true;
4079
+ }
4080
+ };
4081
+ } catch (e$1) {
4082
+ await option.stopWorkers?.();
4083
+ throw e$1;
4084
+ }
4085
+ }
4086
+ async scan() {
4087
+ const { impl } = await this.#getBundlerWithStopWorker({});
4088
+ const output = await impl.scan();
4089
+ return handleOutputErrors(output);
4282
4090
  }
4283
4091
  async generate(outputOptions = {}) {
4284
4092
  validateOption("output", outputOptions);
@@ -4486,4 +4294,4 @@ function defineConfig(config) {
4486
4294
  const VERSION = version;
4487
4295
 
4488
4296
  //#endregion
4489
- export { PluginContextData, PluginDriver, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, createBuiltinPlugin, createBundlerImpl, createBundlerOptions, defineConfig, description$1 as description, dynamicImportVarsPlugin, esmExternalRequirePlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };
4297
+ export { BuiltinPlugin, PluginContextData, PluginDriver, RolldownBuild, VERSION, bindingifyPlugin, build, createBundlerOptions, defineConfig, description$1 as description, getCliSchemaInfo, getInputCliKeys, getOutputCliKeys, makeBuiltinPluginCallable, normalizedStringOrRegex, onExit, rolldown, validateCliOptions, version, watch };