rolldown 0.13.2 → 0.14.0
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/LICENSE +1 -1
- package/dist/cjs/cli.cjs +388 -95
- package/dist/cjs/experimental-index.cjs +2 -3
- package/dist/cjs/index.cjs +2 -13
- package/dist/cjs/parallel-plugin-worker.cjs +2 -2
- package/dist/esm/cli.mjs +387 -94
- package/dist/esm/experimental-index.mjs +1 -2
- package/dist/esm/index.mjs +2 -14
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{consola.36c0034f-eps_ogJv.cjs → consola.36c0034f-HcmWcfPe.cjs} +2 -2
- package/dist/shared/{consola.36c0034f-m5cABVv4.mjs → consola.36c0034f-Xyw7SC_7.mjs} +1 -1
- package/dist/shared/{prompt-Ah5G71p-.cjs → prompt-9Ij3R3TG.cjs} +2 -2
- package/dist/shared/{prompt-9VjtYvi_.mjs → prompt-hoPhcrA-.mjs} +1 -1
- package/dist/shared/rolldown-binding.wasi.cjs +82 -73
- package/dist/shared/src_index-3pqhEViJ.cjs +2785 -0
- package/dist/shared/src_index-ywYMd4vB.mjs +2786 -0
- package/dist/shared/watcher-worker.js +1 -0
- package/dist/types/binding.d.ts +154 -66
- package/dist/types/cli/arguments/alias.d.ts +1 -0
- package/dist/types/cli/arguments/index.d.ts +1 -1
- package/dist/types/cli/arguments/normalize.d.ts +1 -0
- package/dist/types/cli/arguments/schema.d.ts +120 -35
- package/dist/types/constants/plugin.d.ts +1 -1
- package/dist/types/constants/types.d.ts +1 -0
- package/dist/types/experimental-index.d.ts +1 -0
- package/dist/types/index.d.ts +6 -5
- package/dist/types/log/logger.d.ts +9 -2
- package/dist/types/options/input-options.d.ts +241 -13
- package/dist/types/options/normalized-alias-plugin-config.d.ts +0 -2
- package/dist/types/options/normalized-output-options.d.ts +1 -1
- package/dist/types/options/output-options.d.ts +52 -54
- package/dist/types/options/watch-option.d.ts +5 -0
- package/dist/types/plugin/bindingify-hook-filter.d.ts +2 -0
- package/dist/types/plugin/bindingify-output-hooks.d.ts +1 -0
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +7 -0
- package/dist/types/plugin/hook-filter.d.ts +48 -0
- package/dist/types/plugin/index.d.ts +9 -15
- package/dist/types/plugin/plugin-context-data.d.ts +1 -1
- package/dist/types/plugin/plugin-context.d.ts +2 -6
- package/dist/types/plugin/plugin-driver.d.ts +1 -0
- package/dist/types/rolldown-build.d.ts +1 -1
- package/dist/types/rolldown.d.ts +3 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/dist/types/utils/create-bundler.d.ts +3 -2
- package/dist/types/utils/transform-to-rollup-output.d.ts +8 -3
- package/dist/types/watcher.d.ts +31 -0
- package/package.json +19 -17
- package/dist/shared/package-8qJYyGdm.cjs +0 -11
- package/dist/shared/package-unZcnfG9.mjs +0 -9
- package/dist/shared/plugin-context-data-F1I9ytXp.cjs +0 -1435
- package/dist/shared/plugin-context-data-iKSAvmTX.mjs +0 -1442
- package/dist/shared/rolldown-ESzFTeqV.cjs +0 -1087
- package/dist/shared/rolldown-Hf7txSlh.mjs +0 -1071
- /package/dist/shared/{chunk-gQ4GMlVi.cjs → chunk-JoMxl5V2.cjs} +0 -0
package/dist/cjs/cli.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __export, __toESM } = require("../shared/chunk-
|
|
4
|
-
const { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, arraify } = require("../shared/
|
|
5
|
-
const {
|
|
6
|
-
const {
|
|
7
|
-
const { createConsola } = require("../shared/consola.36c0034f-eps_ogJv.cjs");
|
|
8
|
-
const { default: nodePath } = __toESM(require("node:path"));
|
|
3
|
+
const { __export, __toESM } = require("../shared/chunk-JoMxl5V2.cjs");
|
|
4
|
+
const { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, arraify, description, rolldown, version, watch } = require("../shared/src_index-3pqhEViJ.cjs");
|
|
5
|
+
const { createConsola } = require("../shared/consola.36c0034f-HcmWcfPe.cjs");
|
|
6
|
+
const { default: nodePath, default: path } = __toESM(require("node:path"));
|
|
9
7
|
const { ZodFirstPartyTypeKind, ZodFirstPartyTypeKind: ZodFirstPartyTypeKind$1, ZodFirstPartyTypeKind: ZodFirstPartyTypeKind$2, z, z: z$1, z: z$2, z: z$3 } = __toESM(require("zod"));
|
|
10
8
|
const { default: process$1, env } = __toESM(require("node:process"));
|
|
11
9
|
const { performance } = __toESM(require("node:perf_hooks"));
|
|
@@ -115,6 +113,205 @@ __export(colors_ns, {
|
|
|
115
113
|
});
|
|
116
114
|
const { bold: bold, cyan: cyan, dim: dim, gray: gray, green: green, red: red, underline: underline, yellow: yellow } = createColors({useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR});
|
|
117
115
|
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
118
|
+
const signals = [];
|
|
119
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
120
|
+
if (process.platform !== "win32") {
|
|
121
|
+
signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
122
|
+
}
|
|
123
|
+
if (process.platform === "linux") {
|
|
124
|
+
signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
129
|
+
const processOk = (process$3) => !!process$3 && typeof process$3 === "object" && typeof process$3.removeListener === "function" && typeof process$3.emit === "function" && typeof process$3.reallyExit === "function" && typeof process$3.listeners === "function" && typeof process$3.kill === "function" && typeof process$3.pid === "number" && typeof process$3.on === "function";
|
|
130
|
+
const kExitEmitter = Symbol.for("signal-exit emitter");
|
|
131
|
+
const global = globalThis;
|
|
132
|
+
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
133
|
+
class Emitter {
|
|
134
|
+
emitted = {
|
|
135
|
+
afterExit: false,
|
|
136
|
+
exit: false
|
|
137
|
+
};
|
|
138
|
+
listeners = {
|
|
139
|
+
afterExit: [],
|
|
140
|
+
exit: []
|
|
141
|
+
};
|
|
142
|
+
count = 0;
|
|
143
|
+
id = Math.random();
|
|
144
|
+
constructor() {
|
|
145
|
+
if (global[kExitEmitter]) {
|
|
146
|
+
return global[kExitEmitter];
|
|
147
|
+
}
|
|
148
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
149
|
+
value: this,
|
|
150
|
+
writable: false,
|
|
151
|
+
enumerable: false,
|
|
152
|
+
configurable: false
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
on(ev, fn) {
|
|
156
|
+
this.listeners[ev].push(fn);
|
|
157
|
+
}
|
|
158
|
+
removeListener(ev, fn) {
|
|
159
|
+
const list = this.listeners[ev];
|
|
160
|
+
const i = list.indexOf(fn);
|
|
161
|
+
if (i === -1) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (i === 0 && list.length === 1) {
|
|
165
|
+
list.length = 0;
|
|
166
|
+
} else {
|
|
167
|
+
list.splice(i, 1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
emit(ev, code, signal) {
|
|
171
|
+
if (this.emitted[ev]) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
this.emitted[ev] = true;
|
|
175
|
+
let ret = false;
|
|
176
|
+
for (const fn of this.listeners[ev]) {
|
|
177
|
+
ret = fn(code, signal) === true || ret;
|
|
178
|
+
}
|
|
179
|
+
if (ev === "exit") {
|
|
180
|
+
ret = this.emit("afterExit", code, signal) || ret;
|
|
181
|
+
}
|
|
182
|
+
return ret;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
class SignalExitBase {}
|
|
186
|
+
const signalExitWrap = (handler) => {
|
|
187
|
+
return {
|
|
188
|
+
onExit(cb, opts) {
|
|
189
|
+
return handler.onExit(cb, opts);
|
|
190
|
+
},
|
|
191
|
+
load() {
|
|
192
|
+
return handler.load();
|
|
193
|
+
},
|
|
194
|
+
unload() {
|
|
195
|
+
return handler.unload();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
class SignalExitFallback extends SignalExitBase {
|
|
200
|
+
onExit() {
|
|
201
|
+
return () => {};
|
|
202
|
+
}
|
|
203
|
+
load() {}
|
|
204
|
+
unload() {}
|
|
205
|
+
}
|
|
206
|
+
class SignalExit extends SignalExitBase {
|
|
207
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
208
|
+
#emitter = new Emitter();
|
|
209
|
+
#process;
|
|
210
|
+
#originalProcessEmit;
|
|
211
|
+
#originalProcessReallyExit;
|
|
212
|
+
#sigListeners = {};
|
|
213
|
+
#loaded = false;
|
|
214
|
+
constructor(process$3) {
|
|
215
|
+
super();
|
|
216
|
+
this.#process = process$3;
|
|
217
|
+
this.#sigListeners = {};
|
|
218
|
+
for (const sig of signals) {
|
|
219
|
+
this.#sigListeners[sig] = () => {
|
|
220
|
+
const listeners = this.#process.listeners(sig);
|
|
221
|
+
let { count: count } = this.#emitter;
|
|
222
|
+
const p = process$3;
|
|
223
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
|
|
224
|
+
count += p.__signal_exit_emitter__.count;
|
|
225
|
+
}
|
|
226
|
+
if (listeners.length === count) {
|
|
227
|
+
this.unload();
|
|
228
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
229
|
+
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
230
|
+
if (!ret) process$3.kill(process$3.pid, s);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
this.#originalProcessReallyExit = process$3.reallyExit;
|
|
235
|
+
this.#originalProcessEmit = process$3.emit;
|
|
236
|
+
}
|
|
237
|
+
onExit(cb, opts) {
|
|
238
|
+
if (!processOk(this.#process)) {
|
|
239
|
+
return () => {};
|
|
240
|
+
}
|
|
241
|
+
if (this.#loaded === false) {
|
|
242
|
+
this.load();
|
|
243
|
+
}
|
|
244
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
245
|
+
this.#emitter.on(ev, cb);
|
|
246
|
+
return () => {
|
|
247
|
+
this.#emitter.removeListener(ev, cb);
|
|
248
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
|
|
249
|
+
this.unload();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
load() {
|
|
254
|
+
if (this.#loaded) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
this.#loaded = true;
|
|
258
|
+
this.#emitter.count += 1;
|
|
259
|
+
for (const sig of signals) {
|
|
260
|
+
try {
|
|
261
|
+
const fn = this.#sigListeners[sig];
|
|
262
|
+
if (fn) this.#process.on(sig, fn);
|
|
263
|
+
} catch (_) {}
|
|
264
|
+
}
|
|
265
|
+
this.#process.emit = (ev, ...a) => {
|
|
266
|
+
return this.#processEmit(ev, ...a);
|
|
267
|
+
};
|
|
268
|
+
this.#process.reallyExit = (code) => {
|
|
269
|
+
return this.#processReallyExit(code);
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
unload() {
|
|
273
|
+
if (!this.#loaded) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
this.#loaded = false;
|
|
277
|
+
signals.forEach((sig) => {
|
|
278
|
+
const listener = this.#sigListeners[sig];
|
|
279
|
+
if (!listener) {
|
|
280
|
+
throw new Error("Listener not defined for signal: " + sig);
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
this.#process.removeListener(sig, listener);
|
|
284
|
+
} catch (_) {}
|
|
285
|
+
});
|
|
286
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
287
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
288
|
+
this.#emitter.count -= 1;
|
|
289
|
+
}
|
|
290
|
+
#processReallyExit(code) {
|
|
291
|
+
if (!processOk(this.#process)) {
|
|
292
|
+
return 0;
|
|
293
|
+
}
|
|
294
|
+
this.#process.exitCode = code || 0;
|
|
295
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
296
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
297
|
+
}
|
|
298
|
+
#processEmit(ev, ...args) {
|
|
299
|
+
const og = this.#originalProcessEmit;
|
|
300
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
301
|
+
if (typeof args[0] === "number") {
|
|
302
|
+
this.#process.exitCode = args[0];
|
|
303
|
+
}
|
|
304
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
305
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
306
|
+
return ret;
|
|
307
|
+
} else {
|
|
308
|
+
return og.call(this.#process, ev, ...args);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const process$2 = globalThis.process;
|
|
313
|
+
const { onExit: onExit, load: load, unload: unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
314
|
+
|
|
118
315
|
//#endregion
|
|
119
316
|
//#region src/cli/commands/bundle.ts
|
|
120
317
|
async function bundleWithConfig(configPath, cliOptions) {
|
|
@@ -125,13 +322,13 @@ async function bundleWithConfig(configPath, cliOptions) {
|
|
|
125
322
|
}
|
|
126
323
|
const configList = arraify(config);
|
|
127
324
|
for (const config$1 of configList) {
|
|
128
|
-
await bundleInner(config$1, cliOptions);
|
|
325
|
+
cliOptions.watch ? await watchInner(config$1, cliOptions) : bundleInner(config$1, cliOptions);
|
|
129
326
|
}
|
|
130
327
|
}
|
|
131
328
|
async function bundleWithCliOptions(cliOptions) {
|
|
132
329
|
if (cliOptions.output.dir) {
|
|
133
|
-
await bundleInner({}, cliOptions);
|
|
134
|
-
} else {
|
|
330
|
+
cliOptions.watch ? await watchInner({}, cliOptions) : await bundleInner({}, cliOptions);
|
|
331
|
+
} else if (!cliOptions.watch) {
|
|
135
332
|
const build = await rolldown(cliOptions.input);
|
|
136
333
|
const { output: output } = await build.generate(cliOptions.output);
|
|
137
334
|
if (output.length > 1) {
|
|
@@ -143,8 +340,42 @@ async function bundleWithCliOptions(cliOptions) {
|
|
|
143
340
|
} else {
|
|
144
341
|
logger.log(output[0].code);
|
|
145
342
|
}
|
|
343
|
+
} else {
|
|
344
|
+
logger.error("You must specify `output.dir` to use watch mode");
|
|
345
|
+
process.exit(1);
|
|
146
346
|
}
|
|
147
347
|
}
|
|
348
|
+
async function watchInner(options$1, cliOptions) {
|
|
349
|
+
const watcher = await watch({
|
|
350
|
+
...options$1,
|
|
351
|
+
...cliOptions.input
|
|
352
|
+
});
|
|
353
|
+
onExit((code) => {
|
|
354
|
+
(Promise.resolve(watcher.close())).finally(() => {
|
|
355
|
+
process.exit(typeof code === "number" ? code : 0);
|
|
356
|
+
});
|
|
357
|
+
return true;
|
|
358
|
+
});
|
|
359
|
+
const changedFile = [];
|
|
360
|
+
watcher.on("change", (id, event) => {
|
|
361
|
+
if (event.event === "update") {
|
|
362
|
+
changedFile.push(id);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
watcher.on("event", (event) => {
|
|
366
|
+
switch (event.code) {
|
|
367
|
+
case "BUNDLE_START":
|
|
368
|
+
logger.log(`Found ${bold((changedFile.map(relativeId)).join(", "))} changed, rebuilding...`);
|
|
369
|
+
changedFile.length = 0;
|
|
370
|
+
break;
|
|
371
|
+
case "BUNDLE_END":
|
|
372
|
+
logger.success(`Rebuilt ${bold(relativeId(event.output[0]))} in ${bold(ms(event.duration))}.`);
|
|
373
|
+
break;
|
|
374
|
+
default: break;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
logger.log(`Waiting for changes...`);
|
|
378
|
+
}
|
|
148
379
|
async function bundleInner(options$1, cliOptions) {
|
|
149
380
|
const startTime = performance.now();
|
|
150
381
|
const build = await rolldown({
|
|
@@ -159,8 +390,7 @@ async function bundleInner(options$1, cliOptions) {
|
|
|
159
390
|
printBundleOutputPretty(bundleOutput);
|
|
160
391
|
logger.log(``);
|
|
161
392
|
const duration = endTime - startTime;
|
|
162
|
-
|
|
163
|
-
logger.success(`Finished in ${bold(spent)}`);
|
|
393
|
+
logger.success(`Finished in ${bold(ms(duration))}`);
|
|
164
394
|
}
|
|
165
395
|
function printBundleOutputPretty(output) {
|
|
166
396
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -221,15 +451,22 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
221
451
|
}
|
|
222
452
|
}
|
|
223
453
|
}
|
|
224
|
-
function withTrailingSlash(path) {
|
|
225
|
-
if (path[path.length - 1] !== "/") {
|
|
226
|
-
return `${path}/`;
|
|
454
|
+
function withTrailingSlash(path$1) {
|
|
455
|
+
if (path$1[path$1.length - 1] !== "/") {
|
|
456
|
+
return `${path$1}/`;
|
|
227
457
|
}
|
|
228
|
-
return path;
|
|
458
|
+
return path$1;
|
|
459
|
+
}
|
|
460
|
+
function ms(duration) {
|
|
461
|
+
return duration < 1000 ? `${duration.toFixed(2)} ms` : `${(duration / 1000).toFixed(2)} s`;
|
|
462
|
+
}
|
|
463
|
+
function relativeId(id) {
|
|
464
|
+
if (!path.isAbsolute(id)) return id;
|
|
465
|
+
return path.relative(path.resolve(), id);
|
|
229
466
|
}
|
|
230
467
|
|
|
231
468
|
//#endregion
|
|
232
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
469
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
233
470
|
const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
234
471
|
const defaultOptions = {
|
|
235
472
|
name: undefined,
|
|
@@ -261,7 +498,7 @@ const getDefaultOptions = (options$1) => typeof options$1 === "string" ? {
|
|
|
261
498
|
};
|
|
262
499
|
|
|
263
500
|
//#endregion
|
|
264
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
501
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
265
502
|
const getRefs = (options$1) => {
|
|
266
503
|
const _options = getDefaultOptions(options$1);
|
|
267
504
|
const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
@@ -278,7 +515,7 @@ const getRefs = (options$1) => {
|
|
|
278
515
|
};
|
|
279
516
|
|
|
280
517
|
//#endregion
|
|
281
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
518
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
282
519
|
function addErrorMessage(res, key, errorMessage, refs) {
|
|
283
520
|
if (!refs?.errorMessages) return;
|
|
284
521
|
if (errorMessage) {
|
|
@@ -294,16 +531,16 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
|
294
531
|
}
|
|
295
532
|
|
|
296
533
|
//#endregion
|
|
297
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
534
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
298
535
|
function parseAnyDef() {
|
|
299
536
|
return {};
|
|
300
537
|
}
|
|
301
538
|
|
|
302
539
|
//#endregion
|
|
303
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
540
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
304
541
|
function parseArrayDef(def, refs) {
|
|
305
542
|
const res = {type: "array"};
|
|
306
|
-
if (def.type?._def?.typeName !== ZodFirstPartyTypeKind$2.ZodAny) {
|
|
543
|
+
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind$2.ZodAny) {
|
|
307
544
|
res.items = parseDef(def.type._def, {
|
|
308
545
|
...refs,
|
|
309
546
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -323,7 +560,7 @@ function parseArrayDef(def, refs) {
|
|
|
323
560
|
}
|
|
324
561
|
|
|
325
562
|
//#endregion
|
|
326
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
563
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
327
564
|
function parseBigintDef(def, refs) {
|
|
328
565
|
const res = {
|
|
329
566
|
type: "integer",
|
|
@@ -369,25 +606,25 @@ function parseBigintDef(def, refs) {
|
|
|
369
606
|
}
|
|
370
607
|
|
|
371
608
|
//#endregion
|
|
372
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
609
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
373
610
|
function parseBooleanDef() {
|
|
374
611
|
return {type: "boolean"};
|
|
375
612
|
}
|
|
376
613
|
|
|
377
614
|
//#endregion
|
|
378
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
615
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
379
616
|
function parseBrandedDef(_def, refs) {
|
|
380
617
|
return parseDef(_def.type._def, refs);
|
|
381
618
|
}
|
|
382
619
|
|
|
383
620
|
//#endregion
|
|
384
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
621
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
385
622
|
const parseCatchDef = (def, refs) => {
|
|
386
623
|
return parseDef(def.innerType._def, refs);
|
|
387
624
|
};
|
|
388
625
|
|
|
389
626
|
//#endregion
|
|
390
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
627
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
391
628
|
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
392
629
|
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
393
630
|
if (Array.isArray(strategy)) {
|
|
@@ -428,7 +665,7 @@ const integerDateParser = (def, refs) => {
|
|
|
428
665
|
};
|
|
429
666
|
|
|
430
667
|
//#endregion
|
|
431
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
668
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
432
669
|
function parseDefaultDef(_def, refs) {
|
|
433
670
|
return {
|
|
434
671
|
...parseDef(_def.innerType._def, refs),
|
|
@@ -437,13 +674,13 @@ function parseDefaultDef(_def, refs) {
|
|
|
437
674
|
}
|
|
438
675
|
|
|
439
676
|
//#endregion
|
|
440
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
677
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
441
678
|
function parseEffectsDef(_def, refs) {
|
|
442
679
|
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : {};
|
|
443
680
|
}
|
|
444
681
|
|
|
445
682
|
//#endregion
|
|
446
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
683
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
447
684
|
function parseEnumDef(def) {
|
|
448
685
|
return {
|
|
449
686
|
type: "string",
|
|
@@ -452,7 +689,7 @@ function parseEnumDef(def) {
|
|
|
452
689
|
}
|
|
453
690
|
|
|
454
691
|
//#endregion
|
|
455
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
692
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
456
693
|
const isJsonSchema7AllOfType = (type) => {
|
|
457
694
|
if ("type"in type && type.type === "string") return false;
|
|
458
695
|
return "allOf"in type;
|
|
@@ -491,7 +728,7 @@ function parseIntersectionDef(def, refs) {
|
|
|
491
728
|
}
|
|
492
729
|
|
|
493
730
|
//#endregion
|
|
494
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
731
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
495
732
|
function parseLiteralDef(def, refs) {
|
|
496
733
|
const parsedType = typeof def.value;
|
|
497
734
|
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
@@ -510,7 +747,7 @@ function parseLiteralDef(def, refs) {
|
|
|
510
747
|
}
|
|
511
748
|
|
|
512
749
|
//#endregion
|
|
513
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
750
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
514
751
|
let emojiRegex;
|
|
515
752
|
const zodPatterns = {
|
|
516
753
|
cuid: /^[cC][^\s-]{8,}$/,
|
|
@@ -766,7 +1003,7 @@ const processRegExp = (regexOrFunction, refs) => {
|
|
|
766
1003
|
};
|
|
767
1004
|
|
|
768
1005
|
//#endregion
|
|
769
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1006
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
770
1007
|
function parseRecordDef(def, refs) {
|
|
771
1008
|
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodEnum) {
|
|
772
1009
|
return {
|
|
@@ -793,10 +1030,7 @@ function parseRecordDef(def, refs) {
|
|
|
793
1030
|
return schema$1;
|
|
794
1031
|
}
|
|
795
1032
|
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodString && def.keyType._def.checks?.length) {
|
|
796
|
-
const keyType =
|
|
797
|
-
...acc,
|
|
798
|
-
[key]: value
|
|
799
|
-
}, {});
|
|
1033
|
+
const { type: type,...keyType } = parseStringDef(def.keyType._def, refs);
|
|
800
1034
|
return {
|
|
801
1035
|
...schema$1,
|
|
802
1036
|
propertyNames: keyType
|
|
@@ -806,12 +1040,18 @@ function parseRecordDef(def, refs) {
|
|
|
806
1040
|
...schema$1,
|
|
807
1041
|
propertyNames: {enum: def.keyType._def.values}
|
|
808
1042
|
};
|
|
1043
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind$1.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
1044
|
+
const { type: type,...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
1045
|
+
return {
|
|
1046
|
+
...schema$1,
|
|
1047
|
+
propertyNames: keyType
|
|
1048
|
+
};
|
|
809
1049
|
}
|
|
810
1050
|
return schema$1;
|
|
811
1051
|
}
|
|
812
1052
|
|
|
813
1053
|
//#endregion
|
|
814
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1054
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
815
1055
|
function parseMapDef(def, refs) {
|
|
816
1056
|
if (refs.mapStrategy === "record") {
|
|
817
1057
|
return parseRecordDef(def, refs);
|
|
@@ -837,7 +1077,7 @@ function parseMapDef(def, refs) {
|
|
|
837
1077
|
}
|
|
838
1078
|
|
|
839
1079
|
//#endregion
|
|
840
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1080
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
841
1081
|
function parseNativeEnumDef(def) {
|
|
842
1082
|
const object = def.values;
|
|
843
1083
|
const actualKeys = (Object.keys(def.values)).filter((key) => {
|
|
@@ -852,13 +1092,13 @@ function parseNativeEnumDef(def) {
|
|
|
852
1092
|
}
|
|
853
1093
|
|
|
854
1094
|
//#endregion
|
|
855
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1095
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
856
1096
|
function parseNeverDef() {
|
|
857
1097
|
return {not: {}};
|
|
858
1098
|
}
|
|
859
1099
|
|
|
860
1100
|
//#endregion
|
|
861
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1101
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
862
1102
|
function parseNullDef(refs) {
|
|
863
1103
|
return refs.target === "openApi3" ? {
|
|
864
1104
|
enum: ["null"],
|
|
@@ -867,7 +1107,7 @@ function parseNullDef(refs) {
|
|
|
867
1107
|
}
|
|
868
1108
|
|
|
869
1109
|
//#endregion
|
|
870
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1110
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
871
1111
|
const primitiveMappings = {
|
|
872
1112
|
ZodString: "string",
|
|
873
1113
|
ZodNumber: "number",
|
|
@@ -925,7 +1165,7 @@ const asAnyOf = (def, refs) => {
|
|
|
925
1165
|
};
|
|
926
1166
|
|
|
927
1167
|
//#endregion
|
|
928
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1168
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
929
1169
|
function parseNullableDef(def, refs) {
|
|
930
1170
|
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
931
1171
|
if (refs.target === "openApi3") {
|
|
@@ -958,7 +1198,7 @@ function parseNullableDef(def, refs) {
|
|
|
958
1198
|
}
|
|
959
1199
|
|
|
960
1200
|
//#endregion
|
|
961
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1201
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
962
1202
|
function parseNumberDef(def, refs) {
|
|
963
1203
|
const res = {type: "number"};
|
|
964
1204
|
if (!def.checks) return res;
|
|
@@ -1005,7 +1245,7 @@ function parseNumberDef(def, refs) {
|
|
|
1005
1245
|
}
|
|
1006
1246
|
|
|
1007
1247
|
//#endregion
|
|
1008
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1248
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
1009
1249
|
function decideAdditionalProperties(def, refs) {
|
|
1010
1250
|
if (refs.removeAdditionalStrategy === "strict") {
|
|
1011
1251
|
return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys !== "strict" : parseDef(def.catchall._def, {
|
|
@@ -1048,7 +1288,7 @@ function parseObjectDef(def, refs) {
|
|
|
1048
1288
|
}
|
|
1049
1289
|
|
|
1050
1290
|
//#endregion
|
|
1051
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1291
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
1052
1292
|
const parseOptionalDef = (def, refs) => {
|
|
1053
1293
|
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
1054
1294
|
return parseDef(def.innerType._def, refs);
|
|
@@ -1061,7 +1301,7 @@ const parseOptionalDef = (def, refs) => {
|
|
|
1061
1301
|
};
|
|
1062
1302
|
|
|
1063
1303
|
//#endregion
|
|
1064
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1304
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
1065
1305
|
const parsePipelineDef = (def, refs) => {
|
|
1066
1306
|
if (refs.pipeStrategy === "input") {
|
|
1067
1307
|
return parseDef(def.in._def, refs);
|
|
@@ -1080,13 +1320,13 @@ const parsePipelineDef = (def, refs) => {
|
|
|
1080
1320
|
};
|
|
1081
1321
|
|
|
1082
1322
|
//#endregion
|
|
1083
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1323
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
1084
1324
|
function parsePromiseDef(def, refs) {
|
|
1085
1325
|
return parseDef(def.type._def, refs);
|
|
1086
1326
|
}
|
|
1087
1327
|
|
|
1088
1328
|
//#endregion
|
|
1089
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1329
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
1090
1330
|
function parseSetDef(def, refs) {
|
|
1091
1331
|
const items = parseDef(def.valueType._def, {
|
|
1092
1332
|
...refs,
|
|
@@ -1107,7 +1347,7 @@ function parseSetDef(def, refs) {
|
|
|
1107
1347
|
}
|
|
1108
1348
|
|
|
1109
1349
|
//#endregion
|
|
1110
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1350
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
1111
1351
|
function parseTupleDef(def, refs) {
|
|
1112
1352
|
if (def.rest) {
|
|
1113
1353
|
return {
|
|
@@ -1136,25 +1376,25 @@ function parseTupleDef(def, refs) {
|
|
|
1136
1376
|
}
|
|
1137
1377
|
|
|
1138
1378
|
//#endregion
|
|
1139
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1379
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
1140
1380
|
function parseUndefinedDef() {
|
|
1141
1381
|
return {not: {}};
|
|
1142
1382
|
}
|
|
1143
1383
|
|
|
1144
1384
|
//#endregion
|
|
1145
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1385
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
1146
1386
|
function parseUnknownDef() {
|
|
1147
1387
|
return {};
|
|
1148
1388
|
}
|
|
1149
1389
|
|
|
1150
1390
|
//#endregion
|
|
1151
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1391
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
1152
1392
|
const parseReadonlyDef = (def, refs) => {
|
|
1153
1393
|
return parseDef(def.innerType._def, refs);
|
|
1154
1394
|
};
|
|
1155
1395
|
|
|
1156
1396
|
//#endregion
|
|
1157
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1397
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
1158
1398
|
function parseDef(def, refs, forceResolution = false) {
|
|
1159
1399
|
const seenItem = refs.seen.get(def);
|
|
1160
1400
|
if (refs.override) {
|
|
@@ -1255,7 +1495,7 @@ const addMeta = (def, refs, jsonSchema) => {
|
|
|
1255
1495
|
};
|
|
1256
1496
|
|
|
1257
1497
|
//#endregion
|
|
1258
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.
|
|
1498
|
+
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
1259
1499
|
const zodToJsonSchema = (schema$1, options$1) => {
|
|
1260
1500
|
const refs = getRefs(options$1);
|
|
1261
1501
|
const definitions = typeof options$1 === "object" && options$1.definitions ? (Object.entries(options$1.definitions)).reduce((acc, [name$1, schema$2]) => ({
|
|
@@ -1309,7 +1549,27 @@ const voidNullable = () => {
|
|
|
1309
1549
|
//#region src/options/input-options.ts
|
|
1310
1550
|
const inputOptionSchema = ((z$2.string()).or((z$2.string()).array())).or(z$2.record(z$2.string()));
|
|
1311
1551
|
const externalSchema = ((stringOrRegExp()).or((stringOrRegExp()).array())).or(((z$2.function()).args(z$2.string(), (z$2.string()).optional(), z$2.boolean())).returns(voidNullableWith(z$2.boolean())));
|
|
1312
|
-
const moduleTypesSchema = z$2.record((((((((((z$2.literal("js")).or(z$2.literal("jsx"))).or(z$2.literal("ts"))).or(z$2.literal("tsx"))).or(z$2.literal("json"))).or(z$2.literal("text"))).or(z$2.literal("base64"))).or(z$2.literal("dataurl"))).or(z$2.literal("binary"))).or(z$2.literal("empty")));
|
|
1552
|
+
const moduleTypesSchema = z$2.record(((((((((((z$2.literal("js")).or(z$2.literal("jsx"))).or(z$2.literal("ts"))).or(z$2.literal("tsx"))).or(z$2.literal("json"))).or(z$2.literal("text"))).or(z$2.literal("base64"))).or(z$2.literal("dataurl"))).or(z$2.literal("binary"))).or(z$2.literal("empty"))).or(z$2.literal("css")));
|
|
1553
|
+
const jsxOptionsSchema = z$2.strictObject({
|
|
1554
|
+
mode: (((z$2.literal("classic")).or(z$2.literal("automatic"))).describe("Jsx transformation mode")).optional(),
|
|
1555
|
+
factory: ((z$2.string()).describe("Jsx element transformation")).optional(),
|
|
1556
|
+
fragment: ((z$2.string()).describe("Jsx fragment transformation")).optional(),
|
|
1557
|
+
importSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is classic")).optional(),
|
|
1558
|
+
jsxImportSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is automatic")).optional(),
|
|
1559
|
+
refresh: ((z$2.boolean()).describe("React refresh transformation")).optional(),
|
|
1560
|
+
development: ((z$2.boolean()).describe("Development specific information")).optional()
|
|
1561
|
+
});
|
|
1562
|
+
const stringOrRegExpSchema = (stringOrRegExp()).or((stringOrRegExp()).array());
|
|
1563
|
+
const watchOptionsSchema = z$2.strictObject({
|
|
1564
|
+
skipWrite: ((z$2.boolean()).describe("Skip the bundle.write() step")).optional(),
|
|
1565
|
+
notify: ((z$2.strictObject({
|
|
1566
|
+
pollInterval: (z$2.number()).optional(),
|
|
1567
|
+
compareContents: (z$2.boolean()).optional()
|
|
1568
|
+
})).describe("Notify options")).optional(),
|
|
1569
|
+
include: stringOrRegExpSchema.optional(),
|
|
1570
|
+
exclude: stringOrRegExpSchema.optional(),
|
|
1571
|
+
chokidar: (z$2.any()).optional()
|
|
1572
|
+
});
|
|
1313
1573
|
const inputOptionsSchema = z$2.strictObject({
|
|
1314
1574
|
input: inputOptionSchema.optional(),
|
|
1315
1575
|
plugins: ((phantom()).array()).optional(),
|
|
@@ -1318,6 +1578,7 @@ const inputOptionsSchema = z$2.strictObject({
|
|
|
1318
1578
|
alias: (z$2.record(z$2.string())).optional(),
|
|
1319
1579
|
aliasFields: (z$2.array(z$2.array(z$2.string()))).optional(),
|
|
1320
1580
|
conditionNames: optionalStringArray(),
|
|
1581
|
+
extensionAlias: (z$2.record(z$2.string(), z$2.array(z$2.string()))).optional(),
|
|
1321
1582
|
exportsFields: (z$2.array(z$2.array(z$2.string()))).optional(),
|
|
1322
1583
|
extensions: optionalStringArray(),
|
|
1323
1584
|
mainFields: optionalStringArray(),
|
|
@@ -1334,9 +1595,16 @@ const inputOptionsSchema = z$2.strictObject({
|
|
|
1334
1595
|
onLog: ((z$2.function()).args(LogLevelSchema, RollupLogSchema, (z$2.function()).args(LogLevelWithErrorSchema, RollupLogWithStringSchema))).optional(),
|
|
1335
1596
|
onwarn: ((z$2.function()).args(RollupLogSchema, (z$2.function()).args(RollupLogWithStringSchema.or((z$2.function()).returns(RollupLogWithStringSchema))))).optional(),
|
|
1336
1597
|
moduleTypes: (moduleTypesSchema.describe("module types for customized extensions.")).optional(),
|
|
1337
|
-
experimental: (z$2.strictObject({
|
|
1598
|
+
experimental: (z$2.strictObject({
|
|
1599
|
+
enableComposingJsPlugins: (z$2.boolean()).optional(),
|
|
1600
|
+
strictExecutionOrder: (z$2.boolean()).optional(),
|
|
1601
|
+
disableLiveBindings: (z$2.boolean()).optional()
|
|
1602
|
+
})).optional(),
|
|
1338
1603
|
define: ((z$2.record(z$2.string())).describe("define global variables")).optional(),
|
|
1339
|
-
inject: (z$2.record((z$2.string()).or(z$2.tuple([z$2.string(), z$2.string()])))).optional()
|
|
1604
|
+
inject: (z$2.record((z$2.string()).or(z$2.tuple([z$2.string(), z$2.string()])))).optional(),
|
|
1605
|
+
profilerNames: (z$2.boolean()).optional(),
|
|
1606
|
+
jsx: jsxOptionsSchema.optional(),
|
|
1607
|
+
watch: (watchOptionsSchema.or(z$2.literal(false))).optional()
|
|
1340
1608
|
});
|
|
1341
1609
|
const inputCliOptionsSchema = (inputOptionsSchema.extend({
|
|
1342
1610
|
external: ((z$2.array(z$2.string())).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")).optional(),
|
|
@@ -1348,16 +1616,19 @@ const inputCliOptionsSchema = (inputOptionsSchema.extend({
|
|
|
1348
1616
|
onwarn: true,
|
|
1349
1617
|
onLog: true,
|
|
1350
1618
|
resolve: true,
|
|
1351
|
-
experimental: true
|
|
1619
|
+
experimental: true,
|
|
1620
|
+
profilerNames: true,
|
|
1621
|
+
watch: true
|
|
1352
1622
|
});
|
|
1353
1623
|
|
|
1354
1624
|
//#endregion
|
|
1355
1625
|
//#region src/options/output-options.ts
|
|
1356
|
-
const ModuleFormatSchema = (((((((z$1.literal("es")).or(z$1.literal("cjs"))).or(z$1.literal("esm"))).or(z$1.literal("module"))).or(z$1.literal("commonjs"))).or(z$1.literal("iife"))).describe(`output format of the generated bundle (supports ${underline("esm")}, cjs, and iife).`)).optional();
|
|
1626
|
+
const ModuleFormatSchema = ((((((((z$1.literal("es")).or(z$1.literal("cjs"))).or(z$1.literal("esm"))).or(z$1.literal("module"))).or(z$1.literal("commonjs"))).or(z$1.literal("iife"))).or(z$1.literal("umd"))).describe(`output format of the generated bundle (supports ${underline("esm")}, cjs, and iife).`)).optional();
|
|
1357
1627
|
const addonFunctionSchema = ((z$1.function()).args(phantom())).returns((z$1.string()).or(z$1.promise(z$1.string())));
|
|
1358
1628
|
const chunkFileNamesFunctionSchema = ((z$1.function()).args(phantom())).returns(z$1.string());
|
|
1359
1629
|
const outputOptionsSchema = z$1.strictObject({
|
|
1360
|
-
dir: ((z$1.string()).describe("Output directory, defaults to `dist
|
|
1630
|
+
dir: ((z$1.string()).describe("Output directory, defaults to `dist` if `file` is not set.")).optional(),
|
|
1631
|
+
file: ((z$1.string()).describe("Single output file")).optional(),
|
|
1361
1632
|
exports: (((((z$1.literal("auto")).or(z$1.literal("named"))).or(z$1.literal("default"))).or(z$1.literal("none"))).describe(`specify a export mode (${underline("auto")}, named, default, none)`)).optional(),
|
|
1362
1633
|
format: ModuleFormatSchema,
|
|
1363
1634
|
sourcemap: ((((z$1.boolean()).or(z$1.literal("inline"))).or(z$1.literal("hidden"))).describe(`generate sourcemap (\`-s inline\` for inline, or ${bold("pass the `-s` on the last argument if you want to generate `.map` file")}).`)).optional(),
|
|
@@ -1367,22 +1638,22 @@ const outputOptionsSchema = z$1.strictObject({
|
|
|
1367
1638
|
footer: ((z$1.string()).or(addonFunctionSchema)).optional(),
|
|
1368
1639
|
intro: ((z$1.string()).or(addonFunctionSchema)).optional(),
|
|
1369
1640
|
outro: ((z$1.string()).or(addonFunctionSchema)).optional(),
|
|
1370
|
-
extend: ((z$1.boolean()).describe("extend global variable defined by name in IIFE
|
|
1641
|
+
extend: ((z$1.boolean()).describe("extend global variable defined by name in IIFE / UMD formats")).optional(),
|
|
1371
1642
|
esModule: ((z$1.literal("if-default-prop")).or(z$1.boolean())).optional(),
|
|
1372
1643
|
entryFileNames: ((z$1.string()).or(chunkFileNamesFunctionSchema)).optional(),
|
|
1373
1644
|
chunkFileNames: ((z$1.string()).or(chunkFileNamesFunctionSchema)).optional(),
|
|
1374
1645
|
assetFileNames: (z$1.string()).optional(),
|
|
1375
1646
|
minify: ((z$1.boolean()).describe("minify the bundled file.")).optional(),
|
|
1376
1647
|
name: ((z$1.string()).describe("name for UMD / IIFE format outputs")).optional(),
|
|
1377
|
-
globals: ((z$1.record(z$1.string())).describe("
|
|
1378
|
-
externalLiveBindings: (((z$1.boolean()).describe("
|
|
1648
|
+
globals: ((z$1.record(z$1.string())).describe("global variable of UMD / IIFE dependencies (syntax: `key=value`)")).optional(),
|
|
1649
|
+
externalLiveBindings: (((z$1.boolean()).describe("external live bindings")).default(true)).optional(),
|
|
1379
1650
|
inlineDynamicImports: (((z$1.boolean()).describe("inline dynamic imports")).default(false)).optional(),
|
|
1380
1651
|
advancedChunks: (z$1.strictObject({
|
|
1381
1652
|
minSize: (z$1.number()).optional(),
|
|
1382
1653
|
minShareCount: (z$1.number()).optional(),
|
|
1383
1654
|
groups: (z$1.array(z$1.strictObject({
|
|
1384
1655
|
name: z$1.string(),
|
|
1385
|
-
test: (z$1.string()).optional(),
|
|
1656
|
+
test: ((z$1.string()).or(z$1.instanceof(RegExp))).optional(),
|
|
1386
1657
|
priority: (z$1.number()).optional(),
|
|
1387
1658
|
minSize: (z$1.number()).optional(),
|
|
1388
1659
|
minShareCount: (z$1.number()).optional()
|
|
@@ -1398,16 +1669,22 @@ const outputCliOptionsSchema = (outputOptionsSchema.extend({
|
|
|
1398
1669
|
intro: ((z$1.string()).describe(getAddonDescription("top", "inside"))).optional(),
|
|
1399
1670
|
outro: ((z$1.string()).describe(getAddonDescription("bottom", "inside"))).optional(),
|
|
1400
1671
|
esModule: ((z$1.boolean()).describe("always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable).")).optional(),
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1672
|
+
advancedChunks: (z$1.strictObject({
|
|
1673
|
+
minSize: ((z$1.number()).describe("minimum size of the chunk")).optional(),
|
|
1674
|
+
minShareCount: ((z$1.number()).describe("minimum share count of the chunk")).optional()
|
|
1675
|
+
})).optional()
|
|
1676
|
+
})).omit({
|
|
1677
|
+
sourcemapPathTransform: true,
|
|
1678
|
+
sourcemapIgnoreList: true
|
|
1679
|
+
});
|
|
1404
1680
|
|
|
1405
1681
|
//#endregion
|
|
1406
1682
|
//#region src/cli/arguments/schema.ts
|
|
1407
1683
|
const cliOptionsSchema = ((z.strictObject({
|
|
1408
|
-
config: (((z.string()).or(z.boolean())).describe("Path to the config file (default: `
|
|
1684
|
+
config: (((z.string()).or(z.boolean())).describe("Path to the config file (default: `rolldown.config.js`)")).optional(),
|
|
1409
1685
|
help: ((z.boolean()).describe("Show help")).optional(),
|
|
1410
|
-
version: ((z.boolean()).describe("Show version number")).optional()
|
|
1686
|
+
version: ((z.boolean()).describe("Show version number")).optional(),
|
|
1687
|
+
watch: ((z.boolean()).describe("Watch files in bundle and rebuild on changes")).optional()
|
|
1411
1688
|
})).merge(inputCliOptionsSchema)).merge(outputCliOptionsSchema);
|
|
1412
1689
|
const schema = zodToJsonSchema(cliOptionsSchema);
|
|
1413
1690
|
|
|
@@ -1416,12 +1693,12 @@ const schema = zodToJsonSchema(cliOptionsSchema);
|
|
|
1416
1693
|
const alias = {
|
|
1417
1694
|
config: {
|
|
1418
1695
|
abbreviation: "c",
|
|
1419
|
-
description: "Use config file",
|
|
1420
1696
|
hint: "filename",
|
|
1421
1697
|
default: "rolldown.config.js"
|
|
1422
1698
|
},
|
|
1423
1699
|
help: {abbreviation: "h"},
|
|
1424
1700
|
version: {abbreviation: "v"},
|
|
1701
|
+
watch: {abbreviation: "w"},
|
|
1425
1702
|
dir: {abbreviation: "d"},
|
|
1426
1703
|
external: {abbreviation: "e"},
|
|
1427
1704
|
format: {abbreviation: "f"},
|
|
@@ -1429,24 +1706,27 @@ const alias = {
|
|
|
1429
1706
|
globals: {abbreviation: "g"},
|
|
1430
1707
|
sourcemap: {
|
|
1431
1708
|
abbreviation: "s",
|
|
1432
|
-
default:
|
|
1709
|
+
default: true
|
|
1433
1710
|
},
|
|
1434
1711
|
minify: {abbreviation: "m"},
|
|
1435
1712
|
platform: {abbreviation: "p"},
|
|
1436
1713
|
assetFileNames: {hint: "name"},
|
|
1437
1714
|
chunkFileNames: {hint: "name"},
|
|
1438
1715
|
entryFileNames: {hint: "name"},
|
|
1439
|
-
externalLiveBindings: {
|
|
1440
|
-
|
|
1716
|
+
externalLiveBindings: {
|
|
1717
|
+
default: true,
|
|
1718
|
+
reverse: true
|
|
1719
|
+
},
|
|
1720
|
+
treeshake: {
|
|
1721
|
+
default: true,
|
|
1722
|
+
reverse: true
|
|
1723
|
+
},
|
|
1441
1724
|
moduleTypes: {hint: "types"}
|
|
1442
1725
|
};
|
|
1443
1726
|
|
|
1444
1727
|
//#endregion
|
|
1445
1728
|
//#region src/cli/arguments/utils.ts
|
|
1446
1729
|
function getSchemaType(schema$1) {
|
|
1447
|
-
if ("type"in schema$1) {
|
|
1448
|
-
return schema$1.type;
|
|
1449
|
-
}
|
|
1450
1730
|
if ("anyOf"in schema$1) {
|
|
1451
1731
|
const types = schema$1.anyOf.map((s) => getSchemaType(s));
|
|
1452
1732
|
if (types.includes("object")) return "object";
|
|
@@ -1455,6 +1735,9 @@ else if (types.includes("string")) return "string";
|
|
|
1455
1735
|
else if (types.includes("number")) return "number";
|
|
1456
1736
|
else if (types.includes("boolean")) return "boolean";
|
|
1457
1737
|
}
|
|
1738
|
+
if ("type"in schema$1) {
|
|
1739
|
+
return schema$1.type;
|
|
1740
|
+
}
|
|
1458
1741
|
return "object";
|
|
1459
1742
|
}
|
|
1460
1743
|
function flattenSchema(schema$1, base = {}, parent = "") {
|
|
@@ -1472,8 +1755,8 @@ function flattenSchema(schema$1, base = {}, parent = "") {
|
|
|
1472
1755
|
}
|
|
1473
1756
|
return base;
|
|
1474
1757
|
}
|
|
1475
|
-
function setNestedProperty(obj, path, value) {
|
|
1476
|
-
const keys = path.split(".");
|
|
1758
|
+
function setNestedProperty(obj, path$1, value) {
|
|
1759
|
+
const keys = path$1.split(".");
|
|
1477
1760
|
let current = obj;
|
|
1478
1761
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
1479
1762
|
if (!current[keys[i]]) {
|
|
@@ -1503,7 +1786,7 @@ function normalizeCliOptions(cliOptions, positionals) {
|
|
|
1503
1786
|
const options$1 = parsed.data ?? {};
|
|
1504
1787
|
if (!parsed.success) {
|
|
1505
1788
|
parsed.error.errors.forEach((error) => {
|
|
1506
|
-
logger.error(`Invalid value for option
|
|
1789
|
+
logger.error(`Invalid value for option ${error.path.join(", ")}. You can use \`rolldown -h\` to see the help.`);
|
|
1507
1790
|
});
|
|
1508
1791
|
process.exit(1);
|
|
1509
1792
|
}
|
|
@@ -1511,12 +1794,13 @@ function normalizeCliOptions(cliOptions, positionals) {
|
|
|
1511
1794
|
input: {},
|
|
1512
1795
|
output: {},
|
|
1513
1796
|
help: options$1.help ?? false,
|
|
1514
|
-
version: options$1.version ?? false
|
|
1797
|
+
version: options$1.version ?? false,
|
|
1798
|
+
watch: options$1.watch ?? false
|
|
1515
1799
|
};
|
|
1516
1800
|
if (typeof options$1.config === "string") {
|
|
1517
1801
|
result.config = options$1.config ? options$1.config : "rolldown.config.js";
|
|
1518
1802
|
}
|
|
1519
|
-
const reservedKeys = ["help", "version", "config"];
|
|
1803
|
+
const reservedKeys = ["help", "version", "config", "watch"];
|
|
1520
1804
|
const keysOfInput = (inputCliOptionsSchema.keyof())._def.values;
|
|
1521
1805
|
const keysOfOutput = (outputCliOptionsSchema.keyof())._def.values;
|
|
1522
1806
|
for (let [key, value] of Object.entries(options$1)) {
|
|
@@ -1551,8 +1835,15 @@ const options = Object.fromEntries((Object.entries(flattenedSchema)).map(([key,
|
|
|
1551
1835
|
if (config && config?.abbreviation) {
|
|
1552
1836
|
result.short = config?.abbreviation;
|
|
1553
1837
|
}
|
|
1838
|
+
if (config && config.reverse) {
|
|
1839
|
+
if (result.description.startsWith("enable")) {
|
|
1840
|
+
result.description = result.description.replace("enable", "disable");
|
|
1841
|
+
} else {
|
|
1842
|
+
result.description = `disable ${result.description}`;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1554
1845
|
key = camelCaseToKebabCase(key);
|
|
1555
|
-
return [
|
|
1846
|
+
return [config?.reverse ? `no-${key}` : key, result];
|
|
1556
1847
|
}));
|
|
1557
1848
|
function parseCliArguments() {
|
|
1558
1849
|
const { values: values, tokens: tokens, positionals: positionals } = parseArgs({
|
|
@@ -1575,12 +1866,21 @@ function parseCliArguments() {
|
|
|
1575
1866
|
option.name = kebabCaseToCamelCase(option.name);
|
|
1576
1867
|
let originalType = flattenedSchema[option.name];
|
|
1577
1868
|
if (!originalType) {
|
|
1578
|
-
logger.
|
|
1579
|
-
|
|
1869
|
+
logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
|
|
1870
|
+
process.exit(1);
|
|
1580
1871
|
}
|
|
1581
1872
|
let type = getSchemaType(originalType);
|
|
1582
|
-
if (type === "
|
|
1583
|
-
|
|
1873
|
+
if (type === "string" && typeof option.value !== "string") {
|
|
1874
|
+
let opt = option;
|
|
1875
|
+
let defaultValue = (Object.getOwnPropertyDescriptor(alias, opt.name))?.value;
|
|
1876
|
+
Object.defineProperty(values, opt.name, {
|
|
1877
|
+
value: defaultValue.default ?? "",
|
|
1878
|
+
enumerable: true,
|
|
1879
|
+
configurable: true,
|
|
1880
|
+
writable: true
|
|
1881
|
+
});
|
|
1882
|
+
} else if (type === "object" && typeof option.value === "string") {
|
|
1883
|
+
const [key, value] = ((option.value.split(",")).map((x) => x.split("=")))[0];
|
|
1584
1884
|
if (!values[option.name]) {
|
|
1585
1885
|
Object.defineProperty(values, option.name, {
|
|
1586
1886
|
value: {},
|
|
@@ -1666,15 +1966,8 @@ function showHelp() {
|
|
|
1666
1966
|
}
|
|
1667
1967
|
return a.localeCompare(b);
|
|
1668
1968
|
})).map(([option, { type: type, short: short, hint: hint, description: description$1 }]) => {
|
|
1669
|
-
let optionStr =
|
|
1670
|
-
const config = (Object.getOwnPropertyDescriptor(alias, option) ?? {}).value ?? {};
|
|
1969
|
+
let optionStr = ` --${option} `;
|
|
1671
1970
|
option = camelCaseToKebabCase(option);
|
|
1672
|
-
if (typeof config.default === "boolean" && type === "boolean" && config.default) {
|
|
1673
|
-
optionStr += `--no-${option}`;
|
|
1674
|
-
description$1 = `Do not ${description$1}`;
|
|
1675
|
-
} else {
|
|
1676
|
-
optionStr += `--${option} `;
|
|
1677
|
-
}
|
|
1678
1971
|
if (short) {
|
|
1679
1972
|
optionStr += `-${short}, `;
|
|
1680
1973
|
}
|