rolldown 1.0.0-beta.37 → 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.
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +82 -297
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +3 -3
- package/dist/experimental-index.d.mts +14 -4
- package/dist/experimental-index.mjs +73 -8
- package/dist/filter-index.d.mts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/parallel-plugin-worker.d.mts +1 -1
- package/dist/parallel-plugin-worker.mjs +2 -2
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/shared/{binding-Cjs27cfu.d.mts → binding-D6vpD1fz.d.mts} +9 -24
- package/dist/shared/{define-config-CV3aiNwN.d.mts → define-config-2i15IFxp.d.mts} +5 -3
- package/dist/shared/{load-config-BOVuTpJm.mjs → load-config-Dq-xvwYY.mjs} +2 -2
- package/dist/shared/{parse-ast-index-B5HcAOhq.mjs → parse-ast-index-BL17IImH.mjs} +333 -208
- package/dist/shared/{src-BtNlw_84.mjs → src-CWMXqoXE.mjs} +326 -510
- package/package.json +24 -24
|
@@ -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-
|
|
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.
|
|
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
|
|
@@ -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
|
|
569
|
+
var store;
|
|
431
570
|
/* @__NO_SIDE_EFFECTS__ */
|
|
432
571
|
function getGlobalConfig(config2) {
|
|
433
572
|
return {
|
|
434
|
-
lang: config2?.lang ?? store
|
|
573
|
+
lang: config2?.lang ?? store?.lang,
|
|
435
574
|
message: config2?.message,
|
|
436
|
-
abortEarly: config2?.abortEarly ?? store
|
|
437
|
-
abortPipeEarly: config2?.abortPipeEarly ?? store
|
|
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
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
if (
|
|
1429
|
-
|
|
1430
|
-
return
|
|
1431
|
-
|
|
1432
|
-
|
|
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
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
case "
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
if (
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
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
|
-
}
|
|
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
1617
|
}
|
|
1804
|
-
|
|
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
|
-
|
|
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([
|
|
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(
|
|
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
|
|
2283
|
-
return
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
}
|
|
@@ -3373,7 +3189,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
|
|
|
3373
3189
|
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args$1);
|
|
3374
3190
|
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args$1);
|
|
3375
3191
|
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args$1);
|
|
3376
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
|
|
3192
|
+
const { plugin: load$1, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
|
|
3377
3193
|
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args$1);
|
|
3378
3194
|
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args$1);
|
|
3379
3195
|
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args$1);
|
|
@@ -3404,7 +3220,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
|
|
|
3404
3220
|
transformFilter,
|
|
3405
3221
|
moduleParsed,
|
|
3406
3222
|
moduleParsedMeta,
|
|
3407
|
-
load,
|
|
3223
|
+
load: load$1,
|
|
3408
3224
|
loadMeta,
|
|
3409
3225
|
loadFilter,
|
|
3410
3226
|
renderChunk,
|
|
@@ -3853,6 +3669,17 @@ var PluginContextData = class {
|
|
|
3853
3669
|
}
|
|
3854
3670
|
};
|
|
3855
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
|
+
|
|
3856
3683
|
//#endregion
|
|
3857
3684
|
//#region src/utils/bindingify-input-options.ts
|
|
3858
3685
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
@@ -3925,13 +3752,7 @@ function bindingifyExternal(external) {
|
|
|
3925
3752
|
if (id.startsWith("\0")) return false;
|
|
3926
3753
|
return external(id, importer, isResolved) ?? false;
|
|
3927
3754
|
};
|
|
3928
|
-
|
|
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
|
-
};
|
|
3755
|
+
return arraify(external);
|
|
3935
3756
|
}
|
|
3936
3757
|
}
|
|
3937
3758
|
function bindingifyExperimental(experimental) {
|
|
@@ -3965,7 +3786,7 @@ function bindingifyResolve(resolve) {
|
|
|
3965
3786
|
return {
|
|
3966
3787
|
alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
|
|
3967
3788
|
find: name,
|
|
3968
|
-
replacements: arraify(replacement)
|
|
3789
|
+
replacements: replacement === false ? [void 0] : arraify(replacement)
|
|
3969
3790
|
})) : void 0,
|
|
3970
3791
|
extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
|
|
3971
3792
|
target: name,
|
|
@@ -4196,11 +4017,7 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
|
|
|
4196
4017
|
const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
|
|
4197
4018
|
outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
|
|
4198
4019
|
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
|
-
];
|
|
4020
|
+
let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
|
|
4204
4021
|
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
4205
4022
|
try {
|
|
4206
4023
|
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
@@ -4221,27 +4038,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
|
|
|
4221
4038
|
}
|
|
4222
4039
|
}
|
|
4223
4040
|
|
|
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
4041
|
//#endregion
|
|
4246
4042
|
//#region src/utils/transform-hmr-patch-output.ts
|
|
4247
4043
|
function transformHmrPatchOutput(output) {
|
|
@@ -4257,10 +4053,11 @@ function handleHmrPatchOutputErrors(output) {
|
|
|
4257
4053
|
//#endregion
|
|
4258
4054
|
//#region src/api/rolldown/rolldown-build.ts
|
|
4259
4055
|
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
4260
|
-
var RolldownBuild = class {
|
|
4056
|
+
var RolldownBuild = class RolldownBuild {
|
|
4261
4057
|
#inputOptions;
|
|
4262
4058
|
#bundler;
|
|
4263
4059
|
#bundlerImpl;
|
|
4060
|
+
static asyncRuntimeShutdown = false;
|
|
4264
4061
|
constructor(inputOptions) {
|
|
4265
4062
|
this.#inputOptions = inputOptions;
|
|
4266
4063
|
this.#bundler = new BindingBundler();
|
|
@@ -4270,7 +4067,26 @@ var RolldownBuild = class {
|
|
|
4270
4067
|
}
|
|
4271
4068
|
async #getBundlerWithStopWorker(outputOptions) {
|
|
4272
4069
|
if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
|
|
4273
|
-
|
|
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);
|
|
4274
4090
|
}
|
|
4275
4091
|
async generate(outputOptions = {}) {
|
|
4276
4092
|
validateOption("output", outputOptions);
|
|
@@ -4478,4 +4294,4 @@ function defineConfig(config) {
|
|
|
4478
4294
|
const VERSION = version;
|
|
4479
4295
|
|
|
4480
4296
|
//#endregion
|
|
4481
|
-
export { BuiltinPlugin, PluginContextData, PluginDriver,
|
|
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 };
|