rolldown 1.0.0-beta.35 → 1.0.0-beta.37
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.mjs +95 -1068
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +3 -3
- package/dist/experimental-index.d.mts +43 -5
- package/dist/experimental-index.mjs +31 -8
- package/dist/filter-index.d.mts +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/parallel-plugin-worker.mjs +3 -4
- 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-9k0egz6L.d.mts → binding-Cjs27cfu.d.mts} +1 -0
- package/dist/shared/{define-config-DhrkZ_o7.d.cts → define-config-CV3aiNwN.d.mts} +9 -9
- package/dist/shared/{load-config-C93_L4MP.mjs → load-config-BOVuTpJm.mjs} +4 -6
- package/dist/{cli.cjs → shared/logger-CiCY7ucm.mjs} +44 -829
- package/dist/shared/parse-ast-index-B5HcAOhq.mjs +10847 -0
- package/dist/shared/{prompt-C5jz26Zn.mjs → prompt-D2FxOcB5.mjs} +4 -7
- package/dist/shared/{src-D954P1TH.mjs → src-BtNlw_84.mjs} +88 -69
- package/package.json +32 -46
- package/dist/cli.d.cts +0 -1
- package/dist/config.cjs +0 -12
- package/dist/config.d.cts +0 -10
- package/dist/experimental-index.cjs +0 -154
- package/dist/experimental-index.d.cts +0 -99
- package/dist/filter-index.cjs +0 -106
- package/dist/filter-index.d.cts +0 -4
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +0 -3
- package/dist/parallel-plugin-worker.cjs +0 -33
- package/dist/parallel-plugin-worker.d.cts +0 -1
- package/dist/parallel-plugin.cjs +0 -8
- package/dist/parallel-plugin.d.cts +0 -14
- package/dist/parse-ast-index.cjs +0 -4
- package/dist/parse-ast-index.d.cts +0 -8
- package/dist/shared/binding-D13M6Llu.d.cts +0 -1425
- package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
- package/dist/shared/define-config-3arq8OPE.d.mts +0 -1421
- package/dist/shared/load-config-S_ofSLrj.cjs +0 -130
- package/dist/shared/misc-DksvspN4.cjs +0 -58
- package/dist/shared/parse-ast-index-BadydpMA.mjs +0 -725
- package/dist/shared/parse-ast-index-cePJvlvW.cjs +0 -871
- package/dist/shared/prompt-Q05EYrFb.cjs +0 -858
- package/dist/shared/src-BBMxhaqf.cjs +0 -4673
|
@@ -1,222 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const require_load_config = require('./shared/load-config-S_ofSLrj.cjs');
|
|
6
|
-
let node_path = require("node:path");
|
|
7
|
-
node_path = require_chunk.__toESM(node_path);
|
|
8
|
-
let ansis = require("ansis");
|
|
9
|
-
ansis = require_chunk.__toESM(ansis);
|
|
10
|
-
let node_process = require("node:process");
|
|
11
|
-
node_process = require_chunk.__toESM(node_process);
|
|
12
|
-
let node_util = require("node:util");
|
|
13
|
-
node_util = require_chunk.__toESM(node_util);
|
|
14
|
-
let node_tty = require("node:tty");
|
|
15
|
-
node_tty = require_chunk.__toESM(node_tty);
|
|
16
|
-
let node_perf_hooks = require("node:perf_hooks");
|
|
17
|
-
node_perf_hooks = require_chunk.__toESM(node_perf_hooks);
|
|
1
|
+
import { sep } from "node:path";
|
|
2
|
+
import { formatWithOptions } from "node:util";
|
|
3
|
+
import process$1 from "node:process";
|
|
4
|
+
import * as tty from "node:tty";
|
|
18
5
|
|
|
19
|
-
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
20
|
-
/**
|
|
21
|
-
* This is not the set of all possible signals.
|
|
22
|
-
*
|
|
23
|
-
* It IS, however, the set of all signals that trigger
|
|
24
|
-
* an exit on either Linux or BSD systems. Linux is a
|
|
25
|
-
* superset of the signal names supported on BSD, and
|
|
26
|
-
* the unknown signals just fail to register, so we can
|
|
27
|
-
* catch that easily enough.
|
|
28
|
-
*
|
|
29
|
-
* Windows signals are a different set, since there are
|
|
30
|
-
* signals that terminate Windows processes, but don't
|
|
31
|
-
* terminate (or don't even exist) on Posix systems.
|
|
32
|
-
*
|
|
33
|
-
* Don't bother with SIGKILL. It's uncatchable, which
|
|
34
|
-
* means that we can't fire any callbacks anyway.
|
|
35
|
-
*
|
|
36
|
-
* If a user does happen to register a handler on a non-
|
|
37
|
-
* fatal signal like SIGWINCH or something, and then
|
|
38
|
-
* exit, it'll end up firing `process.emit('exit')`, so
|
|
39
|
-
* the handler will be fired anyway.
|
|
40
|
-
*
|
|
41
|
-
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
42
|
-
* artificially, inherently leave the process in a
|
|
43
|
-
* state from which it is not safe to try and enter JS
|
|
44
|
-
* listeners.
|
|
45
|
-
*/
|
|
46
|
-
const signals = [];
|
|
47
|
-
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
48
|
-
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
49
|
-
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
53
|
-
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";
|
|
54
|
-
const kExitEmitter = Symbol.for("signal-exit emitter");
|
|
55
|
-
const global = globalThis;
|
|
56
|
-
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
57
|
-
var Emitter = class {
|
|
58
|
-
emitted = {
|
|
59
|
-
afterExit: false,
|
|
60
|
-
exit: false
|
|
61
|
-
};
|
|
62
|
-
listeners = {
|
|
63
|
-
afterExit: [],
|
|
64
|
-
exit: []
|
|
65
|
-
};
|
|
66
|
-
count = 0;
|
|
67
|
-
id = Math.random();
|
|
68
|
-
constructor() {
|
|
69
|
-
if (global[kExitEmitter]) return global[kExitEmitter];
|
|
70
|
-
ObjectDefineProperty(global, kExitEmitter, {
|
|
71
|
-
value: this,
|
|
72
|
-
writable: false,
|
|
73
|
-
enumerable: false,
|
|
74
|
-
configurable: false
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
on(ev, fn) {
|
|
78
|
-
this.listeners[ev].push(fn);
|
|
79
|
-
}
|
|
80
|
-
removeListener(ev, fn) {
|
|
81
|
-
const list = this.listeners[ev];
|
|
82
|
-
const i$1 = list.indexOf(fn);
|
|
83
|
-
/* c8 ignore start */
|
|
84
|
-
if (i$1 === -1) return;
|
|
85
|
-
/* c8 ignore stop */
|
|
86
|
-
if (i$1 === 0 && list.length === 1) list.length = 0;
|
|
87
|
-
else list.splice(i$1, 1);
|
|
88
|
-
}
|
|
89
|
-
emit(ev, code, signal) {
|
|
90
|
-
if (this.emitted[ev]) return false;
|
|
91
|
-
this.emitted[ev] = true;
|
|
92
|
-
let ret = false;
|
|
93
|
-
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
|
|
94
|
-
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
|
|
95
|
-
return ret;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var SignalExitBase = class {};
|
|
99
|
-
const signalExitWrap = (handler) => {
|
|
100
|
-
return {
|
|
101
|
-
onExit(cb, opts) {
|
|
102
|
-
return handler.onExit(cb, opts);
|
|
103
|
-
},
|
|
104
|
-
load() {
|
|
105
|
-
return handler.load();
|
|
106
|
-
},
|
|
107
|
-
unload() {
|
|
108
|
-
return handler.unload();
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
var SignalExitFallback = class extends SignalExitBase {
|
|
113
|
-
onExit() {
|
|
114
|
-
return () => {};
|
|
115
|
-
}
|
|
116
|
-
load() {}
|
|
117
|
-
unload() {}
|
|
118
|
-
};
|
|
119
|
-
var SignalExit = class extends SignalExitBase {
|
|
120
|
-
/* c8 ignore start */
|
|
121
|
-
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
122
|
-
/* c8 ignore stop */
|
|
123
|
-
#emitter = new Emitter();
|
|
124
|
-
#process;
|
|
125
|
-
#originalProcessEmit;
|
|
126
|
-
#originalProcessReallyExit;
|
|
127
|
-
#sigListeners = {};
|
|
128
|
-
#loaded = false;
|
|
129
|
-
constructor(process$3) {
|
|
130
|
-
super();
|
|
131
|
-
this.#process = process$3;
|
|
132
|
-
this.#sigListeners = {};
|
|
133
|
-
for (const sig of signals) this.#sigListeners[sig] = () => {
|
|
134
|
-
const listeners = this.#process.listeners(sig);
|
|
135
|
-
let { count } = this.#emitter;
|
|
136
|
-
/* c8 ignore start */
|
|
137
|
-
const p = process$3;
|
|
138
|
-
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
|
|
139
|
-
/* c8 ignore stop */
|
|
140
|
-
if (listeners.length === count) {
|
|
141
|
-
this.unload();
|
|
142
|
-
const ret = this.#emitter.emit("exit", null, sig);
|
|
143
|
-
/* c8 ignore start */
|
|
144
|
-
const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
145
|
-
if (!ret) process$3.kill(process$3.pid, s$1);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
this.#originalProcessReallyExit = process$3.reallyExit;
|
|
149
|
-
this.#originalProcessEmit = process$3.emit;
|
|
150
|
-
}
|
|
151
|
-
onExit(cb, opts) {
|
|
152
|
-
/* c8 ignore start */
|
|
153
|
-
if (!processOk(this.#process)) return () => {};
|
|
154
|
-
/* c8 ignore stop */
|
|
155
|
-
if (this.#loaded === false) this.load();
|
|
156
|
-
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
157
|
-
this.#emitter.on(ev, cb);
|
|
158
|
-
return () => {
|
|
159
|
-
this.#emitter.removeListener(ev, cb);
|
|
160
|
-
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
load() {
|
|
164
|
-
if (this.#loaded) return;
|
|
165
|
-
this.#loaded = true;
|
|
166
|
-
this.#emitter.count += 1;
|
|
167
|
-
for (const sig of signals) try {
|
|
168
|
-
const fn = this.#sigListeners[sig];
|
|
169
|
-
if (fn) this.#process.on(sig, fn);
|
|
170
|
-
} catch (_$1) {}
|
|
171
|
-
this.#process.emit = (ev, ...a$1) => {
|
|
172
|
-
return this.#processEmit(ev, ...a$1);
|
|
173
|
-
};
|
|
174
|
-
this.#process.reallyExit = (code) => {
|
|
175
|
-
return this.#processReallyExit(code);
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
unload() {
|
|
179
|
-
if (!this.#loaded) return;
|
|
180
|
-
this.#loaded = false;
|
|
181
|
-
signals.forEach((sig) => {
|
|
182
|
-
const listener = this.#sigListeners[sig];
|
|
183
|
-
/* c8 ignore start */
|
|
184
|
-
if (!listener) throw new Error("Listener not defined for signal: " + sig);
|
|
185
|
-
/* c8 ignore stop */
|
|
186
|
-
try {
|
|
187
|
-
this.#process.removeListener(sig, listener);
|
|
188
|
-
} catch (_$1) {}
|
|
189
|
-
/* c8 ignore stop */
|
|
190
|
-
});
|
|
191
|
-
this.#process.emit = this.#originalProcessEmit;
|
|
192
|
-
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
193
|
-
this.#emitter.count -= 1;
|
|
194
|
-
}
|
|
195
|
-
#processReallyExit(code) {
|
|
196
|
-
/* c8 ignore start */
|
|
197
|
-
if (!processOk(this.#process)) return 0;
|
|
198
|
-
this.#process.exitCode = code || 0;
|
|
199
|
-
/* c8 ignore stop */
|
|
200
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
201
|
-
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
202
|
-
}
|
|
203
|
-
#processEmit(ev, ...args) {
|
|
204
|
-
const og = this.#originalProcessEmit;
|
|
205
|
-
if (ev === "exit" && processOk(this.#process)) {
|
|
206
|
-
if (typeof args[0] === "number") this.#process.exitCode = args[0];
|
|
207
|
-
/* c8 ignore start */
|
|
208
|
-
const ret = og.call(this.#process, ev, ...args);
|
|
209
|
-
/* c8 ignore start */
|
|
210
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
211
|
-
/* c8 ignore stop */
|
|
212
|
-
return ret;
|
|
213
|
-
} else return og.call(this.#process, ev, ...args);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
const process$2 = globalThis.process;
|
|
217
|
-
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
218
|
-
|
|
219
|
-
//#endregion
|
|
220
6
|
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
|
|
221
7
|
const LogLevels = {
|
|
222
8
|
silent: Number.NEGATIVE_INFINITY,
|
|
@@ -296,13 +82,13 @@ var Consola = class Consola {
|
|
|
296
82
|
*
|
|
297
83
|
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
298
84
|
*/
|
|
299
|
-
constructor(options
|
|
300
|
-
const types = options
|
|
85
|
+
constructor(options = {}) {
|
|
86
|
+
const types = options.types || LogTypes;
|
|
301
87
|
this.options = defu({
|
|
302
|
-
...options
|
|
303
|
-
defaults: { ...options
|
|
304
|
-
level: _normalizeLogLevel(options
|
|
305
|
-
reporters: [...options
|
|
88
|
+
...options,
|
|
89
|
+
defaults: { ...options.defaults },
|
|
90
|
+
level: _normalizeLogLevel(options.level, types),
|
|
91
|
+
reporters: [...options.reporters || []]
|
|
306
92
|
}, {
|
|
307
93
|
types: LogTypes,
|
|
308
94
|
throttle: 1e3,
|
|
@@ -360,10 +146,10 @@ var Consola = class Consola {
|
|
|
360
146
|
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
361
147
|
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
362
148
|
*/
|
|
363
|
-
create(options
|
|
149
|
+
create(options) {
|
|
364
150
|
const instance = new Consola({
|
|
365
151
|
...this.options,
|
|
366
|
-
...options
|
|
152
|
+
...options
|
|
367
153
|
});
|
|
368
154
|
if (this._mockFn) instance.mockTypes(this._mockFn);
|
|
369
155
|
return instance;
|
|
@@ -598,20 +384,18 @@ Consola.prototype.withScope = Consola.prototype.withTag;
|
|
|
598
384
|
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
599
385
|
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
600
386
|
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
601
|
-
function createConsola$1(options
|
|
602
|
-
return new Consola(options
|
|
387
|
+
function createConsola$1(options = {}) {
|
|
388
|
+
return new Consola(options);
|
|
603
389
|
}
|
|
604
390
|
|
|
605
391
|
//#endregion
|
|
606
392
|
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
|
|
607
393
|
function parseStack(stack, message) {
|
|
608
|
-
const cwd = process.cwd() +
|
|
609
|
-
|
|
610
|
-
return lines;
|
|
394
|
+
const cwd$1 = process.cwd() + sep;
|
|
395
|
+
return stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd$1, ""));
|
|
611
396
|
}
|
|
612
397
|
function writeStream(data, stream) {
|
|
613
|
-
|
|
614
|
-
return write.call(stream, data);
|
|
398
|
+
return (stream.__write || stream.write).call(stream, data);
|
|
615
399
|
}
|
|
616
400
|
const bracket = (x) => x ? `[${x}]` : "";
|
|
617
401
|
var BasicReporter = class {
|
|
@@ -621,7 +405,7 @@ var BasicReporter = class {
|
|
|
621
405
|
${indent}`);
|
|
622
406
|
}
|
|
623
407
|
formatError(err, opts) {
|
|
624
|
-
const message = err.message ??
|
|
408
|
+
const message = err.message ?? formatWithOptions(opts, err);
|
|
625
409
|
const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
|
|
626
410
|
const level = opts?.errorLevel || 0;
|
|
627
411
|
const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
|
|
@@ -636,7 +420,7 @@ ${indent}`);
|
|
|
636
420
|
if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
|
|
637
421
|
return arg;
|
|
638
422
|
});
|
|
639
|
-
return
|
|
423
|
+
return formatWithOptions(opts, ..._args);
|
|
640
424
|
}
|
|
641
425
|
formatDate(date, opts) {
|
|
642
426
|
return opts.date ? date.toLocaleTimeString() : "";
|
|
@@ -673,7 +457,7 @@ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
|
673
457
|
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
674
458
|
const isWindows = platform === "win32";
|
|
675
459
|
const isDumbTerminal = env.TERM === "dumb";
|
|
676
|
-
const isCompatibleTerminal =
|
|
460
|
+
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
677
461
|
const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
678
462
|
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
679
463
|
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
|
@@ -734,9 +518,9 @@ const colorDefs = {
|
|
|
734
518
|
function createColors(useColor = isColorSupported) {
|
|
735
519
|
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
736
520
|
}
|
|
737
|
-
const colors
|
|
521
|
+
const colors = createColors();
|
|
738
522
|
function getColor$1(color, fallback = "reset") {
|
|
739
|
-
return colors
|
|
523
|
+
return colors[color] || colors[fallback];
|
|
740
524
|
}
|
|
741
525
|
const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
|
|
742
526
|
function stripAnsi(text) {
|
|
@@ -857,7 +641,7 @@ function box(text, _opts = {}) {
|
|
|
857
641
|
|
|
858
642
|
//#endregion
|
|
859
643
|
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
860
|
-
const r = Object.create(null), i = (e) => globalThis.process?.env ||
|
|
644
|
+
const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
|
|
861
645
|
get(e, s$1) {
|
|
862
646
|
return i()[s$1] ?? r[s$1];
|
|
863
647
|
},
|
|
@@ -1015,11 +799,9 @@ function G() {
|
|
|
1015
799
|
const e = F.find((s$1) => s$1[0]);
|
|
1016
800
|
if (e) return { name: e[1] };
|
|
1017
801
|
}
|
|
1018
|
-
|
|
1019
|
-
P?.name;
|
|
802
|
+
G()?.name;
|
|
1020
803
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1021
|
-
const
|
|
1022
|
-
const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
804
|
+
const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
1023
805
|
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
1024
806
|
}
|
|
1025
807
|
const regex = ansiRegex();
|
|
@@ -1049,9 +831,9 @@ const emojiRegex = () => {
|
|
|
1049
831
|
};
|
|
1050
832
|
const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
|
|
1051
833
|
const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
1052
|
-
function stringWidth$1(string, options
|
|
834
|
+
function stringWidth$1(string, options = {}) {
|
|
1053
835
|
if (typeof string !== "string" || string.length === 0) return 0;
|
|
1054
|
-
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options
|
|
836
|
+
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
|
|
1055
837
|
if (!countAnsiEscapeCodes) string = stripAnsi$1(string);
|
|
1056
838
|
if (string.length === 0) return 0;
|
|
1057
839
|
let width = 0;
|
|
@@ -1073,9 +855,9 @@ function stringWidth$1(string, options$1 = {}) {
|
|
|
1073
855
|
return width;
|
|
1074
856
|
}
|
|
1075
857
|
function isUnicodeSupported() {
|
|
1076
|
-
const { env: env$1 } =
|
|
858
|
+
const { env: env$1 } = process$1;
|
|
1077
859
|
const { TERM, TERM_PROGRAM } = env$1;
|
|
1078
|
-
if (
|
|
860
|
+
if (process$1.platform !== "win32") return TERM !== "linux";
|
|
1079
861
|
return Boolean(env$1.WT_SESSION) || Boolean(env$1.TERMINUS_SUBLIME) || env$1.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env$1.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1080
862
|
}
|
|
1081
863
|
const TYPE_COLOR_MAP = {
|
|
@@ -1105,20 +887,19 @@ const TYPE_ICONS = {
|
|
|
1105
887
|
log: ""
|
|
1106
888
|
};
|
|
1107
889
|
function stringWidth(str) {
|
|
1108
|
-
|
|
1109
|
-
if (!hasICU || !Intl.Segmenter) return stripAnsi(str).length;
|
|
890
|
+
if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi(str).length;
|
|
1110
891
|
return stringWidth$1(str);
|
|
1111
892
|
}
|
|
1112
893
|
var FancyReporter = class extends BasicReporter {
|
|
1113
894
|
formatStack(stack, message, opts) {
|
|
1114
895
|
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
1115
896
|
return `
|
|
1116
|
-
${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors
|
|
897
|
+
${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_$1, m) => `(${colors.cyan(m)})`)).join(`
|
|
1117
898
|
${indent}`);
|
|
1118
899
|
}
|
|
1119
900
|
formatType(logObj, isBadge, opts) {
|
|
1120
901
|
const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
|
|
1121
|
-
if (isBadge) return getBgColor(typeColor)(colors
|
|
902
|
+
if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
|
|
1122
903
|
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
1123
904
|
return _type ? getColor(typeColor)(_type) : "";
|
|
1124
905
|
}
|
|
@@ -1129,15 +910,15 @@ ${indent}`);
|
|
|
1129
910
|
style: logObj.style
|
|
1130
911
|
});
|
|
1131
912
|
const date = this.formatDate(logObj.date, opts);
|
|
1132
|
-
const coloredDate = date && colors
|
|
913
|
+
const coloredDate = date && colors.gray(date);
|
|
1133
914
|
const isBadge = logObj.badge ?? logObj.level < 2;
|
|
1134
915
|
const type = this.formatType(logObj, isBadge, opts);
|
|
1135
|
-
const tag = logObj.tag ? colors
|
|
916
|
+
const tag = logObj.tag ? colors.gray(logObj.tag) : "";
|
|
1136
917
|
let line;
|
|
1137
918
|
const left = this.filterAndJoin([type, characterFormat(message)]);
|
|
1138
919
|
const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
|
|
1139
920
|
const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
|
|
1140
|
-
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors
|
|
921
|
+
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
|
|
1141
922
|
line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
|
|
1142
923
|
if (logObj.type === "trace") {
|
|
1143
924
|
const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
|
|
@@ -1147,27 +928,26 @@ ${indent}`);
|
|
|
1147
928
|
}
|
|
1148
929
|
};
|
|
1149
930
|
function characterFormat(str) {
|
|
1150
|
-
return str.replace(/`([^`]+)`/gm, (_$1, m) => colors
|
|
931
|
+
return str.replace(/`([^`]+)`/gm, (_$1, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_$1, m) => ` ${colors.underline(m)} `);
|
|
1151
932
|
}
|
|
1152
933
|
function getColor(color = "white") {
|
|
1153
|
-
return colors
|
|
934
|
+
return colors[color] || colors.white;
|
|
1154
935
|
}
|
|
1155
936
|
function getBgColor(color = "bgWhite") {
|
|
1156
|
-
return colors
|
|
937
|
+
return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
|
|
1157
938
|
}
|
|
1158
|
-
function createConsola(options
|
|
939
|
+
function createConsola(options = {}) {
|
|
1159
940
|
let level = _getDefaultLogLevel();
|
|
1160
941
|
if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
1161
|
-
|
|
942
|
+
return createConsola$1({
|
|
1162
943
|
level,
|
|
1163
944
|
defaults: { level },
|
|
1164
945
|
stdout: process.stdout,
|
|
1165
946
|
stderr: process.stderr,
|
|
1166
|
-
prompt: (...args) =>
|
|
1167
|
-
reporters: options
|
|
1168
|
-
...options
|
|
947
|
+
prompt: (...args) => import("./prompt-D2FxOcB5.mjs").then((m) => m.prompt(...args)),
|
|
948
|
+
reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
|
|
949
|
+
...options
|
|
1169
950
|
});
|
|
1170
|
-
return consola2;
|
|
1171
951
|
}
|
|
1172
952
|
function _getDefaultLogLevel() {
|
|
1173
953
|
if (g) return LogLevels.debug;
|
|
@@ -1205,569 +985,4 @@ function createTestingLogger() {
|
|
|
1205
985
|
}
|
|
1206
986
|
|
|
1207
987
|
//#endregion
|
|
1208
|
-
|
|
1209
|
-
const alias = {
|
|
1210
|
-
config: {
|
|
1211
|
-
abbreviation: "c",
|
|
1212
|
-
hint: "filename"
|
|
1213
|
-
},
|
|
1214
|
-
help: { abbreviation: "h" },
|
|
1215
|
-
version: { abbreviation: "v" },
|
|
1216
|
-
watch: { abbreviation: "w" },
|
|
1217
|
-
dir: { abbreviation: "d" },
|
|
1218
|
-
file: { abbreviation: "o" },
|
|
1219
|
-
external: { abbreviation: "e" },
|
|
1220
|
-
format: { abbreviation: "f" },
|
|
1221
|
-
name: { abbreviation: "n" },
|
|
1222
|
-
globals: { abbreviation: "g" },
|
|
1223
|
-
sourcemap: {
|
|
1224
|
-
abbreviation: "s",
|
|
1225
|
-
default: true
|
|
1226
|
-
},
|
|
1227
|
-
minify: { abbreviation: "m" },
|
|
1228
|
-
platform: { abbreviation: "p" },
|
|
1229
|
-
assetFileNames: { hint: "name" },
|
|
1230
|
-
chunkFileNames: { hint: "name" },
|
|
1231
|
-
entryFileNames: { hint: "name" },
|
|
1232
|
-
externalLiveBindings: {
|
|
1233
|
-
default: true,
|
|
1234
|
-
reverse: true
|
|
1235
|
-
},
|
|
1236
|
-
treeshake: {
|
|
1237
|
-
default: true,
|
|
1238
|
-
reverse: true
|
|
1239
|
-
},
|
|
1240
|
-
preserveEntrySignatures: {
|
|
1241
|
-
default: "strict",
|
|
1242
|
-
reverse: true
|
|
1243
|
-
},
|
|
1244
|
-
moduleTypes: { hint: "types" }
|
|
1245
|
-
};
|
|
1246
|
-
|
|
1247
|
-
//#endregion
|
|
1248
|
-
//#region src/cli/arguments/utils.ts
|
|
1249
|
-
const priority = [
|
|
1250
|
-
"object",
|
|
1251
|
-
"array",
|
|
1252
|
-
"string",
|
|
1253
|
-
"number",
|
|
1254
|
-
"boolean"
|
|
1255
|
-
];
|
|
1256
|
-
function getSchemaType(schema) {
|
|
1257
|
-
if ("anyOf" in schema) {
|
|
1258
|
-
const types = schema.anyOf.map(getSchemaType);
|
|
1259
|
-
let result = priority.find((type) => types.includes(type));
|
|
1260
|
-
if (result) return result;
|
|
1261
|
-
}
|
|
1262
|
-
if ("type" in schema) return schema.type;
|
|
1263
|
-
if ("const" in schema) return typeof schema.const;
|
|
1264
|
-
return "never";
|
|
1265
|
-
}
|
|
1266
|
-
function flattenSchema(schema, base = {}, parent = "") {
|
|
1267
|
-
if (schema === void 0) return base;
|
|
1268
|
-
for (const [k, value] of Object.entries(schema)) {
|
|
1269
|
-
const key = parent ? `${parent}.${k}` : k;
|
|
1270
|
-
if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
|
|
1271
|
-
else base[key] = value;
|
|
1272
|
-
else base[key] = value;
|
|
1273
|
-
}
|
|
1274
|
-
return base;
|
|
1275
|
-
}
|
|
1276
|
-
function setNestedProperty(obj, path$1, value) {
|
|
1277
|
-
const keys = path$1.split(".");
|
|
1278
|
-
let current = obj;
|
|
1279
|
-
for (let i$1 = 0; i$1 < keys.length - 1; i$1++) {
|
|
1280
|
-
if (!current[keys[i$1]]) current[keys[i$1]] = {};
|
|
1281
|
-
current = current[keys[i$1]];
|
|
1282
|
-
}
|
|
1283
|
-
const finalKey = keys[keys.length - 1];
|
|
1284
|
-
Object.defineProperty(current, finalKey, {
|
|
1285
|
-
value,
|
|
1286
|
-
writable: true,
|
|
1287
|
-
enumerable: true,
|
|
1288
|
-
configurable: true
|
|
1289
|
-
});
|
|
1290
|
-
}
|
|
1291
|
-
function camelCaseToKebabCase(str) {
|
|
1292
|
-
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1293
|
-
}
|
|
1294
|
-
function kebabCaseToCamelCase(str) {
|
|
1295
|
-
return str.replace(/-./g, (match) => match[1].toUpperCase());
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
//#endregion
|
|
1299
|
-
//#region src/cli/arguments/normalize.ts
|
|
1300
|
-
function normalizeCliOptions(cliOptions, positionals) {
|
|
1301
|
-
const [data, errors] = require_src.validateCliOptions(cliOptions);
|
|
1302
|
-
if (errors?.length) {
|
|
1303
|
-
errors.forEach((error) => {
|
|
1304
|
-
logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
|
|
1305
|
-
});
|
|
1306
|
-
process.exit(1);
|
|
1307
|
-
}
|
|
1308
|
-
const options$1 = data ?? {};
|
|
1309
|
-
const result = {
|
|
1310
|
-
input: {},
|
|
1311
|
-
output: {},
|
|
1312
|
-
help: options$1.help ?? false,
|
|
1313
|
-
version: options$1.version ?? false,
|
|
1314
|
-
watch: options$1.watch ?? false
|
|
1315
|
-
};
|
|
1316
|
-
if (typeof options$1.config === "string") result.config = options$1.config;
|
|
1317
|
-
const keysOfInput = require_src.getInputCliKeys();
|
|
1318
|
-
const keysOfOutput = require_src.getOutputCliKeys();
|
|
1319
|
-
const reservedKeys = [
|
|
1320
|
-
"help",
|
|
1321
|
-
"version",
|
|
1322
|
-
"config",
|
|
1323
|
-
"watch"
|
|
1324
|
-
];
|
|
1325
|
-
for (let [key, value] of Object.entries(options$1)) {
|
|
1326
|
-
const keys = key.split(".");
|
|
1327
|
-
const [primary] = keys;
|
|
1328
|
-
if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
|
|
1329
|
-
else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
|
|
1330
|
-
else if (!reservedKeys.includes(key)) {
|
|
1331
|
-
logger.error(`Unknown option: ${key}`);
|
|
1332
|
-
process.exit(1);
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
if (!result.config && positionals.length > 0) if (Array.isArray(result.input.input)) result.input.input.push(...positionals);
|
|
1336
|
-
else result.input.input = positionals;
|
|
1337
|
-
return result;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
//#endregion
|
|
1341
|
-
//#region src/cli/arguments/index.ts
|
|
1342
|
-
const objectSchema = require_src.getJsonSchema();
|
|
1343
|
-
const flattenedSchema = flattenSchema(objectSchema.properties);
|
|
1344
|
-
const options = Object.fromEntries(Object.entries(flattenedSchema).filter(([_key, schema]) => getSchemaType(schema) !== "never").map(([key, schema]) => {
|
|
1345
|
-
const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
|
|
1346
|
-
const type = getSchemaType(schema);
|
|
1347
|
-
const result = {
|
|
1348
|
-
type: type === "boolean" ? "boolean" : "string",
|
|
1349
|
-
description: schema?.description ?? config?.description ?? "",
|
|
1350
|
-
hint: config?.hint
|
|
1351
|
-
};
|
|
1352
|
-
if (config && config?.abbreviation) result.short = config?.abbreviation;
|
|
1353
|
-
if (config && config.reverse) {
|
|
1354
|
-
if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
|
|
1355
|
-
else if (!result.description.startsWith("Avoid")) result.description = `disable ${result.description}`;
|
|
1356
|
-
}
|
|
1357
|
-
key = camelCaseToKebabCase(key);
|
|
1358
|
-
return [config?.reverse ? `no-${key}` : key, result];
|
|
1359
|
-
}));
|
|
1360
|
-
function parseCliArguments() {
|
|
1361
|
-
const { values, tokens, positionals } = (0, node_util.parseArgs)({
|
|
1362
|
-
options,
|
|
1363
|
-
tokens: true,
|
|
1364
|
-
allowPositionals: true,
|
|
1365
|
-
strict: false
|
|
1366
|
-
});
|
|
1367
|
-
tokens.filter((token) => token.kind === "option").forEach((option) => {
|
|
1368
|
-
let negative = false;
|
|
1369
|
-
if (option.name.startsWith("no-")) {
|
|
1370
|
-
const name = kebabCaseToCamelCase(option.name.substring(3));
|
|
1371
|
-
if (name in flattenedSchema) {
|
|
1372
|
-
delete values[option.name];
|
|
1373
|
-
option.name = name;
|
|
1374
|
-
negative = true;
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
delete values[option.name];
|
|
1378
|
-
option.name = kebabCaseToCamelCase(option.name);
|
|
1379
|
-
let originalType = flattenedSchema[option.name];
|
|
1380
|
-
if (!originalType) {
|
|
1381
|
-
logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
|
|
1382
|
-
process.exit(1);
|
|
1383
|
-
}
|
|
1384
|
-
let type = getSchemaType(originalType);
|
|
1385
|
-
if (type === "string" && typeof option.value !== "string") {
|
|
1386
|
-
let opt = option;
|
|
1387
|
-
let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
|
|
1388
|
-
Object.defineProperty(values, opt.name, {
|
|
1389
|
-
value: defaultValue.default ?? "",
|
|
1390
|
-
enumerable: true,
|
|
1391
|
-
configurable: true,
|
|
1392
|
-
writable: true
|
|
1393
|
-
});
|
|
1394
|
-
} else if (type === "object" && typeof option.value === "string") {
|
|
1395
|
-
const [key, value] = option.value.split(",").map((x) => x.split("="))[0];
|
|
1396
|
-
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
1397
|
-
value: {},
|
|
1398
|
-
enumerable: true,
|
|
1399
|
-
configurable: true,
|
|
1400
|
-
writable: true
|
|
1401
|
-
});
|
|
1402
|
-
if (key && value) Object.defineProperty(values[option.name], key, {
|
|
1403
|
-
value,
|
|
1404
|
-
enumerable: true,
|
|
1405
|
-
configurable: true,
|
|
1406
|
-
writable: true
|
|
1407
|
-
});
|
|
1408
|
-
} else if (type === "array" && typeof option.value === "string") {
|
|
1409
|
-
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
1410
|
-
value: [],
|
|
1411
|
-
enumerable: true,
|
|
1412
|
-
configurable: true,
|
|
1413
|
-
writable: true
|
|
1414
|
-
});
|
|
1415
|
-
values[option.name].push(option.value);
|
|
1416
|
-
} else if (type === "boolean") Object.defineProperty(values, option.name, {
|
|
1417
|
-
value: !negative,
|
|
1418
|
-
enumerable: true,
|
|
1419
|
-
configurable: true,
|
|
1420
|
-
writable: true
|
|
1421
|
-
});
|
|
1422
|
-
else Object.defineProperty(values, option.name, {
|
|
1423
|
-
value: option.value ?? "",
|
|
1424
|
-
enumerable: true,
|
|
1425
|
-
configurable: true,
|
|
1426
|
-
writable: true
|
|
1427
|
-
});
|
|
1428
|
-
});
|
|
1429
|
-
return normalizeCliOptions(values, positionals);
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
//#endregion
|
|
1433
|
-
//#region src/utils/clear-screen.ts
|
|
1434
|
-
const CLEAR_SCREEN = "\x1Bc";
|
|
1435
|
-
function getClearScreenFunction(options$1) {
|
|
1436
|
-
const isTTY = process.stdout.isTTY;
|
|
1437
|
-
const isAnyOptionNotAllowingClearScreen = require_misc.arraify(options$1).some(({ watch: watch$1 }) => watch$1 === false || watch$1?.clearScreen === false);
|
|
1438
|
-
if (isTTY && !isAnyOptionNotAllowingClearScreen) return () => {
|
|
1439
|
-
process.stdout.write(CLEAR_SCREEN);
|
|
1440
|
-
};
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
//#endregion
|
|
1444
|
-
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.82.3/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
|
|
1445
|
-
var require_usingCtx = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.82.3/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js": ((exports, module) => {
|
|
1446
|
-
function _usingCtx() {
|
|
1447
|
-
var r$1 = "function" == typeof SuppressedError ? SuppressedError : function(r$2, e$1) {
|
|
1448
|
-
var n$2 = Error();
|
|
1449
|
-
return n$2.name = "SuppressedError", n$2.error = r$2, n$2.suppressed = e$1, n$2;
|
|
1450
|
-
}, e = {}, n$1 = [];
|
|
1451
|
-
function using(r$2, e$1) {
|
|
1452
|
-
if (null != e$1) {
|
|
1453
|
-
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
1454
|
-
if (r$2) var o$1 = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
1455
|
-
if (void 0 === o$1 && (o$1 = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$2)) var t$1 = o$1;
|
|
1456
|
-
if ("function" != typeof o$1) throw new TypeError("Object is not disposable.");
|
|
1457
|
-
t$1 && (o$1 = function o$2() {
|
|
1458
|
-
try {
|
|
1459
|
-
t$1.call(e$1);
|
|
1460
|
-
} catch (r$3) {
|
|
1461
|
-
return Promise.reject(r$3);
|
|
1462
|
-
}
|
|
1463
|
-
}), n$1.push({
|
|
1464
|
-
v: e$1,
|
|
1465
|
-
d: o$1,
|
|
1466
|
-
a: r$2
|
|
1467
|
-
});
|
|
1468
|
-
} else r$2 && n$1.push({
|
|
1469
|
-
d: e$1,
|
|
1470
|
-
a: r$2
|
|
1471
|
-
});
|
|
1472
|
-
return e$1;
|
|
1473
|
-
}
|
|
1474
|
-
return {
|
|
1475
|
-
e,
|
|
1476
|
-
u: using.bind(null, !1),
|
|
1477
|
-
a: using.bind(null, !0),
|
|
1478
|
-
d: function d() {
|
|
1479
|
-
var o$1, t$1 = this.e, s$1 = 0;
|
|
1480
|
-
function next() {
|
|
1481
|
-
for (; o$1 = n$1.pop();) try {
|
|
1482
|
-
if (!o$1.a && 1 === s$1) return s$1 = 0, n$1.push(o$1), Promise.resolve().then(next);
|
|
1483
|
-
if (o$1.d) {
|
|
1484
|
-
var r$2 = o$1.d.call(o$1.v);
|
|
1485
|
-
if (o$1.a) return s$1 |= 2, Promise.resolve(r$2).then(next, err);
|
|
1486
|
-
} else s$1 |= 1;
|
|
1487
|
-
} catch (r$3) {
|
|
1488
|
-
return err(r$3);
|
|
1489
|
-
}
|
|
1490
|
-
if (1 === s$1) return t$1 !== e ? Promise.reject(t$1) : Promise.resolve();
|
|
1491
|
-
if (t$1 !== e) throw t$1;
|
|
1492
|
-
}
|
|
1493
|
-
function err(n$2) {
|
|
1494
|
-
return t$1 = t$1 !== e ? new r$1(n$2, t$1) : n$2, next();
|
|
1495
|
-
}
|
|
1496
|
-
return next();
|
|
1497
|
-
}
|
|
1498
|
-
};
|
|
1499
|
-
}
|
|
1500
|
-
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1501
|
-
}) });
|
|
1502
|
-
|
|
1503
|
-
//#endregion
|
|
1504
|
-
//#region src/cli/commands/bundle.ts
|
|
1505
|
-
var import_usingCtx = /* @__PURE__ */ require_chunk.__toESM(require_usingCtx(), 1);
|
|
1506
|
-
async function bundleWithConfig(configPath, cliOptions) {
|
|
1507
|
-
if (cliOptions.watch) {
|
|
1508
|
-
process.env.ROLLUP_WATCH = "true";
|
|
1509
|
-
process.env.ROLLDOWN_WATCH = "true";
|
|
1510
|
-
}
|
|
1511
|
-
const config = await require_load_config.loadConfig(configPath);
|
|
1512
|
-
if (!config) {
|
|
1513
|
-
logger.error(`No configuration found at ${config}`);
|
|
1514
|
-
process.exit(1);
|
|
1515
|
-
}
|
|
1516
|
-
if (cliOptions.watch) await watchInner(config, cliOptions);
|
|
1517
|
-
else await bundleInner(config, cliOptions);
|
|
1518
|
-
}
|
|
1519
|
-
async function bundleWithCliOptions(cliOptions) {
|
|
1520
|
-
try {
|
|
1521
|
-
var _usingCtx$1 = (0, import_usingCtx.default)();
|
|
1522
|
-
if (cliOptions.output.dir || cliOptions.output.file) {
|
|
1523
|
-
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
1524
|
-
await operation({}, cliOptions);
|
|
1525
|
-
return;
|
|
1526
|
-
}
|
|
1527
|
-
if (cliOptions.watch) {
|
|
1528
|
-
logger.error("You must specify `output.dir` to use watch mode");
|
|
1529
|
-
process.exit(1);
|
|
1530
|
-
}
|
|
1531
|
-
const build = _usingCtx$1.a(await require_src.rolldown(cliOptions.input));
|
|
1532
|
-
const { output: outputs } = await build.generate(cliOptions.output);
|
|
1533
|
-
if (outputs.length === 0) {
|
|
1534
|
-
logger.error("No output generated");
|
|
1535
|
-
process.exit(1);
|
|
1536
|
-
}
|
|
1537
|
-
for (const file of outputs) {
|
|
1538
|
-
if (outputs.length > 1) logger.log(`\n${ansis.default.cyan(ansis.default.bold(`|→ ${file.fileName}:`))}\n`);
|
|
1539
|
-
console.log(file.type === "asset" ? file.source : file.code);
|
|
1540
|
-
}
|
|
1541
|
-
} catch (_$1) {
|
|
1542
|
-
_usingCtx$1.e = _$1;
|
|
1543
|
-
} finally {
|
|
1544
|
-
await _usingCtx$1.d();
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
async function watchInner(config, cliOptions) {
|
|
1548
|
-
let normalizedConfig = require_misc.arraify(config).map((option) => {
|
|
1549
|
-
return {
|
|
1550
|
-
...option,
|
|
1551
|
-
...cliOptions.input,
|
|
1552
|
-
output: require_misc.arraify(option.output || {}).map((output) => {
|
|
1553
|
-
return {
|
|
1554
|
-
...output,
|
|
1555
|
-
...cliOptions.output
|
|
1556
|
-
};
|
|
1557
|
-
})
|
|
1558
|
-
};
|
|
1559
|
-
});
|
|
1560
|
-
const watcher = require_src.watch(normalizedConfig);
|
|
1561
|
-
onExit((code) => {
|
|
1562
|
-
Promise.resolve(watcher.close()).finally(() => {
|
|
1563
|
-
process.exit(typeof code === "number" ? code : 0);
|
|
1564
|
-
});
|
|
1565
|
-
return true;
|
|
1566
|
-
});
|
|
1567
|
-
const changedFile = [];
|
|
1568
|
-
watcher.on("change", (id, event) => {
|
|
1569
|
-
if (event.event === "update") changedFile.push(id);
|
|
1570
|
-
});
|
|
1571
|
-
const clearScreen = getClearScreenFunction(normalizedConfig);
|
|
1572
|
-
watcher.on("event", async (event) => {
|
|
1573
|
-
switch (event.code) {
|
|
1574
|
-
case "START":
|
|
1575
|
-
clearScreen?.();
|
|
1576
|
-
break;
|
|
1577
|
-
case "BUNDLE_START":
|
|
1578
|
-
if (changedFile.length > 0) logger.log(`Found ${ansis.default.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
1579
|
-
changedFile.length = 0;
|
|
1580
|
-
break;
|
|
1581
|
-
case "BUNDLE_END":
|
|
1582
|
-
await event.result.close();
|
|
1583
|
-
logger.success(`Rebuilt ${ansis.default.bold(relativeId(event.output[0]))} in ${ansis.default.green(ms(event.duration))}.`);
|
|
1584
|
-
break;
|
|
1585
|
-
case "ERROR":
|
|
1586
|
-
await event.result.close();
|
|
1587
|
-
logger.error(event.error);
|
|
1588
|
-
break;
|
|
1589
|
-
default: break;
|
|
1590
|
-
}
|
|
1591
|
-
});
|
|
1592
|
-
logger.log(`Waiting for changes...`);
|
|
1593
|
-
}
|
|
1594
|
-
async function bundleInner(config, cliOptions) {
|
|
1595
|
-
const startTime = node_perf_hooks.performance.now();
|
|
1596
|
-
const result = [];
|
|
1597
|
-
const configList = require_misc.arraify(config);
|
|
1598
|
-
for (const config$1 of configList) {
|
|
1599
|
-
const outputList = require_misc.arraify(config$1.output || {});
|
|
1600
|
-
const build = await require_src.rolldown({
|
|
1601
|
-
...config$1,
|
|
1602
|
-
...cliOptions.input
|
|
1603
|
-
});
|
|
1604
|
-
for (const output of outputList) try {
|
|
1605
|
-
result.push(await build.write({
|
|
1606
|
-
...output,
|
|
1607
|
-
...cliOptions.output
|
|
1608
|
-
}));
|
|
1609
|
-
} finally {
|
|
1610
|
-
await build.close();
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
result.forEach(printBundleOutputPretty);
|
|
1614
|
-
logger.log(``);
|
|
1615
|
-
const endTime = node_perf_hooks.performance.now();
|
|
1616
|
-
const duration = endTime - startTime;
|
|
1617
|
-
logger.success(`rolldown v${require_src.version} Finished in ${ansis.default.green(ms(duration))}`);
|
|
1618
|
-
}
|
|
1619
|
-
function printBundleOutputPretty(output) {
|
|
1620
|
-
const outputEntries = collectOutputEntries(output.output);
|
|
1621
|
-
const outputLayoutSizes = collectOutputLayoutAdjustmentSizes(outputEntries);
|
|
1622
|
-
printOutputEntries(outputEntries, outputLayoutSizes, "<DIR>");
|
|
1623
|
-
}
|
|
1624
|
-
function collectOutputEntries(output) {
|
|
1625
|
-
return output.map((chunk) => ({
|
|
1626
|
-
type: chunk.type,
|
|
1627
|
-
fileName: chunk.fileName,
|
|
1628
|
-
size: chunk.type === "chunk" ? Buffer.byteLength(chunk.code) : Buffer.byteLength(chunk.source)
|
|
1629
|
-
}));
|
|
1630
|
-
}
|
|
1631
|
-
function collectOutputLayoutAdjustmentSizes(entries) {
|
|
1632
|
-
let longest = 0;
|
|
1633
|
-
let biggestSize = 0;
|
|
1634
|
-
for (const entry of entries) {
|
|
1635
|
-
if (entry.fileName.length > longest) longest = entry.fileName.length;
|
|
1636
|
-
if (entry.size > biggestSize) biggestSize = entry.size;
|
|
1637
|
-
}
|
|
1638
|
-
const sizePad = displaySize(biggestSize).length;
|
|
1639
|
-
return {
|
|
1640
|
-
longest,
|
|
1641
|
-
biggestSize,
|
|
1642
|
-
sizePad
|
|
1643
|
-
};
|
|
1644
|
-
}
|
|
1645
|
-
const numberFormatter = new Intl.NumberFormat("en", {
|
|
1646
|
-
maximumFractionDigits: 2,
|
|
1647
|
-
minimumFractionDigits: 2
|
|
1648
|
-
});
|
|
1649
|
-
function displaySize(bytes) {
|
|
1650
|
-
return `${numberFormatter.format(bytes / 1e3)} kB`;
|
|
1651
|
-
}
|
|
1652
|
-
const CHUNK_GROUPS = [{
|
|
1653
|
-
type: "asset",
|
|
1654
|
-
color: "green"
|
|
1655
|
-
}, {
|
|
1656
|
-
type: "chunk",
|
|
1657
|
-
color: "cyan"
|
|
1658
|
-
}];
|
|
1659
|
-
function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
1660
|
-
for (const group of CHUNK_GROUPS) {
|
|
1661
|
-
const filtered = entries.filter((e) => e.type === group.type);
|
|
1662
|
-
if (!filtered.length) continue;
|
|
1663
|
-
for (const entry of filtered.sort((a$1, z) => a$1.size - z.size)) {
|
|
1664
|
-
let log = ansis.default.dim(withTrailingSlash(distPath));
|
|
1665
|
-
log += ansis.default[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
1666
|
-
log += ansis.default.dim(entry.type);
|
|
1667
|
-
log += ansis.default.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
1668
|
-
logger.log(log);
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
function withTrailingSlash(path$1) {
|
|
1673
|
-
if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
|
|
1674
|
-
return path$1;
|
|
1675
|
-
}
|
|
1676
|
-
function ms(duration) {
|
|
1677
|
-
return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
|
|
1678
|
-
}
|
|
1679
|
-
function relativeId(id) {
|
|
1680
|
-
if (!node_path.default.isAbsolute(id)) return id;
|
|
1681
|
-
return node_path.default.relative(node_path.default.resolve(), id);
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
//#endregion
|
|
1685
|
-
//#region src/cli/commands/help.ts
|
|
1686
|
-
const introduction = `${ansis.default.gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
1687
|
-
|
|
1688
|
-
${ansis.default.bold(ansis.default.underline("USAGE"))} ${ansis.default.cyan("rolldown -c <config>")} or ${ansis.default.cyan("rolldown <input> <options>")}`;
|
|
1689
|
-
const examples = [
|
|
1690
|
-
{
|
|
1691
|
-
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
1692
|
-
command: "rolldown -c rolldown.config.mjs"
|
|
1693
|
-
},
|
|
1694
|
-
{
|
|
1695
|
-
title: "Bundle the `src/main.ts` to `dist` with `cjs` format",
|
|
1696
|
-
command: "rolldown src/main.ts -d dist -f cjs"
|
|
1697
|
-
},
|
|
1698
|
-
{
|
|
1699
|
-
title: "Bundle the `src/main.ts` and handle the `.png` assets to Data URL",
|
|
1700
|
-
command: "rolldown src/main.ts -d dist --moduleTypes .png=dataurl"
|
|
1701
|
-
},
|
|
1702
|
-
{
|
|
1703
|
-
title: "Bundle the `src/main.tsx` and minify the output with sourcemap",
|
|
1704
|
-
command: "rolldown src/main.tsx -d dist -m -s"
|
|
1705
|
-
},
|
|
1706
|
-
{
|
|
1707
|
-
title: "Create self-executing IIFE using external jQuery as `$` and `_`",
|
|
1708
|
-
command: "rolldown src/main.ts -d dist -n bundle -f iife -e jQuery,window._ -g jQuery=$"
|
|
1709
|
-
}
|
|
1710
|
-
];
|
|
1711
|
-
const notes = [
|
|
1712
|
-
"Due to the API limitation, you need to pass `-s` for `.map` sourcemap file as the last argument.",
|
|
1713
|
-
"If you are using the configuration, please pass the `-c` as the last argument if you ignore the default configuration file.",
|
|
1714
|
-
"CLI options will override the configuration file.",
|
|
1715
|
-
"For more information, please visit https://rolldown.rs/."
|
|
1716
|
-
];
|
|
1717
|
-
function showHelp() {
|
|
1718
|
-
logger.log(introduction);
|
|
1719
|
-
logger.log("");
|
|
1720
|
-
logger.log(`${ansis.default.bold(ansis.default.underline("OPTIONS"))}`);
|
|
1721
|
-
logger.log("");
|
|
1722
|
-
logger.log(Object.entries(options).sort(([a$1], [b$1]) => {
|
|
1723
|
-
if (options[a$1].short && !options[b$1].short) return -1;
|
|
1724
|
-
if (!options[a$1].short && options[b$1].short) return 1;
|
|
1725
|
-
if (options[a$1].short && options[b$1].short) return options[a$1].short.localeCompare(options[b$1].short);
|
|
1726
|
-
return a$1.localeCompare(b$1);
|
|
1727
|
-
}).map(([option, { type, short, hint, description: description$1 }]) => {
|
|
1728
|
-
let optionStr = ` --${option} `;
|
|
1729
|
-
option = camelCaseToKebabCase(option);
|
|
1730
|
-
if (short) optionStr += `-${short}, `;
|
|
1731
|
-
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
1732
|
-
if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
|
|
1733
|
-
return ansis.default.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1734
|
-
}).join("\n"));
|
|
1735
|
-
logger.log("");
|
|
1736
|
-
logger.log(`${ansis.default.bold(ansis.default.underline("EXAMPLES"))}`);
|
|
1737
|
-
logger.log("");
|
|
1738
|
-
examples.forEach(({ title, command }, ord) => {
|
|
1739
|
-
logger.log(` ${ord + 1}. ${title}:`);
|
|
1740
|
-
logger.log(` ${ansis.default.cyan(command)}`);
|
|
1741
|
-
logger.log("");
|
|
1742
|
-
});
|
|
1743
|
-
logger.log(`${ansis.default.bold(ansis.default.underline("NOTES"))}`);
|
|
1744
|
-
logger.log("");
|
|
1745
|
-
notes.forEach((note) => {
|
|
1746
|
-
logger.log(` * ${ansis.default.gray(note)}`);
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
//#endregion
|
|
1751
|
-
//#region src/cli/index.ts
|
|
1752
|
-
async function main() {
|
|
1753
|
-
const cliOptions = parseCliArguments();
|
|
1754
|
-
if (cliOptions.config || cliOptions.config === "") {
|
|
1755
|
-
await bundleWithConfig(cliOptions.config, cliOptions);
|
|
1756
|
-
return;
|
|
1757
|
-
}
|
|
1758
|
-
if ("input" in cliOptions.input) {
|
|
1759
|
-
await bundleWithCliOptions(cliOptions);
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
if (cliOptions.version) {
|
|
1763
|
-
logger.log(`rolldown v${require_src.version}`);
|
|
1764
|
-
return;
|
|
1765
|
-
}
|
|
1766
|
-
showHelp();
|
|
1767
|
-
}
|
|
1768
|
-
main().catch((err) => {
|
|
1769
|
-
logger.error(err);
|
|
1770
|
-
node_process.default.exit(1);
|
|
1771
|
-
});
|
|
1772
|
-
|
|
1773
|
-
//#endregion
|
|
988
|
+
export { logger };
|