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