rolldown 1.0.0-beta.37 → 1.0.0-beta.39

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,15 +1,224 @@
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-B5HcAOhq.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-BzRh1cX7.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.37";
221
+ var version = "1.0.0-beta.39";
13
222
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
14
223
 
15
224
  //#endregion
@@ -165,75 +374,6 @@ function normalizeHook(hook) {
165
374
  unreachable("Invalid hook type");
166
375
  }
167
376
 
168
- //#endregion
169
- //#region src/utils/normalize-string-or-regex.ts
170
- function normalizedStringOrRegex(pattern) {
171
- if (!pattern) return;
172
- if (!isReadonlyArray(pattern)) return [pattern];
173
- return pattern;
174
- }
175
- function isReadonlyArray(input) {
176
- return Array.isArray(input);
177
- }
178
-
179
- //#endregion
180
- //#region src/builtin-plugin/constructors.ts
181
- function modulePreloadPolyfillPlugin(config) {
182
- return new BuiltinPlugin("builtin:module-preload-polyfill", config);
183
- }
184
- function dynamicImportVarsPlugin(config) {
185
- if (config) {
186
- config.include = normalizedStringOrRegex(config.include);
187
- config.exclude = normalizedStringOrRegex(config.exclude);
188
- }
189
- return new BuiltinPlugin("builtin:dynamic-import-vars", config);
190
- }
191
- function importGlobPlugin(config) {
192
- return new BuiltinPlugin("builtin:import-glob", config);
193
- }
194
- function reporterPlugin(config) {
195
- return new BuiltinPlugin("builtin:reporter", config);
196
- }
197
- function manifestPlugin(config) {
198
- return new BuiltinPlugin("builtin:manifest", config);
199
- }
200
- function wasmHelperPlugin(config) {
201
- return new BuiltinPlugin("builtin:wasm-helper", config);
202
- }
203
- function wasmFallbackPlugin() {
204
- const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
205
- return makeBuiltinPluginCallable(builtinPlugin);
206
- }
207
- function loadFallbackPlugin() {
208
- return new BuiltinPlugin("builtin:load-fallback");
209
- }
210
- function jsonPlugin(config) {
211
- const builtinPlugin = new BuiltinPlugin("builtin:json", config);
212
- return makeBuiltinPluginCallable(builtinPlugin);
213
- }
214
- function buildImportAnalysisPlugin(config) {
215
- return new BuiltinPlugin("builtin:build-import-analysis", config);
216
- }
217
- function viteResolvePlugin(config) {
218
- const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", config);
219
- return makeBuiltinPluginCallable(builtinPlugin);
220
- }
221
- function isolatedDeclarationPlugin(config) {
222
- return new BuiltinPlugin("builtin:isolated-declaration", config);
223
- }
224
- function assetPlugin(config) {
225
- return new BuiltinPlugin("builtin:asset", config);
226
- }
227
- function webWorkerPostPlugin() {
228
- return new BuiltinPlugin("builtin:web-worker-post");
229
- }
230
- function oxcRuntimePlugin(config) {
231
- return new BuiltinPlugin("builtin:oxc-runtime", config);
232
- }
233
- function esmExternalRequirePlugin(config) {
234
- return new BuiltinPlugin("builtin:esm-external-require", config);
235
- }
236
-
237
377
  //#endregion
238
378
  //#region src/constants/plugin.ts
239
379
  const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
@@ -332,7 +472,6 @@ function normalizePlugins(plugins, anonymousPrefix) {
332
472
  }
333
473
  const ANONYMOUS_PLUGIN_PREFIX = "at position ";
334
474
  const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
335
- const BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
336
475
 
337
476
  //#endregion
338
477
  //#region src/plugin/minimal-plugin-context.ts
@@ -427,14 +566,14 @@ function getSortedPlugins(hookName, plugins) {
427
566
 
428
567
  //#endregion
429
568
  //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.9.2/node_modules/valibot/dist/index.js
430
- var store$1;
569
+ var store;
431
570
  /* @__NO_SIDE_EFFECTS__ */
432
571
  function getGlobalConfig(config2) {
433
572
  return {
434
- lang: config2?.lang ?? store$1?.lang,
573
+ lang: config2?.lang ?? store?.lang,
435
574
  message: config2?.message,
436
- abortEarly: config2?.abortEarly ?? store$1?.abortEarly,
437
- abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
575
+ abortEarly: config2?.abortEarly ?? store?.abortEarly,
576
+ abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
438
577
  };
439
578
  }
440
579
  var store2;
@@ -1415,395 +1554,68 @@ function safeParse(schema, input, config2) {
1415
1554
  }
1416
1555
 
1417
1556
  //#endregion
1418
- //#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
1419
- /**
1420
- * Adds an error message to the errors array.
1421
- *
1422
- * @param errors The array of error messages.
1423
- * @param message The error message to add.
1424
- *
1425
- * @returns The new errors.
1426
- */
1427
- function addError(errors, message) {
1428
- if (errors) {
1429
- errors.push(message);
1430
- return errors;
1431
- }
1432
- return [message];
1433
- }
1434
- /**
1435
- * Throws an error or logs a warning based on the configuration.
1436
- *
1437
- * @param message The message to throw or log.
1438
- * @param config The conversion configuration.
1439
- */
1440
- function handleError(message, config) {
1441
- switch (config?.errorMode) {
1442
- case "ignore": break;
1443
- case "warn":
1444
- console.warn(message);
1445
- break;
1446
- default: throw new Error(message);
1447
- }
1448
- }
1449
- /**
1450
- * Converts any supported Valibot action to the JSON Schema format.
1451
- *
1452
- * @param jsonSchema The JSON Schema object.
1453
- * @param valibotAction The Valibot action object.
1454
- * @param config The conversion configuration.
1455
- *
1456
- * @returns The converted JSON Schema.
1457
- */
1458
- function convertAction(jsonSchema, valibotAction, config) {
1459
- if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
1460
- let errors;
1461
- switch (valibotAction.type) {
1462
- case "base64":
1463
- jsonSchema.contentEncoding = "base64";
1464
- break;
1465
- case "bic":
1466
- case "cuid2":
1467
- case "decimal":
1468
- case "digits":
1469
- case "emoji":
1470
- case "hexadecimal":
1471
- case "hex_color":
1472
- case "nanoid":
1473
- case "octal":
1474
- case "ulid":
1475
- jsonSchema.pattern = valibotAction.requirement.source;
1476
- break;
1477
- case "description":
1478
- jsonSchema.description = valibotAction.description;
1479
- break;
1480
- case "email":
1481
- jsonSchema.format = "email";
1482
- break;
1483
- case "empty":
1484
- if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
1485
- else {
1486
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1487
- jsonSchema.maxLength = 0;
1488
- }
1489
- break;
1490
- case "entries":
1491
- jsonSchema.minProperties = valibotAction.requirement;
1492
- jsonSchema.maxProperties = valibotAction.requirement;
1493
- break;
1494
- case "integer":
1495
- jsonSchema.type = "integer";
1496
- break;
1497
- case "ipv4":
1498
- jsonSchema.format = "ipv4";
1499
- break;
1500
- case "ipv6":
1501
- jsonSchema.format = "ipv6";
1502
- break;
1503
- case "iso_date":
1504
- jsonSchema.format = "date";
1505
- break;
1506
- case "iso_date_time":
1507
- case "iso_timestamp":
1508
- jsonSchema.format = "date-time";
1509
- break;
1510
- case "iso_time":
1511
- jsonSchema.format = "time";
1512
- break;
1513
- case "length":
1514
- if (jsonSchema.type === "array") {
1515
- jsonSchema.minItems = valibotAction.requirement;
1516
- jsonSchema.maxItems = valibotAction.requirement;
1517
- } else {
1518
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1519
- jsonSchema.minLength = valibotAction.requirement;
1520
- jsonSchema.maxLength = valibotAction.requirement;
1521
- }
1522
- break;
1523
- case "max_entries":
1524
- jsonSchema.maxProperties = valibotAction.requirement;
1525
- break;
1526
- case "max_length":
1527
- if (jsonSchema.type === "array") jsonSchema.maxItems = valibotAction.requirement;
1528
- else {
1529
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1530
- jsonSchema.maxLength = valibotAction.requirement;
1531
- }
1532
- break;
1533
- case "max_value":
1534
- if (jsonSchema.type !== "number") errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
1535
- jsonSchema.maximum = valibotAction.requirement;
1536
- break;
1537
- case "metadata":
1538
- if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
1539
- if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
1540
- if (Array.isArray(valibotAction.metadata.examples)) jsonSchema.examples = valibotAction.metadata.examples;
1541
- break;
1542
- case "min_entries":
1543
- jsonSchema.minProperties = valibotAction.requirement;
1544
- break;
1545
- case "min_length":
1546
- if (jsonSchema.type === "array") jsonSchema.minItems = valibotAction.requirement;
1547
- else {
1548
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1549
- jsonSchema.minLength = valibotAction.requirement;
1550
- }
1551
- break;
1552
- case "min_value":
1553
- if (jsonSchema.type !== "number") errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
1554
- jsonSchema.minimum = valibotAction.requirement;
1555
- break;
1556
- case "multiple_of":
1557
- jsonSchema.multipleOf = valibotAction.requirement;
1558
- break;
1559
- case "non_empty":
1560
- if (jsonSchema.type === "array") jsonSchema.minItems = 1;
1561
- else {
1562
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1563
- jsonSchema.minLength = 1;
1564
- }
1565
- break;
1566
- case "regex":
1567
- if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
1568
- jsonSchema.pattern = valibotAction.requirement.source;
1569
- break;
1570
- case "title":
1571
- jsonSchema.title = valibotAction.title;
1572
- break;
1573
- case "url":
1574
- jsonSchema.format = "uri";
1575
- break;
1576
- case "uuid":
1577
- jsonSchema.format = "uuid";
1578
- break;
1579
- case "value":
1580
- jsonSchema.const = valibotAction.requirement;
1581
- break;
1582
- default: errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
1583
- }
1584
- if (config?.overrideAction) {
1585
- const actionOverride = config.overrideAction({
1586
- valibotAction,
1587
- jsonSchema,
1588
- errors
1589
- });
1590
- if (actionOverride) return { ...actionOverride };
1591
- }
1592
- if (errors) for (const message of errors) handleError(message, config);
1593
- return jsonSchema;
1594
- }
1595
- /**
1596
- * Flattens a Valibot pipe by recursively expanding nested pipes.
1597
- *
1598
- * @param pipe The pipeline to flatten.
1599
- *
1600
- * @returns A flat pipeline.
1601
- */
1602
- function flattenPipe(pipe$1) {
1603
- return pipe$1.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1604
- }
1605
- let refCount = 0;
1606
- /**
1607
- * Converts any supported Valibot schema to the JSON Schema format.
1608
- *
1609
- * @param jsonSchema The JSON Schema object.
1610
- * @param valibotSchema The Valibot schema object.
1611
- * @param config The conversion configuration.
1612
- * @param context The conversion context.
1613
- * @param skipRef Whether to skip using a reference.
1614
- *
1615
- * @returns The converted JSON Schema.
1616
- */
1617
- function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1618
- if (!skipRef) {
1619
- const referenceId = context.referenceMap.get(valibotSchema);
1620
- if (referenceId) {
1621
- jsonSchema.$ref = `#/$defs/${referenceId}`;
1622
- if (config?.overrideRef) {
1623
- const refOverride = config.overrideRef({
1624
- ...context,
1625
- referenceId,
1626
- valibotSchema,
1627
- jsonSchema
1628
- });
1629
- if (refOverride) jsonSchema.$ref = refOverride;
1630
- }
1631
- return jsonSchema;
1632
- }
1633
- }
1634
- if ("pipe" in valibotSchema) {
1635
- const flatPipe = flattenPipe(valibotSchema.pipe);
1636
- let startIndex = 0;
1637
- let stopIndex = flatPipe.length - 1;
1638
- if (config?.typeMode === "input") {
1639
- 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"));
1640
- if (inputStopIndex !== -1) stopIndex = inputStopIndex;
1641
- } else if (config?.typeMode === "output") {
1642
- const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
1643
- if (outputStartIndex !== -1) startIndex = outputStartIndex;
1644
- }
1645
- for (let index = startIndex; index <= stopIndex; index++) {
1646
- const valibotPipeItem = flatPipe[index];
1647
- if (valibotPipeItem.kind === "schema") {
1648
- if (index > startIndex) handleError("Set the \"typeMode\" config to \"input\" or \"output\" to convert pipelines with multiple schemas.", config);
1649
- jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1650
- } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1651
- }
1652
- return jsonSchema;
1653
- }
1654
- let errors;
1655
- switch (valibotSchema.type) {
1656
- case "boolean":
1657
- jsonSchema.type = "boolean";
1658
- break;
1659
- case "null":
1660
- jsonSchema.type = "null";
1661
- break;
1662
- case "number":
1663
- jsonSchema.type = "number";
1664
- break;
1665
- case "string":
1666
- jsonSchema.type = "string";
1667
- break;
1668
- case "array":
1669
- jsonSchema.type = "array";
1670
- jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
1671
- break;
1672
- case "tuple":
1673
- case "tuple_with_rest":
1674
- case "loose_tuple":
1675
- case "strict_tuple":
1676
- jsonSchema.type = "array";
1677
- jsonSchema.items = [];
1678
- jsonSchema.minItems = valibotSchema.items.length;
1679
- for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
1680
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
1681
- else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
1682
- 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";
1683
1572
  case "object":
1684
- case "object_with_rest":
1685
- case "loose_object":
1686
1573
  case "strict_object":
1687
- jsonSchema.type = "object";
1688
- jsonSchema.properties = {};
1689
- jsonSchema.required = [];
1690
- for (const key in valibotSchema.entries) {
1691
- const entry = valibotSchema.entries[key];
1692
- jsonSchema.properties[key] = convertSchema({}, entry, config, context);
1693
- if (entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
1694
- }
1695
- if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
1696
- else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
1697
- break;
1698
- case "record":
1699
- 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.");
1700
- 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.`);
1701
- jsonSchema.type = "object";
1702
- jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
1703
- break;
1704
- case "any":
1705
- case "unknown": break;
1706
- case "nullable":
1707
- case "nullish":
1708
- jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
1709
- if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
1710
- break;
1711
- case "exact_optional":
1712
- case "optional":
1713
- case "undefinedable":
1714
- jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
1715
- if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
1716
- break;
1717
- case "literal":
1718
- 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.");
1719
- jsonSchema.const = valibotSchema.literal;
1720
- break;
1721
- case "enum":
1722
- jsonSchema.enum = valibotSchema.options;
1723
- break;
1724
- case "picklist":
1725
- if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) errors = addError(errors, "An option of the \"picklist\" schema is not JSON compatible.");
1726
- jsonSchema.enum = valibotSchema.options;
1727
- break;
1728
- case "union":
1729
- case "variant":
1730
- jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1731
- break;
1732
- case "intersect":
1733
- jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1734
- break;
1735
- case "lazy": {
1736
- let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
1737
- if (!wrappedValibotSchema) {
1738
- wrappedValibotSchema = valibotSchema.getter(void 0);
1739
- context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
1740
- }
1741
- let referenceId = context.referenceMap.get(wrappedValibotSchema);
1742
- if (!referenceId) {
1743
- referenceId = `${refCount++}`;
1744
- context.referenceMap.set(wrappedValibotSchema, referenceId);
1745
- context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
1746
- }
1747
- jsonSchema.$ref = `#/$defs/${referenceId}`;
1748
- if (config?.overrideRef) {
1749
- const refOverride = config.overrideRef({
1750
- ...context,
1751
- referenceId,
1752
- valibotSchema: wrappedValibotSchema,
1753
- jsonSchema
1754
- });
1755
- if (refOverride) jsonSchema.$ref = refOverride;
1756
- }
1757
- 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
+ };
1758
1616
  }
1759
- default: errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
1760
- }
1761
- if (config?.overrideSchema) {
1762
- const schemaOverride = config.overrideSchema({
1763
- ...context,
1764
- referenceId: context.referenceMap.get(valibotSchema),
1765
- valibotSchema,
1766
- jsonSchema,
1767
- errors
1768
- });
1769
- if (schemaOverride) return { ...schemaOverride };
1770
1617
  }
1771
- if (errors) for (const message of errors) handleError(message, config);
1772
- return jsonSchema;
1773
- }
1774
- let store;
1775
- /**
1776
- * Returns the current global schema definitions.
1777
- *
1778
- * @returns The schema definitions.
1779
- *
1780
- * @beta
1781
- */
1782
- function getGlobalDefs() {
1783
- return store;
1784
- }
1785
- /**
1786
- * Converts a Valibot schema to the JSON Schema format.
1787
- *
1788
- * @param schema The Valibot schema object.
1789
- * @param config The JSON Schema configuration.
1790
- *
1791
- * @returns The converted JSON Schema.
1792
- */
1793
- function toJsonSchema(schema, config) {
1794
- const context = {
1795
- definitions: {},
1796
- referenceMap: /* @__PURE__ */ new Map(),
1797
- getterMap: /* @__PURE__ */ new Map()
1798
- };
1799
- const definitions = config?.definitions ?? getGlobalDefs();
1800
- if (definitions) {
1801
- for (const key in definitions) context.referenceMap.set(definitions[key], key);
1802
- for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
1803
- }
1804
- const jsonSchema = convertSchema({ $schema: "http://json-schema.org/draft-07/schema#" }, schema, config, context);
1805
- if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
1806
- return jsonSchema;
1618
+ return result;
1807
1619
  }
1808
1620
 
1809
1621
  //#endregion
@@ -1852,7 +1664,7 @@ const JsxOptionsSchema = strictObject({
1852
1664
  throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
1853
1665
  importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
1854
1666
  pragma: pipe(optional(string()), description("Jsx element transformation")),
1855
- pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
1667
+ pragmaFrag: pipe(optional(string()), description("Jsx fragment transformation")),
1856
1668
  refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
1857
1669
  });
1858
1670
  const RollupJsxOptionsSchema = strictObject({
@@ -1971,7 +1783,11 @@ const MinifyOptionsSchema = strictObject({
1971
1783
  codegen: optional(union([boolean(), CodegenOptionsSchema]))
1972
1784
  });
1973
1785
  const ResolveOptionsSchema = strictObject({
1974
- alias: optional(record(string(), union([string(), array(string())]))),
1786
+ alias: optional(record(string(), union([
1787
+ literal(false),
1788
+ string(),
1789
+ array(string())
1790
+ ]))),
1975
1791
  aliasFields: optional(array(array(string()))),
1976
1792
  conditionNames: optional(array(string())),
1977
1793
  extensionAlias: optional(record(string(), array(string()))),
@@ -2089,7 +1905,7 @@ const InputCliOverrideSchema = strictObject({
2089
1905
  literal("react-jsx"),
2090
1906
  literal("preserve")
2091
1907
  ])), description("Jsx options preset")),
2092
- 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")),
2093
1909
  context: pipe(optional(string()), description("The entity top-level `this` represents."))
2094
1910
  });
2095
1911
  const InputCliOptionsSchema = omit(strictObject({
@@ -2279,8 +2095,8 @@ function getInputCliKeys() {
2279
2095
  function getOutputCliKeys() {
2280
2096
  return keyof(OutputCliOptionsSchema).options;
2281
2097
  }
2282
- function getJsonSchema() {
2283
- return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2098
+ function getCliSchemaInfo() {
2099
+ return flattenValibotSchema(CliOptionsSchema);
2284
2100
  }
2285
2101
 
2286
2102
  //#endregion
@@ -2390,7 +2206,7 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
2390
2206
  }
2391
2207
 
2392
2208
  //#endregion
2393
- //#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
2394
2210
  function e(e$1, t$2, n$1) {
2395
2211
  let r = (n$2) => e$1(n$2, ...t$2);
2396
2212
  return n$1 === void 0 ? r : Object.assign(r, {
@@ -2400,7 +2216,7 @@ function e(e$1, t$2, n$1) {
2400
2216
  }
2401
2217
 
2402
2218
  //#endregion
2403
- //#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
2404
2220
  function t(t$2, n$1, r) {
2405
2221
  let i = t$2.length - n$1.length;
2406
2222
  if (i === 0) return t$2(...n$1);
@@ -2409,7 +2225,7 @@ function t(t$2, n$1, r) {
2409
2225
  }
2410
2226
 
2411
2227
  //#endregion
2412
- //#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
2413
2229
  function t$1(...t$2) {
2414
2230
  return t(n, t$2);
2415
2231
  }
@@ -2620,23 +2436,14 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
2620
2436
  invalidate: false
2621
2437
  };
2622
2438
  this.data.updateModuleOption(id, rawOptions);
2623
- async function createLoadModulePromise(context, data) {
2624
- const loadPromise = data.loadModulePromiseMap.get(id);
2625
- if (loadPromise) return loadPromise;
2626
- const promise$1 = new Promise((resolve, _) => {
2627
- data.loadModulePromiseResolveFnMap.set(id, resolve);
2439
+ let loadPromise = this.data.loadModulePromiseMap.get(id);
2440
+ if (!loadPromise) {
2441
+ loadPromise = this.context.load(id, options.moduleSideEffects ?? void 0).catch(() => {
2442
+ this.data.loadModulePromiseMap.delete(id);
2628
2443
  });
2629
- data.loadModulePromiseMap.set(id, promise$1);
2630
- try {
2631
- await context.load(id, options.moduleSideEffects ?? void 0);
2632
- } catch (e$1) {
2633
- data.loadModulePromiseMap.delete(id);
2634
- data.loadModulePromiseResolveFnMap.delete(id);
2635
- throw e$1;
2636
- }
2637
- return promise$1;
2444
+ this.data.loadModulePromiseMap.set(id, loadPromise);
2638
2445
  }
2639
- await createLoadModulePromise(this.context, this.data);
2446
+ await loadPromise;
2640
2447
  return this.data.getModuleInfo(id, this.context);
2641
2448
  }
2642
2449
  async resolve(source, importer, options) {
@@ -3373,7 +3180,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
3373
3180
  const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args$1);
3374
3181
  const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args$1);
3375
3182
  const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args$1);
3376
- const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
3183
+ const { plugin: load$1, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
3377
3184
  const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args$1);
3378
3185
  const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args$1);
3379
3186
  const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args$1);
@@ -3404,7 +3211,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
3404
3211
  transformFilter,
3405
3212
  moduleParsed,
3406
3213
  moduleParsedMeta,
3407
- load,
3214
+ load: load$1,
3408
3215
  loadMeta,
3409
3216
  loadFilter,
3410
3217
  renderChunk,
@@ -3756,7 +3563,6 @@ var PluginContextData = class {
3756
3563
  moduleOptionMap = /* @__PURE__ */ new Map();
3757
3564
  resolveOptionsMap = /* @__PURE__ */ new Map();
3758
3565
  loadModulePromiseMap = /* @__PURE__ */ new Map();
3759
- loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3760
3566
  renderedChunkMeta = null;
3761
3567
  normalizedInputOptions = null;
3762
3568
  normalizedOutputOptions = null;
@@ -3842,17 +3648,23 @@ var PluginContextData = class {
3842
3648
  this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
3843
3649
  return this.normalizedOutputOptions;
3844
3650
  }
3845
- markModuleLoaded(id, _success) {
3846
- const resolve = this.loadModulePromiseResolveFnMap.get(id);
3847
- if (resolve) resolve();
3848
- }
3849
3651
  clear() {
3850
3652
  this.renderedChunkMeta = null;
3851
3653
  this.loadModulePromiseMap.clear();
3852
- this.loadModulePromiseResolveFnMap.clear();
3853
3654
  }
3854
3655
  };
3855
3656
 
3657
+ //#endregion
3658
+ //#region src/utils/normalize-string-or-regex.ts
3659
+ function normalizedStringOrRegex(pattern) {
3660
+ if (!pattern) return;
3661
+ if (!isReadonlyArray(pattern)) return [pattern];
3662
+ return pattern;
3663
+ }
3664
+ function isReadonlyArray(input) {
3665
+ return Array.isArray(input);
3666
+ }
3667
+
3856
3668
  //#endregion
3857
3669
  //#region src/utils/bindingify-input-options.ts
3858
3670
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
@@ -3898,7 +3710,6 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
3898
3710
  makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
3899
3711
  debug: inputOptions.debug,
3900
3712
  invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
3901
- markModuleLoaded: pluginContextData.markModuleLoaded.bind(pluginContextData),
3902
3713
  preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
3903
3714
  optimization: inputOptions.optimization,
3904
3715
  context: inputOptions.context,
@@ -3925,13 +3736,7 @@ function bindingifyExternal(external) {
3925
3736
  if (id.startsWith("\0")) return false;
3926
3737
  return external(id, importer, isResolved) ?? false;
3927
3738
  };
3928
- const externalArr = arraify(external);
3929
- return (id, _importer, _isResolved) => {
3930
- return externalArr.some((pat) => {
3931
- if (pat instanceof RegExp) return pat.test(id);
3932
- return id === pat;
3933
- });
3934
- };
3739
+ return arraify(external);
3935
3740
  }
3936
3741
  }
3937
3742
  function bindingifyExperimental(experimental) {
@@ -3965,7 +3770,7 @@ function bindingifyResolve(resolve) {
3965
3770
  return {
3966
3771
  alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
3967
3772
  find: name,
3968
- replacements: arraify(replacement)
3773
+ replacements: replacement === false ? [void 0] : arraify(replacement)
3969
3774
  })) : void 0,
3970
3775
  extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
3971
3776
  target: name,
@@ -4196,11 +4001,7 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4196
4001
  const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
4197
4002
  outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
4198
4003
  const normalizedOutputPlugins = await normalizePluginOption(outputOptions.plugins);
4199
- let plugins = [
4200
- ...BUILTIN_PLUGINS,
4201
- ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4202
- ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4203
- ];
4004
+ let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
4204
4005
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4205
4006
  try {
4206
4007
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -4221,27 +4022,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4221
4022
  }
4222
4023
  }
4223
4024
 
4224
- //#endregion
4225
- //#region src/utils/create-bundler.ts
4226
- let asyncRuntimeShutdown = false;
4227
- async function createBundlerImpl(bundler, inputOptions, outputOptions) {
4228
- const option = await createBundlerOptions(inputOptions, outputOptions, false);
4229
- if (asyncRuntimeShutdown) startAsyncRuntime();
4230
- try {
4231
- return {
4232
- impl: bundler.createImpl(option.bundlerOptions),
4233
- stopWorkers: option.stopWorkers,
4234
- shutdown: () => {
4235
- shutdownAsyncRuntime();
4236
- asyncRuntimeShutdown = true;
4237
- }
4238
- };
4239
- } catch (e$1) {
4240
- await option.stopWorkers?.();
4241
- throw e$1;
4242
- }
4243
- }
4244
-
4245
4025
  //#endregion
4246
4026
  //#region src/utils/transform-hmr-patch-output.ts
4247
4027
  function transformHmrPatchOutput(output) {
@@ -4257,10 +4037,11 @@ function handleHmrPatchOutputErrors(output) {
4257
4037
  //#endregion
4258
4038
  //#region src/api/rolldown/rolldown-build.ts
4259
4039
  Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4260
- var RolldownBuild = class {
4040
+ var RolldownBuild = class RolldownBuild {
4261
4041
  #inputOptions;
4262
4042
  #bundler;
4263
4043
  #bundlerImpl;
4044
+ static asyncRuntimeShutdown = false;
4264
4045
  constructor(inputOptions) {
4265
4046
  this.#inputOptions = inputOptions;
4266
4047
  this.#bundler = new BindingBundler();
@@ -4270,7 +4051,26 @@ var RolldownBuild = class {
4270
4051
  }
4271
4052
  async #getBundlerWithStopWorker(outputOptions) {
4272
4053
  if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4273
- return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions);
4054
+ const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
4055
+ if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
4056
+ try {
4057
+ return this.#bundlerImpl = {
4058
+ impl: this.#bundler.createImpl(option.bundlerOptions),
4059
+ stopWorkers: option.stopWorkers,
4060
+ shutdown: () => {
4061
+ shutdownAsyncRuntime();
4062
+ RolldownBuild.asyncRuntimeShutdown = true;
4063
+ }
4064
+ };
4065
+ } catch (e$1) {
4066
+ await option.stopWorkers?.();
4067
+ throw e$1;
4068
+ }
4069
+ }
4070
+ async scan() {
4071
+ const { impl } = await this.#getBundlerWithStopWorker({});
4072
+ const output = await impl.scan();
4073
+ return handleOutputErrors(output);
4274
4074
  }
4275
4075
  async generate(outputOptions = {}) {
4276
4076
  validateOption("output", outputOptions);
@@ -4478,4 +4278,4 @@ function defineConfig(config) {
4478
4278
  const VERSION = version;
4479
4279
 
4480
4280
  //#endregion
4481
- export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, 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 };
4281
+ export { BuiltinPlugin, PluginContextData, PluginDriver, RolldownBuild, VERSION, bindingifyPlugin, build, createBundlerOptions, defineConfig, description$1 as description, getCliSchemaInfo, getInputCliKeys, getOutputCliKeys, makeBuiltinPluginCallable, normalizedStringOrRegex, onExit, rolldown, validateCliOptions, version, watch };