rolldown 1.0.0-beta.2-commit.2666b23 → 1.0.0-beta.20
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/bin/cli.mjs +2 -0
- package/dist/{cjs/cli.cjs → cli.cjs} +630 -603
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/{esm/cli.mjs → cli.mjs} +605 -575
- package/dist/config.cjs +12 -0
- package/dist/config.d.cts +10 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +10 -0
- package/dist/experimental-index.cjs +107 -0
- package/dist/experimental-index.d.cts +63 -0
- package/dist/experimental-index.d.mts +63 -0
- package/dist/experimental-index.mjs +82 -0
- package/dist/experimental-runtime-types.d.ts +52 -0
- package/dist/filter-index.cjs +105 -0
- package/dist/filter-index.d.cts +4 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +44 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -0
- package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -14
- package/dist/parallel-plugin-worker.d.cts +1 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -12
- package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
- package/dist/parallel-plugin.d.cts +14 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
- package/dist/parse-ast-index.cjs +4 -0
- package/dist/parse-ast-index.d.cts +9 -0
- package/dist/parse-ast-index.d.mts +9 -0
- package/dist/parse-ast-index.mjs +3 -0
- package/dist/shared/binding-5O9lFYtz.d.mts +1215 -0
- package/dist/shared/binding-BvKFOCZr.d.cts +1215 -0
- package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
- package/dist/shared/define-config-BOD4oRSZ.d.cts +1204 -0
- package/dist/shared/define-config-DdVYel_V.d.mts +1204 -0
- package/dist/shared/load-config-B_hPIyxu.mjs +119 -0
- package/dist/shared/load-config-BdY850xq.cjs +125 -0
- package/dist/shared/misc-BKp5iIef.cjs +67 -0
- package/dist/shared/misc-BN0nse6C.mjs +25 -0
- package/dist/shared/parse-ast-index-CVVmsBjK.cjs +738 -0
- package/dist/shared/parse-ast-index-DW8kbzjr.mjs +616 -0
- package/dist/shared/{prompt-Nfm4Xz36.mjs → prompt-C5jz26Zn.mjs} +247 -246
- package/dist/shared/{prompt-B7tq3GL9.cjs → prompt-QNI93ne7.cjs} +250 -250
- package/dist/shared/src-CZ0tgOug.cjs +4851 -0
- package/dist/shared/src-DHXNdTPA.mjs +4647 -0
- package/package.json +63 -67
- package/bin/cli.js +0 -2
- package/dist/cjs/experimental-index.cjs +0 -79
- package/dist/cjs/index.cjs +0 -8
- package/dist/cjs/parse-ast-index.cjs +0 -57
- package/dist/esm/experimental-index.mjs +0 -56
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/parse-ast-index.mjs +0 -55
- package/dist/shared/binding-l7VLSKnB.mjs +0 -610
- package/dist/shared/binding-orkvONpS.cjs +0 -661
- package/dist/shared/src-BC6S-BmL.cjs +0 -2828
- package/dist/shared/src-mupmacNC.mjs +0 -2647
- package/dist/types/api/build.d.ts +0 -18
- package/dist/types/api/build.js +0 -22
- package/dist/types/api/experimental.d.ts +0 -7
- package/dist/types/api/experimental.js +0 -13
- package/dist/types/api/rolldown/index.d.ts +0 -3
- package/dist/types/api/rolldown/index.js +0 -7
- package/dist/types/api/rolldown/rolldown-build.d.ts +0 -12
- package/dist/types/api/rolldown/rolldown-build.js +0 -43
- package/dist/types/api/watch/index.d.ts +0 -3
- package/dist/types/api/watch/index.js +0 -8
- package/dist/types/api/watch/watch-emitter.d.ts +0 -31
- package/dist/types/api/watch/watch-emitter.js +0 -69
- package/dist/types/api/watch/watcher.d.ts +0 -13
- package/dist/types/api/watch/watcher.js +0 -66
- package/dist/types/binding.d.ts +0 -1327
- package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
- package/dist/types/builtin-plugin/alias-plugin.js +0 -4
- package/dist/types/builtin-plugin/constructors.d.ts +0 -20
- package/dist/types/builtin-plugin/constructors.js +0 -68
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
- package/dist/types/builtin-plugin/replace-plugin.js +0 -29
- package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
- package/dist/types/builtin-plugin/transform-plugin.js +0 -16
- package/dist/types/builtin-plugin/utils.d.ts +0 -8
- package/dist/types/builtin-plugin/utils.js +0 -19
- package/dist/types/cli/arguments/alias.d.ts +0 -16
- package/dist/types/cli/arguments/alias.js +0 -63
- package/dist/types/cli/arguments/index.d.ts +0 -15
- package/dist/types/cli/arguments/index.js +0 -127
- package/dist/types/cli/arguments/normalize.d.ts +0 -12
- package/dist/types/cli/arguments/normalize.js +0 -48
- package/dist/types/cli/arguments/utils.d.ts +0 -8
- package/dist/types/cli/arguments/utils.js +0 -67
- package/dist/types/cli/colors.d.ts +0 -11
- package/dist/types/cli/colors.js +0 -17
- package/dist/types/cli/commands/bundle.d.ts +0 -3
- package/dist/types/cli/commands/bundle.js +0 -203
- package/dist/types/cli/commands/help.d.ts +0 -1
- package/dist/types/cli/commands/help.js +0 -88
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/index.js +0 -27
- package/dist/types/cli/load-config.d.ts +0 -3
- package/dist/types/cli/load-config.js +0 -95
- package/dist/types/cli/logger.d.ts +0 -5
- package/dist/types/cli/logger.js +0 -35
- package/dist/types/constants/plugin-context.d.ts +0 -7
- package/dist/types/constants/plugin-context.js +0 -7
- package/dist/types/constants/plugin.d.ts +0 -45
- package/dist/types/constants/plugin.js +0 -69
- package/dist/types/experimental-index.d.ts +0 -9
- package/dist/types/experimental-index.js +0 -9
- package/dist/types/index.d.ts +0 -28
- package/dist/types/index.js +0 -7
- package/dist/types/log/logHandler.d.ts +0 -4
- package/dist/types/log/logHandler.js +0 -25
- package/dist/types/log/logger.d.ts +0 -6
- package/dist/types/log/logger.js +0 -107
- package/dist/types/log/logging.d.ts +0 -11
- package/dist/types/log/logging.js +0 -11
- package/dist/types/log/logs.d.ts +0 -18
- package/dist/types/log/logs.js +0 -86
- package/dist/types/options/input-options.d.ts +0 -170
- package/dist/types/options/input-options.js +0 -1
- package/dist/types/options/normalized-input-options.d.ts +0 -18
- package/dist/types/options/normalized-input-options.js +0 -21
- package/dist/types/options/normalized-output-options.d.ts +0 -67
- package/dist/types/options/normalized-output-options.js +0 -99
- package/dist/types/options/output-options.d.ts +0 -86
- package/dist/types/options/output-options.js +0 -1
- package/dist/types/options/watch-options.d.ts +0 -5
- package/dist/types/options/watch-options.js +0 -1
- package/dist/types/parallel-plugin-worker.d.ts +0 -1
- package/dist/types/parallel-plugin-worker.js +0 -31
- package/dist/types/parallel-plugin.d.ts +0 -1
- package/dist/types/parallel-plugin.js +0 -1
- package/dist/types/parse-ast-index.d.ts +0 -4
- package/dist/types/parse-ast-index.js +0 -73
- package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
- package/dist/types/plugin/bindingify-build-hooks.js +0 -213
- package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
- package/dist/types/plugin/bindingify-hook-filter.js +0 -39
- package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
- package/dist/types/plugin/bindingify-output-hooks.js +0 -189
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
- package/dist/types/plugin/bindingify-plugin-hook-meta.js +0 -19
- package/dist/types/plugin/bindingify-plugin.d.ts +0 -15
- package/dist/types/plugin/bindingify-plugin.js +0 -124
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
- package/dist/types/plugin/bindingify-watch-hooks.js +0 -29
- package/dist/types/plugin/hook-filter.d.ts +0 -48
- package/dist/types/plugin/hook-filter.js +0 -1
- package/dist/types/plugin/index.d.ts +0 -126
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/minimal-plugin-context.d.ts +0 -15
- package/dist/types/plugin/minimal-plugin-context.js +0 -25
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
- package/dist/types/plugin/parallel-plugin-implementation.js +0 -3
- package/dist/types/plugin/parallel-plugin.d.ts +0 -9
- package/dist/types/plugin/parallel-plugin.js +0 -6
- package/dist/types/plugin/plugin-context-data.d.ts +0 -16
- package/dist/types/plugin/plugin-context-data.js +0 -55
- package/dist/types/plugin/plugin-context.d.ts +0 -52
- package/dist/types/plugin/plugin-context.js +0 -108
- package/dist/types/plugin/plugin-driver.d.ts +0 -8
- package/dist/types/plugin/plugin-driver.js +0 -88
- package/dist/types/plugin/transform-plugin-context.d.ts +0 -17
- package/dist/types/plugin/transform-plugin-context.js +0 -37
- package/dist/types/types/assert.d.ts +0 -13
- package/dist/types/types/assert.js +0 -1
- package/dist/types/types/config-export.d.ts +0 -5
- package/dist/types/types/config-export.js +0 -1
- package/dist/types/types/misc.d.ts +0 -40
- package/dist/types/types/misc.js +0 -1
- package/dist/types/types/module-info.d.ts +0 -15
- package/dist/types/types/module-info.js +0 -1
- package/dist/types/types/module-side-effects.d.ts +0 -10
- package/dist/types/types/module-side-effects.js +0 -1
- package/dist/types/types/output-bundle.d.ts +0 -4
- package/dist/types/types/output-bundle.js +0 -1
- package/dist/types/types/rolldown-options.d.ts +0 -5
- package/dist/types/types/rolldown-options.js +0 -1
- package/dist/types/types/rolldown-output.d.ts +0 -63
- package/dist/types/types/rolldown-output.js +0 -1
- package/dist/types/types/schema.d.ts +0 -33
- package/dist/types/types/schema.js +0 -1
- package/dist/types/types/sourcemap.d.ts +0 -13
- package/dist/types/types/sourcemap.js +0 -16
- package/dist/types/types/utils.d.ts +0 -13
- package/dist/types/types/utils.js +0 -1
- package/dist/types/utils/asset-source.d.ts +0 -4
- package/dist/types/utils/asset-source.js +0 -8
- package/dist/types/utils/async-flatten.d.ts +0 -1
- package/dist/types/utils/async-flatten.js +0 -7
- package/dist/types/utils/bindingify-input-options.d.ts +0 -7
- package/dist/types/utils/bindingify-input-options.js +0 -225
- package/dist/types/utils/bindingify-output-options.d.ts +0 -3
- package/dist/types/utils/bindingify-output-options.js +0 -92
- package/dist/types/utils/code-frame.d.ts +0 -1
- package/dist/types/utils/code-frame.js +0 -46
- package/dist/types/utils/compose-js-plugins.d.ts +0 -2
- package/dist/types/utils/compose-js-plugins.js +0 -400
- package/dist/types/utils/create-bundler-option.d.ts +0 -11
- package/dist/types/utils/create-bundler-option.js +0 -53
- package/dist/types/utils/create-bundler.d.ts +0 -8
- package/dist/types/utils/create-bundler.js +0 -15
- package/dist/types/utils/define-config.d.ts +0 -5
- package/dist/types/utils/define-config.js +0 -3
- package/dist/types/utils/error.d.ts +0 -2
- package/dist/types/utils/error.js +0 -65
- package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
- package/dist/types/utils/initialize-parallel-plugins.js +0 -54
- package/dist/types/utils/misc.d.ts +0 -6
- package/dist/types/utils/misc.js +0 -22
- package/dist/types/utils/normalize-hook.d.ts +0 -7
- package/dist/types/utils/normalize-hook.js +0 -21
- package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
- package/dist/types/utils/normalize-plugin-option.js +0 -35
- package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
- package/dist/types/utils/normalize-string-or-regex.js +0 -14
- package/dist/types/utils/plugin/index.d.ts +0 -2
- package/dist/types/utils/plugin/index.js +0 -7
- package/dist/types/utils/transform-module-info.d.ts +0 -4
- package/dist/types/utils/transform-module-info.js +0 -19
- package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
- package/dist/types/utils/transform-rendered-chunk.js +0 -43
- package/dist/types/utils/transform-rendered-module.d.ts +0 -3
- package/dist/types/utils/transform-rendered-module.js +0 -10
- package/dist/types/utils/transform-side-effects.d.ts +0 -3
- package/dist/types/utils/transform-side-effects.js +0 -16
- package/dist/types/utils/transform-sourcemap.d.ts +0 -3
- package/dist/types/utils/transform-sourcemap.js +0 -29
- package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
- package/dist/types/utils/transform-to-rollup-output.js +0 -165
- package/dist/types/utils/validator.d.ts +0 -7
- package/dist/types/utils/validator.js +0 -275
|
@@ -1,189 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
const require_chunk = require('./shared/chunk-DDkG_k5U.cjs');
|
|
2
|
+
const require_src = require('./shared/src-CZ0tgOug.cjs');
|
|
3
|
+
require('./shared/parse-ast-index-CVVmsBjK.cjs');
|
|
4
|
+
const require_misc = require('./shared/misc-BKp5iIef.cjs');
|
|
5
|
+
const require_load_config = require('./shared/load-config-BdY850xq.cjs');
|
|
6
6
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const ansis = require_chunk.__toESM(require("ansis"));
|
|
8
|
+
const node_process = require_chunk.__toESM(require("node:process"));
|
|
9
9
|
const node_util = require_chunk.__toESM(require("node:util"));
|
|
10
10
|
const node_tty = require_chunk.__toESM(require("node:tty"));
|
|
11
|
-
const
|
|
12
|
-
const node_url = require_chunk.__toESM(require("node:url"));
|
|
13
|
-
|
|
14
|
-
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
15
|
-
const signals = [];
|
|
16
|
-
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
17
|
-
if (process.platform !== "win32") signals.push(
|
|
18
|
-
"SIGALRM",
|
|
19
|
-
"SIGABRT",
|
|
20
|
-
"SIGVTALRM",
|
|
21
|
-
"SIGXCPU",
|
|
22
|
-
"SIGXFSZ",
|
|
23
|
-
"SIGUSR2",
|
|
24
|
-
"SIGTRAP",
|
|
25
|
-
"SIGSYS",
|
|
26
|
-
"SIGQUIT",
|
|
27
|
-
"SIGIOT"
|
|
28
|
-
// should detect profiler and enable/disable accordingly.
|
|
29
|
-
// see #21
|
|
30
|
-
// 'SIGPROF'
|
|
31
|
-
);
|
|
32
|
-
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
36
|
-
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";
|
|
37
|
-
const kExitEmitter = Symbol.for("signal-exit emitter");
|
|
38
|
-
const global = globalThis;
|
|
39
|
-
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
40
|
-
var Emitter = class {
|
|
41
|
-
emitted = {
|
|
42
|
-
afterExit: false,
|
|
43
|
-
exit: false
|
|
44
|
-
};
|
|
45
|
-
listeners = {
|
|
46
|
-
afterExit: [],
|
|
47
|
-
exit: []
|
|
48
|
-
};
|
|
49
|
-
count = 0;
|
|
50
|
-
id = Math.random();
|
|
51
|
-
constructor() {
|
|
52
|
-
if (global[kExitEmitter]) return global[kExitEmitter];
|
|
53
|
-
ObjectDefineProperty(global, kExitEmitter, {
|
|
54
|
-
value: this,
|
|
55
|
-
writable: false,
|
|
56
|
-
enumerable: false,
|
|
57
|
-
configurable: false
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
on(ev, fn) {
|
|
61
|
-
this.listeners[ev].push(fn);
|
|
62
|
-
}
|
|
63
|
-
removeListener(ev, fn) {
|
|
64
|
-
const list = this.listeners[ev];
|
|
65
|
-
const i$1 = list.indexOf(fn);
|
|
66
|
-
if (i$1 === -1) return;
|
|
67
|
-
if (i$1 === 0 && list.length === 1) list.length = 0;
|
|
68
|
-
else list.splice(i$1, 1);
|
|
69
|
-
}
|
|
70
|
-
emit(ev, code, signal) {
|
|
71
|
-
if (this.emitted[ev]) return false;
|
|
72
|
-
this.emitted[ev] = true;
|
|
73
|
-
let ret = false;
|
|
74
|
-
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
|
|
75
|
-
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
|
|
76
|
-
return ret;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var SignalExitBase = class {};
|
|
80
|
-
const signalExitWrap = (handler) => {
|
|
81
|
-
return {
|
|
82
|
-
onExit(cb, opts) {
|
|
83
|
-
return handler.onExit(cb, opts);
|
|
84
|
-
},
|
|
85
|
-
load() {
|
|
86
|
-
return handler.load();
|
|
87
|
-
},
|
|
88
|
-
unload() {
|
|
89
|
-
return handler.unload();
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
var SignalExitFallback = class extends SignalExitBase {
|
|
94
|
-
onExit() {
|
|
95
|
-
return () => {};
|
|
96
|
-
}
|
|
97
|
-
load() {}
|
|
98
|
-
unload() {}
|
|
99
|
-
};
|
|
100
|
-
var SignalExit = class extends SignalExitBase {
|
|
101
|
-
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
102
|
-
#emitter = new Emitter();
|
|
103
|
-
#process;
|
|
104
|
-
#originalProcessEmit;
|
|
105
|
-
#originalProcessReallyExit;
|
|
106
|
-
#sigListeners = {};
|
|
107
|
-
#loaded = false;
|
|
108
|
-
constructor(process$3) {
|
|
109
|
-
super();
|
|
110
|
-
this.#process = process$3;
|
|
111
|
-
this.#sigListeners = {};
|
|
112
|
-
for (const sig of signals) this.#sigListeners[sig] = () => {
|
|
113
|
-
const listeners = this.#process.listeners(sig);
|
|
114
|
-
let { count } = this.#emitter;
|
|
115
|
-
const p$2 = process$3;
|
|
116
|
-
if (typeof p$2.__signal_exit_emitter__ === "object" && typeof p$2.__signal_exit_emitter__.count === "number") count += p$2.__signal_exit_emitter__.count;
|
|
117
|
-
if (listeners.length === count) {
|
|
118
|
-
this.unload();
|
|
119
|
-
const ret = this.#emitter.emit("exit", null, sig);
|
|
120
|
-
const s$2 = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
121
|
-
if (!ret) process$3.kill(process$3.pid, s$2);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
this.#originalProcessReallyExit = process$3.reallyExit;
|
|
125
|
-
this.#originalProcessEmit = process$3.emit;
|
|
126
|
-
}
|
|
127
|
-
onExit(cb, opts) {
|
|
128
|
-
if (!processOk(this.#process)) return () => {};
|
|
129
|
-
if (this.#loaded === false) this.load();
|
|
130
|
-
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
131
|
-
this.#emitter.on(ev, cb);
|
|
132
|
-
return () => {
|
|
133
|
-
this.#emitter.removeListener(ev, cb);
|
|
134
|
-
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
load() {
|
|
138
|
-
if (this.#loaded) return;
|
|
139
|
-
this.#loaded = true;
|
|
140
|
-
this.#emitter.count += 1;
|
|
141
|
-
for (const sig of signals) try {
|
|
142
|
-
const fn = this.#sigListeners[sig];
|
|
143
|
-
if (fn) this.#process.on(sig, fn);
|
|
144
|
-
} catch (_$1) {}
|
|
145
|
-
this.#process.emit = (ev, ...a$1) => {
|
|
146
|
-
return this.#processEmit(ev, ...a$1);
|
|
147
|
-
};
|
|
148
|
-
this.#process.reallyExit = (code) => {
|
|
149
|
-
return this.#processReallyExit(code);
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
unload() {
|
|
153
|
-
if (!this.#loaded) return;
|
|
154
|
-
this.#loaded = false;
|
|
155
|
-
signals.forEach((sig) => {
|
|
156
|
-
const listener = this.#sigListeners[sig];
|
|
157
|
-
if (!listener) throw new Error("Listener not defined for signal: " + sig);
|
|
158
|
-
try {
|
|
159
|
-
this.#process.removeListener(sig, listener);
|
|
160
|
-
} catch (_$1) {}
|
|
161
|
-
});
|
|
162
|
-
this.#process.emit = this.#originalProcessEmit;
|
|
163
|
-
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
164
|
-
this.#emitter.count -= 1;
|
|
165
|
-
}
|
|
166
|
-
#processReallyExit(code) {
|
|
167
|
-
if (!processOk(this.#process)) return 0;
|
|
168
|
-
this.#process.exitCode = code || 0;
|
|
169
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
170
|
-
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
171
|
-
}
|
|
172
|
-
#processEmit(ev, ...args) {
|
|
173
|
-
const og = this.#originalProcessEmit;
|
|
174
|
-
if (ev === "exit" && processOk(this.#process)) {
|
|
175
|
-
if (typeof args[0] === "number") this.#process.exitCode = args[0];
|
|
176
|
-
const ret = og.call(this.#process, ev, ...args);
|
|
177
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
178
|
-
return ret;
|
|
179
|
-
} else return og.call(this.#process, ev, ...args);
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
const process$2 = globalThis.process;
|
|
183
|
-
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
11
|
+
const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
|
|
184
12
|
|
|
185
|
-
//#
|
|
186
|
-
//#region ../../node_modules/.pnpm/consola@3.4.0/node_modules/consola/dist/core.mjs
|
|
13
|
+
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
|
|
187
14
|
const LogLevels = {
|
|
188
15
|
silent: Number.NEGATIVE_INFINITY,
|
|
189
16
|
fatal: 0,
|
|
@@ -230,7 +57,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
|
230
57
|
for (const key in baseObject) {
|
|
231
58
|
if (key === "__proto__" || key === "constructor") continue;
|
|
232
59
|
const value = baseObject[key];
|
|
233
|
-
if (value === null || value ===
|
|
60
|
+
if (value === null || value === void 0) continue;
|
|
234
61
|
if (merger && merger(object, key, value, namespace)) continue;
|
|
235
62
|
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
236
63
|
else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
@@ -239,7 +66,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
|
239
66
|
return object;
|
|
240
67
|
}
|
|
241
68
|
function createDefu(merger) {
|
|
242
|
-
return (...arguments_) => arguments_.reduce((p
|
|
69
|
+
return (...arguments_) => arguments_.reduce((p, c$1) => _defu(p, c$1, "", merger), {});
|
|
243
70
|
}
|
|
244
71
|
const defu = createDefu();
|
|
245
72
|
function isPlainObject(obj) {
|
|
@@ -552,9 +379,9 @@ var Consola = class Consola {
|
|
|
552
379
|
}
|
|
553
380
|
};
|
|
554
381
|
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
555
|
-
if (input ===
|
|
382
|
+
if (input === void 0) return defaultLevel;
|
|
556
383
|
if (typeof input === "number") return input;
|
|
557
|
-
if (types[input] && types[input].level !==
|
|
384
|
+
if (types[input] && types[input].level !== void 0) return types[input].level;
|
|
558
385
|
return defaultLevel;
|
|
559
386
|
}
|
|
560
387
|
Consola.prototype.add = Consola.prototype.addReporter;
|
|
@@ -569,10 +396,10 @@ function createConsola$1(options$1 = {}) {
|
|
|
569
396
|
}
|
|
570
397
|
|
|
571
398
|
//#endregion
|
|
572
|
-
//#region ../../node_modules/.pnpm/consola@3.4.
|
|
573
|
-
function parseStack(stack) {
|
|
574
|
-
const cwd
|
|
575
|
-
const lines = stack.split("\n").splice(
|
|
399
|
+
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
|
|
400
|
+
function parseStack(stack, message) {
|
|
401
|
+
const cwd = process.cwd() + node_path.sep;
|
|
402
|
+
const lines = stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd, ""));
|
|
576
403
|
return lines;
|
|
577
404
|
}
|
|
578
405
|
function writeStream(data, stream) {
|
|
@@ -581,14 +408,14 @@ function writeStream(data, stream) {
|
|
|
581
408
|
}
|
|
582
409
|
const bracket = (x) => x ? `[${x}]` : "";
|
|
583
410
|
var BasicReporter = class {
|
|
584
|
-
formatStack(stack, opts) {
|
|
411
|
+
formatStack(stack, message, opts) {
|
|
585
412
|
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
586
|
-
return indent + parseStack(stack).join(`
|
|
413
|
+
return indent + parseStack(stack, message).join(`
|
|
587
414
|
${indent}`);
|
|
588
415
|
}
|
|
589
416
|
formatError(err, opts) {
|
|
590
417
|
const message = err.message ?? (0, node_util.formatWithOptions)(opts, err);
|
|
591
|
-
const stack = err.stack ? this.formatStack(err.stack, opts) : "";
|
|
418
|
+
const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
|
|
592
419
|
const level = opts?.errorLevel || 0;
|
|
593
420
|
const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
|
|
594
421
|
const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
|
|
@@ -633,7 +460,7 @@ ${indent}`);
|
|
|
633
460
|
};
|
|
634
461
|
|
|
635
462
|
//#endregion
|
|
636
|
-
//#region ../../node_modules/.pnpm/consola@3.4.
|
|
463
|
+
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
|
|
637
464
|
const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
638
465
|
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
639
466
|
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
@@ -649,7 +476,7 @@ function clearBleed(index, string, open, close, replace) {
|
|
|
649
476
|
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
650
477
|
}
|
|
651
478
|
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
|
652
|
-
return (string) => string || !(string === "" || string ===
|
|
479
|
+
return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
653
480
|
}
|
|
654
481
|
function init(open, close, replace) {
|
|
655
482
|
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
|
@@ -700,12 +527,12 @@ const colorDefs = {
|
|
|
700
527
|
function createColors(useColor = isColorSupported) {
|
|
701
528
|
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
702
529
|
}
|
|
703
|
-
const colors$
|
|
530
|
+
const colors$2 = createColors();
|
|
704
531
|
function getColor$1(color, fallback = "reset") {
|
|
705
|
-
return colors$
|
|
532
|
+
return colors$2[color] || colors$2[fallback];
|
|
706
533
|
}
|
|
707
534
|
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("|");
|
|
708
|
-
function stripAnsi
|
|
535
|
+
function stripAnsi(text) {
|
|
709
536
|
return text.replace(new RegExp(ansiRegex$1, "g"), "");
|
|
710
537
|
}
|
|
711
538
|
const boxStylePresets = {
|
|
@@ -798,14 +625,14 @@ function box(text, _opts = {}) {
|
|
|
798
625
|
if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
|
|
799
626
|
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
800
627
|
const height = textLines.length + paddingOffset;
|
|
801
|
-
const width = Math.max(...textLines.map((line) => stripAnsi
|
|
628
|
+
const width = Math.max(...textLines.map((line) => stripAnsi(line).length), opts.title ? stripAnsi(opts.title).length : 0) + paddingOffset;
|
|
802
629
|
const widthOffset = width + paddingOffset;
|
|
803
630
|
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
804
631
|
if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
|
|
805
632
|
if (opts.title) {
|
|
806
633
|
const title = _color ? _color(opts.title) : opts.title;
|
|
807
|
-
const left = borderStyle.h.repeat(Math.floor((width - stripAnsi
|
|
808
|
-
const right = borderStyle.h.repeat(width - stripAnsi
|
|
634
|
+
const left = borderStyle.h.repeat(Math.floor((width - stripAnsi(opts.title).length) / 2));
|
|
635
|
+
const right = borderStyle.h.repeat(width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset);
|
|
809
636
|
boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
|
|
810
637
|
} else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
|
|
811
638
|
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
@@ -813,7 +640,7 @@ function box(text, _opts = {}) {
|
|
|
813
640
|
else {
|
|
814
641
|
const line = textLines[i$1 - valignOffset];
|
|
815
642
|
const left = " ".repeat(paddingOffset);
|
|
816
|
-
const right = " ".repeat(width - stripAnsi
|
|
643
|
+
const right = " ".repeat(width - stripAnsi(line).length);
|
|
817
644
|
boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
|
|
818
645
|
}
|
|
819
646
|
boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
|
|
@@ -822,29 +649,29 @@ function box(text, _opts = {}) {
|
|
|
822
649
|
}
|
|
823
650
|
|
|
824
651
|
//#endregion
|
|
825
|
-
//#region ../../node_modules/.pnpm/consola@3.4.
|
|
826
|
-
const r = Object.create(null), i = (e) => globalThis.process?.env ||
|
|
827
|
-
get(e,
|
|
828
|
-
return i()[
|
|
652
|
+
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
653
|
+
const r = Object.create(null), i = (e) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
|
|
654
|
+
get(e, s$1) {
|
|
655
|
+
return i()[s$1] ?? r[s$1];
|
|
829
656
|
},
|
|
830
|
-
has(e,
|
|
657
|
+
has(e, s$1) {
|
|
831
658
|
const E = i();
|
|
832
|
-
return
|
|
659
|
+
return s$1 in E || s$1 in r;
|
|
833
660
|
},
|
|
834
|
-
set(e,
|
|
835
|
-
const
|
|
836
|
-
return
|
|
661
|
+
set(e, s$1, E) {
|
|
662
|
+
const B = i(true);
|
|
663
|
+
return B[s$1] = E, true;
|
|
837
664
|
},
|
|
838
|
-
deleteProperty(e,
|
|
839
|
-
if (!
|
|
665
|
+
deleteProperty(e, s$1) {
|
|
666
|
+
if (!s$1) return false;
|
|
840
667
|
const E = i(true);
|
|
841
|
-
return delete E[
|
|
668
|
+
return delete E[s$1], true;
|
|
842
669
|
},
|
|
843
670
|
ownKeys() {
|
|
844
671
|
const e = i(true);
|
|
845
672
|
return Object.keys(e);
|
|
846
673
|
}
|
|
847
|
-
}), t = typeof process < "u" && process.env && process.env.NODE_ENV || "",
|
|
674
|
+
}), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
|
|
848
675
|
["APPVEYOR"],
|
|
849
676
|
[
|
|
850
677
|
"AWS_AMPLIFY",
|
|
@@ -912,6 +739,11 @@ const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta
|
|
|
912
739
|
"CODESANDBOX_SSE",
|
|
913
740
|
{ ci: false }
|
|
914
741
|
],
|
|
742
|
+
[
|
|
743
|
+
"CODESANDBOX",
|
|
744
|
+
"CODESANDBOX_HOST",
|
|
745
|
+
{ ci: false }
|
|
746
|
+
],
|
|
915
747
|
["STACKBLITZ"],
|
|
916
748
|
["STORMKIT"],
|
|
917
749
|
["CLEAVR"],
|
|
@@ -930,10 +762,10 @@ const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta
|
|
|
930
762
|
{ ci: true }
|
|
931
763
|
]
|
|
932
764
|
];
|
|
933
|
-
function
|
|
934
|
-
if (globalThis.process?.env) for (const e of
|
|
935
|
-
const
|
|
936
|
-
if (globalThis.process?.env[
|
|
765
|
+
function b() {
|
|
766
|
+
if (globalThis.process?.env) for (const e of f) {
|
|
767
|
+
const s$1 = e[1] || e[0];
|
|
768
|
+
if (globalThis.process?.env[s$1]) return {
|
|
937
769
|
name: e[0].toLowerCase(),
|
|
938
770
|
...e[2]
|
|
939
771
|
};
|
|
@@ -946,45 +778,45 @@ function p() {
|
|
|
946
778
|
ci: false
|
|
947
779
|
};
|
|
948
780
|
}
|
|
949
|
-
const l =
|
|
781
|
+
const l = b();
|
|
950
782
|
l.name;
|
|
951
783
|
function n(e) {
|
|
952
784
|
return e ? e !== "false" : false;
|
|
953
785
|
}
|
|
954
|
-
const I = globalThis.process?.platform || "", T = n(
|
|
955
|
-
n(
|
|
956
|
-
const
|
|
957
|
-
!n(
|
|
786
|
+
const I = globalThis.process?.platform || "", T = n(o.CI) || l.ci !== false, a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), g = n(o.DEBUG), R = t === "test" || n(o.TEST);
|
|
787
|
+
n(o.MINIMAL);
|
|
788
|
+
const A = /^win/i.test(I);
|
|
789
|
+
!n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
|
|
958
790
|
const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
|
|
959
|
-
Number(C?.split(".")[0])
|
|
960
|
-
const y = globalThis.process || Object.create(null),
|
|
961
|
-
new Proxy(y, { get(e,
|
|
962
|
-
if (
|
|
963
|
-
if (
|
|
964
|
-
if (
|
|
791
|
+
Number(C?.split(".")[0]);
|
|
792
|
+
const y = globalThis.process || Object.create(null), _ = { versions: {} };
|
|
793
|
+
new Proxy(y, { get(e, s$1) {
|
|
794
|
+
if (s$1 === "env") return o;
|
|
795
|
+
if (s$1 in e) return e[s$1];
|
|
796
|
+
if (s$1 in _) return _[s$1];
|
|
965
797
|
} });
|
|
966
|
-
const
|
|
798
|
+
const c = globalThis.process?.release?.name === "node", O = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
|
|
967
799
|
[S, "netlify"],
|
|
968
|
-
[
|
|
969
|
-
[
|
|
970
|
-
[
|
|
800
|
+
[u, "edge-light"],
|
|
801
|
+
[N, "workerd"],
|
|
802
|
+
[L, "fastly"],
|
|
971
803
|
[D, "deno"],
|
|
972
|
-
[
|
|
973
|
-
[
|
|
804
|
+
[O, "bun"],
|
|
805
|
+
[c, "node"]
|
|
974
806
|
];
|
|
975
807
|
function G() {
|
|
976
|
-
const e = F.find((
|
|
808
|
+
const e = F.find((s$1) => s$1[0]);
|
|
977
809
|
if (e) return { name: e[1] };
|
|
978
810
|
}
|
|
979
|
-
const
|
|
980
|
-
|
|
811
|
+
const P = G();
|
|
812
|
+
P?.name;
|
|
981
813
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
982
814
|
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
983
815
|
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("|");
|
|
984
|
-
return new RegExp(pattern, onlyFirst ?
|
|
816
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
985
817
|
}
|
|
986
818
|
const regex = ansiRegex();
|
|
987
|
-
function stripAnsi(string) {
|
|
819
|
+
function stripAnsi$1(string) {
|
|
988
820
|
if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
989
821
|
return string.replace(regex, "");
|
|
990
822
|
}
|
|
@@ -1013,7 +845,7 @@ const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
|
1013
845
|
function stringWidth$1(string, options$1 = {}) {
|
|
1014
846
|
if (typeof string !== "string" || string.length === 0) return 0;
|
|
1015
847
|
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options$1;
|
|
1016
|
-
if (!countAnsiEscapeCodes) string = stripAnsi(string);
|
|
848
|
+
if (!countAnsiEscapeCodes) string = stripAnsi$1(string);
|
|
1017
849
|
if (string.length === 0) return 0;
|
|
1018
850
|
let width = 0;
|
|
1019
851
|
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
@@ -1067,54 +899,54 @@ const TYPE_ICONS = {
|
|
|
1067
899
|
};
|
|
1068
900
|
function stringWidth(str) {
|
|
1069
901
|
const hasICU = typeof Intl === "object";
|
|
1070
|
-
if (!hasICU || !Intl.Segmenter) return stripAnsi
|
|
902
|
+
if (!hasICU || !Intl.Segmenter) return stripAnsi(str).length;
|
|
1071
903
|
return stringWidth$1(str);
|
|
1072
904
|
}
|
|
1073
905
|
var FancyReporter = class extends BasicReporter {
|
|
1074
|
-
formatStack(stack, opts) {
|
|
906
|
+
formatStack(stack, message, opts) {
|
|
1075
907
|
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
1076
908
|
return `
|
|
1077
|
-
${indent}` + parseStack(stack).map((line) => " " + line.replace(/^at +/, (m) => colors$
|
|
909
|
+
${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors$2.gray(m)).replace(/\((.+)\)/, (_$1, m) => `(${colors$2.cyan(m)})`)).join(`
|
|
1078
910
|
${indent}`);
|
|
1079
911
|
}
|
|
1080
912
|
formatType(logObj, isBadge, opts) {
|
|
1081
913
|
const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
|
|
1082
|
-
if (isBadge) return getBgColor(typeColor)(colors$
|
|
914
|
+
if (isBadge) return getBgColor(typeColor)(colors$2.black(` ${logObj.type.toUpperCase()} `));
|
|
1083
915
|
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
1084
916
|
return _type ? getColor(typeColor)(_type) : "";
|
|
1085
917
|
}
|
|
1086
918
|
formatLogObj(logObj, opts) {
|
|
1087
919
|
const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
|
|
1088
920
|
if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
|
|
1089
|
-
title: logObj.title ? characterFormat(logObj.title) :
|
|
921
|
+
title: logObj.title ? characterFormat(logObj.title) : void 0,
|
|
1090
922
|
style: logObj.style
|
|
1091
923
|
});
|
|
1092
924
|
const date = this.formatDate(logObj.date, opts);
|
|
1093
|
-
const coloredDate = date && colors$
|
|
925
|
+
const coloredDate = date && colors$2.gray(date);
|
|
1094
926
|
const isBadge = logObj.badge ?? logObj.level < 2;
|
|
1095
927
|
const type = this.formatType(logObj, isBadge, opts);
|
|
1096
|
-
const tag = logObj.tag ? colors$
|
|
928
|
+
const tag = logObj.tag ? colors$2.gray(logObj.tag) : "";
|
|
1097
929
|
let line;
|
|
1098
930
|
const left = this.filterAndJoin([type, characterFormat(message)]);
|
|
1099
931
|
const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
|
|
1100
932
|
const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
|
|
1101
|
-
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors$
|
|
933
|
+
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors$2.gray(`[${right}]`)} ` : "") + left;
|
|
1102
934
|
line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
|
|
1103
935
|
if (logObj.type === "trace") {
|
|
1104
|
-
const _err = new Error("Trace: " + logObj.message);
|
|
1105
|
-
line += this.formatStack(_err.stack || "");
|
|
936
|
+
const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
|
|
937
|
+
line += this.formatStack(_err.stack || "", _err.message);
|
|
1106
938
|
}
|
|
1107
939
|
return isBadge ? "\n" + line + "\n" : line;
|
|
1108
940
|
}
|
|
1109
941
|
};
|
|
1110
942
|
function characterFormat(str) {
|
|
1111
|
-
return str.replace(/`([^`]+)`/gm, (_$1, m) => colors$
|
|
943
|
+
return str.replace(/`([^`]+)`/gm, (_$1, m) => colors$2.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_$1, m) => ` ${colors$2.underline(m)} `);
|
|
1112
944
|
}
|
|
1113
945
|
function getColor(color = "white") {
|
|
1114
|
-
return colors$
|
|
946
|
+
return colors$2[color] || colors$2.white;
|
|
1115
947
|
}
|
|
1116
948
|
function getBgColor(color = "bgWhite") {
|
|
1117
|
-
return colors$
|
|
949
|
+
return colors$2[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors$2.bgWhite;
|
|
1118
950
|
}
|
|
1119
951
|
function createConsola(options$1 = {}) {
|
|
1120
952
|
let level = _getDefaultLogLevel();
|
|
@@ -1124,23 +956,24 @@ function createConsola(options$1 = {}) {
|
|
|
1124
956
|
defaults: { level },
|
|
1125
957
|
stdout: process.stdout,
|
|
1126
958
|
stderr: process.stderr,
|
|
1127
|
-
prompt: (...args) => Promise.resolve().then(
|
|
1128
|
-
|
|
1129
|
-
}).then((m) => m.prompt(...args)),
|
|
1130
|
-
reporters: options$1.reporters || [options$1.fancy ?? !(T || A) ? new FancyReporter() : new BasicReporter()],
|
|
959
|
+
prompt: (...args) => Promise.resolve().then(() => require("./shared/prompt-QNI93ne7.cjs")).then((m) => m.prompt(...args)),
|
|
960
|
+
reporters: options$1.reporters || [options$1.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
|
|
1131
961
|
...options$1
|
|
1132
962
|
});
|
|
1133
963
|
return consola2;
|
|
1134
964
|
}
|
|
1135
965
|
function _getDefaultLogLevel() {
|
|
1136
|
-
if (
|
|
1137
|
-
if (
|
|
966
|
+
if (g) return LogLevels.debug;
|
|
967
|
+
if (R) return LogLevels.warn;
|
|
1138
968
|
return LogLevels.info;
|
|
1139
969
|
}
|
|
1140
970
|
const consola = createConsola();
|
|
1141
971
|
|
|
1142
972
|
//#endregion
|
|
1143
973
|
//#region src/cli/logger.ts
|
|
974
|
+
/**
|
|
975
|
+
* Console logger
|
|
976
|
+
*/
|
|
1144
977
|
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
|
|
1145
978
|
function createTestingLogger() {
|
|
1146
979
|
const types = [
|
|
@@ -1165,131 +998,541 @@ function createTestingLogger() {
|
|
|
1165
998
|
}
|
|
1166
999
|
|
|
1167
1000
|
//#endregion
|
|
1168
|
-
//#region src/cli/
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
"
|
|
1212
|
-
"
|
|
1213
|
-
"
|
|
1214
|
-
|
|
1215
|
-
const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
1216
|
-
".ts",
|
|
1217
|
-
".mts",
|
|
1218
|
-
".cts"
|
|
1001
|
+
//#region src/cli/arguments/alias.ts
|
|
1002
|
+
const alias = {
|
|
1003
|
+
config: {
|
|
1004
|
+
abbreviation: "c",
|
|
1005
|
+
hint: "filename"
|
|
1006
|
+
},
|
|
1007
|
+
help: { abbreviation: "h" },
|
|
1008
|
+
version: { abbreviation: "v" },
|
|
1009
|
+
watch: { abbreviation: "w" },
|
|
1010
|
+
dir: { abbreviation: "d" },
|
|
1011
|
+
file: { abbreviation: "o" },
|
|
1012
|
+
external: { abbreviation: "e" },
|
|
1013
|
+
format: { abbreviation: "f" },
|
|
1014
|
+
name: { abbreviation: "n" },
|
|
1015
|
+
globals: { abbreviation: "g" },
|
|
1016
|
+
sourcemap: {
|
|
1017
|
+
abbreviation: "s",
|
|
1018
|
+
default: true
|
|
1019
|
+
},
|
|
1020
|
+
minify: { abbreviation: "m" },
|
|
1021
|
+
platform: { abbreviation: "p" },
|
|
1022
|
+
assetFileNames: { hint: "name" },
|
|
1023
|
+
chunkFileNames: { hint: "name" },
|
|
1024
|
+
entryFileNames: { hint: "name" },
|
|
1025
|
+
externalLiveBindings: {
|
|
1026
|
+
default: true,
|
|
1027
|
+
reverse: true
|
|
1028
|
+
},
|
|
1029
|
+
treeshake: {
|
|
1030
|
+
default: true,
|
|
1031
|
+
reverse: true
|
|
1032
|
+
},
|
|
1033
|
+
preserveEntrySignatures: {
|
|
1034
|
+
default: "strict",
|
|
1035
|
+
reverse: true
|
|
1036
|
+
},
|
|
1037
|
+
moduleTypes: { hint: "types" }
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region src/cli/arguments/utils.ts
|
|
1042
|
+
const priority = [
|
|
1043
|
+
"object",
|
|
1044
|
+
"array",
|
|
1045
|
+
"string",
|
|
1046
|
+
"number",
|
|
1047
|
+
"boolean"
|
|
1219
1048
|
];
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1049
|
+
function getSchemaType(schema) {
|
|
1050
|
+
if ("anyOf" in schema) {
|
|
1051
|
+
const types = schema.anyOf.map(getSchemaType);
|
|
1052
|
+
let result = priority.find((type) => types.includes(type));
|
|
1053
|
+
if (result) return result;
|
|
1054
|
+
}
|
|
1055
|
+
if ("type" in schema) return schema.type;
|
|
1056
|
+
if ("const" in schema) return typeof schema.const;
|
|
1057
|
+
return "never";
|
|
1229
1058
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1059
|
+
function flattenSchema(schema, base = {}, parent = "") {
|
|
1060
|
+
if (schema === void 0) return base;
|
|
1061
|
+
for (const [k, value] of Object.entries(schema)) {
|
|
1062
|
+
const key = parent ? `${parent}.${k}` : k;
|
|
1063
|
+
if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
|
|
1064
|
+
else base[key] = value;
|
|
1065
|
+
else base[key] = value;
|
|
1236
1066
|
}
|
|
1067
|
+
return base;
|
|
1237
1068
|
}
|
|
1238
|
-
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
return await loadTsConfig(rawConfigPath);
|
|
1245
|
-
} else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
|
|
1246
|
-
} catch (err) {
|
|
1247
|
-
throw new Error("Error happened while loading config.", { cause: err });
|
|
1069
|
+
function setNestedProperty(obj, path$1, value) {
|
|
1070
|
+
const keys = path$1.split(".");
|
|
1071
|
+
let current = obj;
|
|
1072
|
+
for (let i$1 = 0; i$1 < keys.length - 1; i$1++) {
|
|
1073
|
+
if (!current[keys[i$1]]) current[keys[i$1]] = {};
|
|
1074
|
+
current = current[keys[i$1]];
|
|
1248
1075
|
}
|
|
1076
|
+
const finalKey = keys[keys.length - 1];
|
|
1077
|
+
Object.defineProperty(current, finalKey, {
|
|
1078
|
+
value,
|
|
1079
|
+
writable: true,
|
|
1080
|
+
enumerable: true,
|
|
1081
|
+
configurable: true
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
function camelCaseToKebabCase(str) {
|
|
1085
|
+
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1086
|
+
}
|
|
1087
|
+
function kebabCaseToCamelCase(str) {
|
|
1088
|
+
return str.replace(/-./g, (match) => match[1].toUpperCase());
|
|
1249
1089
|
}
|
|
1250
1090
|
|
|
1251
1091
|
//#endregion
|
|
1252
|
-
//#region src/cli/
|
|
1253
|
-
|
|
1254
|
-
const
|
|
1255
|
-
if (
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1092
|
+
//#region src/cli/arguments/normalize.ts
|
|
1093
|
+
function normalizeCliOptions(cliOptions, positionals) {
|
|
1094
|
+
const [data, errors] = require_src.validateCliOptions(cliOptions);
|
|
1095
|
+
if (errors?.length) {
|
|
1096
|
+
errors.forEach((error) => {
|
|
1097
|
+
logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
|
|
1098
|
+
});
|
|
1099
|
+
process.exit(1);
|
|
1100
|
+
}
|
|
1101
|
+
const options$1 = data ?? {};
|
|
1102
|
+
const result = {
|
|
1103
|
+
input: {},
|
|
1104
|
+
output: {},
|
|
1105
|
+
help: options$1.help ?? false,
|
|
1106
|
+
version: options$1.version ?? false,
|
|
1107
|
+
watch: options$1.watch ?? false
|
|
1108
|
+
};
|
|
1109
|
+
if (typeof options$1.config === "string") result.config = options$1.config;
|
|
1110
|
+
const keysOfInput = require_src.getInputCliKeys();
|
|
1111
|
+
const keysOfOutput = require_src.getOutputCliKeys();
|
|
1112
|
+
const reservedKeys = [
|
|
1113
|
+
"help",
|
|
1114
|
+
"version",
|
|
1115
|
+
"config",
|
|
1116
|
+
"watch"
|
|
1117
|
+
];
|
|
1118
|
+
for (let [key, value] of Object.entries(options$1)) {
|
|
1119
|
+
const keys = key.split(".");
|
|
1120
|
+
const [primary] = keys;
|
|
1121
|
+
if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
|
|
1122
|
+
else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
|
|
1123
|
+
else if (!reservedKeys.includes(key)) {
|
|
1124
|
+
logger.error(`Unknown option: ${key}`);
|
|
1125
|
+
process.exit(1);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
if (!result.config && positionals.length > 0) if (Array.isArray(result.input.input)) result.input.input.push(...positionals);
|
|
1129
|
+
else result.input.input = positionals;
|
|
1130
|
+
return result;
|
|
1261
1131
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1132
|
+
|
|
1133
|
+
//#endregion
|
|
1134
|
+
//#region src/cli/arguments/index.ts
|
|
1135
|
+
const objectSchema = require_src.getJsonSchema();
|
|
1136
|
+
const flattenedSchema = flattenSchema(objectSchema.properties);
|
|
1137
|
+
const options = Object.fromEntries(Object.entries(flattenedSchema).filter(([_key, schema]) => getSchemaType(schema) !== "never").map(([key, schema]) => {
|
|
1138
|
+
const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
|
|
1139
|
+
const type = getSchemaType(schema);
|
|
1140
|
+
const result = {
|
|
1141
|
+
type: type === "boolean" ? "boolean" : "string",
|
|
1142
|
+
description: schema?.description ?? config?.description ?? "",
|
|
1143
|
+
hint: config?.hint
|
|
1144
|
+
};
|
|
1145
|
+
if (config && config?.abbreviation) result.short = config?.abbreviation;
|
|
1146
|
+
if (config && config.reverse) {
|
|
1147
|
+
if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
|
|
1148
|
+
else if (!result.description.startsWith("Avoid")) result.description = `disable ${result.description}`;
|
|
1149
|
+
}
|
|
1150
|
+
key = camelCaseToKebabCase(key);
|
|
1151
|
+
return [config?.reverse ? `no-${key}` : key, result];
|
|
1152
|
+
}));
|
|
1153
|
+
function parseCliArguments() {
|
|
1154
|
+
const { values, tokens, positionals } = (0, node_util.parseArgs)({
|
|
1155
|
+
options,
|
|
1156
|
+
tokens: true,
|
|
1157
|
+
allowPositionals: true,
|
|
1158
|
+
strict: false
|
|
1159
|
+
});
|
|
1160
|
+
tokens.filter((token) => token.kind === "option").forEach((option) => {
|
|
1161
|
+
let negative = false;
|
|
1162
|
+
if (option.name.startsWith("no-")) {
|
|
1163
|
+
const name = kebabCaseToCamelCase(option.name.substring(3));
|
|
1164
|
+
if (name in flattenedSchema) {
|
|
1165
|
+
delete values[option.name];
|
|
1166
|
+
option.name = name;
|
|
1167
|
+
negative = true;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
delete values[option.name];
|
|
1171
|
+
option.name = kebabCaseToCamelCase(option.name);
|
|
1172
|
+
let originalType = flattenedSchema[option.name];
|
|
1173
|
+
if (!originalType) {
|
|
1174
|
+
logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
|
|
1175
|
+
process.exit(1);
|
|
1176
|
+
}
|
|
1177
|
+
let type = getSchemaType(originalType);
|
|
1178
|
+
if (type === "string" && typeof option.value !== "string") {
|
|
1179
|
+
let opt = option;
|
|
1180
|
+
let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
|
|
1181
|
+
Object.defineProperty(values, opt.name, {
|
|
1182
|
+
value: defaultValue.default ?? "",
|
|
1183
|
+
enumerable: true,
|
|
1184
|
+
configurable: true,
|
|
1185
|
+
writable: true
|
|
1186
|
+
});
|
|
1187
|
+
} else if (type === "object" && typeof option.value === "string") {
|
|
1188
|
+
const [key, value] = option.value.split(",").map((x) => x.split("="))[0];
|
|
1189
|
+
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
1190
|
+
value: {},
|
|
1191
|
+
enumerable: true,
|
|
1192
|
+
configurable: true,
|
|
1193
|
+
writable: true
|
|
1194
|
+
});
|
|
1195
|
+
if (key && value) Object.defineProperty(values[option.name], key, {
|
|
1196
|
+
value,
|
|
1197
|
+
enumerable: true,
|
|
1198
|
+
configurable: true,
|
|
1199
|
+
writable: true
|
|
1200
|
+
});
|
|
1201
|
+
} else if (type === "array" && typeof option.value === "string") {
|
|
1202
|
+
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
1203
|
+
value: [],
|
|
1204
|
+
enumerable: true,
|
|
1205
|
+
configurable: true,
|
|
1206
|
+
writable: true
|
|
1207
|
+
});
|
|
1208
|
+
values[option.name].push(option.value);
|
|
1209
|
+
} else if (type === "boolean") Object.defineProperty(values, option.name, {
|
|
1210
|
+
value: !negative,
|
|
1211
|
+
enumerable: true,
|
|
1212
|
+
configurable: true,
|
|
1213
|
+
writable: true
|
|
1214
|
+
});
|
|
1215
|
+
else Object.defineProperty(values, option.name, {
|
|
1216
|
+
value: option.value ?? "",
|
|
1217
|
+
enumerable: true,
|
|
1218
|
+
configurable: true,
|
|
1219
|
+
writable: true
|
|
1220
|
+
});
|
|
1221
|
+
});
|
|
1222
|
+
return normalizeCliOptions(values, positionals);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
1227
|
+
/**
|
|
1228
|
+
* This is not the set of all possible signals.
|
|
1229
|
+
*
|
|
1230
|
+
* It IS, however, the set of all signals that trigger
|
|
1231
|
+
* an exit on either Linux or BSD systems. Linux is a
|
|
1232
|
+
* superset of the signal names supported on BSD, and
|
|
1233
|
+
* the unknown signals just fail to register, so we can
|
|
1234
|
+
* catch that easily enough.
|
|
1235
|
+
*
|
|
1236
|
+
* Windows signals are a different set, since there are
|
|
1237
|
+
* signals that terminate Windows processes, but don't
|
|
1238
|
+
* terminate (or don't even exist) on Posix systems.
|
|
1239
|
+
*
|
|
1240
|
+
* Don't bother with SIGKILL. It's uncatchable, which
|
|
1241
|
+
* means that we can't fire any callbacks anyway.
|
|
1242
|
+
*
|
|
1243
|
+
* If a user does happen to register a handler on a non-
|
|
1244
|
+
* fatal signal like SIGWINCH or something, and then
|
|
1245
|
+
* exit, it'll end up firing `process.emit('exit')`, so
|
|
1246
|
+
* the handler will be fired anyway.
|
|
1247
|
+
*
|
|
1248
|
+
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
1249
|
+
* artificially, inherently leave the process in a
|
|
1250
|
+
* state from which it is not safe to try and enter JS
|
|
1251
|
+
* listeners.
|
|
1252
|
+
*/
|
|
1253
|
+
const signals = [];
|
|
1254
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
1255
|
+
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
1256
|
+
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
1257
|
+
|
|
1258
|
+
//#endregion
|
|
1259
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
1260
|
+
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";
|
|
1261
|
+
const kExitEmitter = Symbol.for("signal-exit emitter");
|
|
1262
|
+
const global = globalThis;
|
|
1263
|
+
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
1264
|
+
var Emitter = class {
|
|
1265
|
+
emitted = {
|
|
1266
|
+
afterExit: false,
|
|
1267
|
+
exit: false
|
|
1268
|
+
};
|
|
1269
|
+
listeners = {
|
|
1270
|
+
afterExit: [],
|
|
1271
|
+
exit: []
|
|
1272
|
+
};
|
|
1273
|
+
count = 0;
|
|
1274
|
+
id = Math.random();
|
|
1275
|
+
constructor() {
|
|
1276
|
+
if (global[kExitEmitter]) return global[kExitEmitter];
|
|
1277
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
1278
|
+
value: this,
|
|
1279
|
+
writable: false,
|
|
1280
|
+
enumerable: false,
|
|
1281
|
+
configurable: false
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
on(ev, fn) {
|
|
1285
|
+
this.listeners[ev].push(fn);
|
|
1286
|
+
}
|
|
1287
|
+
removeListener(ev, fn) {
|
|
1288
|
+
const list = this.listeners[ev];
|
|
1289
|
+
const i$1 = list.indexOf(fn);
|
|
1290
|
+
/* c8 ignore start */
|
|
1291
|
+
if (i$1 === -1) return;
|
|
1292
|
+
/* c8 ignore stop */
|
|
1293
|
+
if (i$1 === 0 && list.length === 1) list.length = 0;
|
|
1294
|
+
else list.splice(i$1, 1);
|
|
1295
|
+
}
|
|
1296
|
+
emit(ev, code, signal) {
|
|
1297
|
+
if (this.emitted[ev]) return false;
|
|
1298
|
+
this.emitted[ev] = true;
|
|
1299
|
+
let ret = false;
|
|
1300
|
+
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
|
|
1301
|
+
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
|
|
1302
|
+
return ret;
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
var SignalExitBase = class {};
|
|
1306
|
+
const signalExitWrap = (handler) => {
|
|
1307
|
+
return {
|
|
1308
|
+
onExit(cb, opts) {
|
|
1309
|
+
return handler.onExit(cb, opts);
|
|
1310
|
+
},
|
|
1311
|
+
load() {
|
|
1312
|
+
return handler.load();
|
|
1313
|
+
},
|
|
1314
|
+
unload() {
|
|
1315
|
+
return handler.unload();
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
};
|
|
1319
|
+
var SignalExitFallback = class extends SignalExitBase {
|
|
1320
|
+
onExit() {
|
|
1321
|
+
return () => {};
|
|
1322
|
+
}
|
|
1323
|
+
load() {}
|
|
1324
|
+
unload() {}
|
|
1325
|
+
};
|
|
1326
|
+
var SignalExit = class extends SignalExitBase {
|
|
1327
|
+
/* c8 ignore start */
|
|
1328
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
1329
|
+
/* c8 ignore stop */
|
|
1330
|
+
#emitter = new Emitter();
|
|
1331
|
+
#process;
|
|
1332
|
+
#originalProcessEmit;
|
|
1333
|
+
#originalProcessReallyExit;
|
|
1334
|
+
#sigListeners = {};
|
|
1335
|
+
#loaded = false;
|
|
1336
|
+
constructor(process$3) {
|
|
1337
|
+
super();
|
|
1338
|
+
this.#process = process$3;
|
|
1339
|
+
this.#sigListeners = {};
|
|
1340
|
+
for (const sig of signals) this.#sigListeners[sig] = () => {
|
|
1341
|
+
const listeners = this.#process.listeners(sig);
|
|
1342
|
+
let { count } = this.#emitter;
|
|
1343
|
+
/* c8 ignore start */
|
|
1344
|
+
const p = process$3;
|
|
1345
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
|
|
1346
|
+
/* c8 ignore stop */
|
|
1347
|
+
if (listeners.length === count) {
|
|
1348
|
+
this.unload();
|
|
1349
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
1350
|
+
/* c8 ignore start */
|
|
1351
|
+
const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
1352
|
+
if (!ret) process$3.kill(process$3.pid, s$1);
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
this.#originalProcessReallyExit = process$3.reallyExit;
|
|
1356
|
+
this.#originalProcessEmit = process$3.emit;
|
|
1357
|
+
}
|
|
1358
|
+
onExit(cb, opts) {
|
|
1359
|
+
/* c8 ignore start */
|
|
1360
|
+
if (!processOk(this.#process)) return () => {};
|
|
1361
|
+
/* c8 ignore stop */
|
|
1362
|
+
if (this.#loaded === false) this.load();
|
|
1363
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
1364
|
+
this.#emitter.on(ev, cb);
|
|
1365
|
+
return () => {
|
|
1366
|
+
this.#emitter.removeListener(ev, cb);
|
|
1367
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
load() {
|
|
1371
|
+
if (this.#loaded) return;
|
|
1372
|
+
this.#loaded = true;
|
|
1373
|
+
this.#emitter.count += 1;
|
|
1374
|
+
for (const sig of signals) try {
|
|
1375
|
+
const fn = this.#sigListeners[sig];
|
|
1376
|
+
if (fn) this.#process.on(sig, fn);
|
|
1377
|
+
} catch (_$1) {}
|
|
1378
|
+
this.#process.emit = (ev, ...a$1) => {
|
|
1379
|
+
return this.#processEmit(ev, ...a$1);
|
|
1380
|
+
};
|
|
1381
|
+
this.#process.reallyExit = (code) => {
|
|
1382
|
+
return this.#processReallyExit(code);
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
unload() {
|
|
1386
|
+
if (!this.#loaded) return;
|
|
1387
|
+
this.#loaded = false;
|
|
1388
|
+
signals.forEach((sig) => {
|
|
1389
|
+
const listener = this.#sigListeners[sig];
|
|
1390
|
+
/* c8 ignore start */
|
|
1391
|
+
if (!listener) throw new Error("Listener not defined for signal: " + sig);
|
|
1392
|
+
/* c8 ignore stop */
|
|
1393
|
+
try {
|
|
1394
|
+
this.#process.removeListener(sig, listener);
|
|
1395
|
+
} catch (_$1) {}
|
|
1396
|
+
/* c8 ignore stop */
|
|
1397
|
+
});
|
|
1398
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
1399
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
1400
|
+
this.#emitter.count -= 1;
|
|
1401
|
+
}
|
|
1402
|
+
#processReallyExit(code) {
|
|
1403
|
+
/* c8 ignore start */
|
|
1404
|
+
if (!processOk(this.#process)) return 0;
|
|
1405
|
+
this.#process.exitCode = code || 0;
|
|
1406
|
+
/* c8 ignore stop */
|
|
1407
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1408
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
1409
|
+
}
|
|
1410
|
+
#processEmit(ev, ...args) {
|
|
1411
|
+
const og = this.#originalProcessEmit;
|
|
1412
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
1413
|
+
if (typeof args[0] === "number") this.#process.exitCode = args[0];
|
|
1414
|
+
/* c8 ignore start */
|
|
1415
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
1416
|
+
/* c8 ignore start */
|
|
1417
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1418
|
+
/* c8 ignore stop */
|
|
1419
|
+
return ret;
|
|
1420
|
+
} else return og.call(this.#process, ev, ...args);
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
const process$2 = globalThis.process;
|
|
1424
|
+
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
1425
|
+
|
|
1426
|
+
//#endregion
|
|
1427
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.75.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
|
|
1428
|
+
var require_usingCtx = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.75.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
|
|
1429
|
+
function _usingCtx() {
|
|
1430
|
+
var r$1 = "function" == typeof SuppressedError ? SuppressedError : function(r$2, e$1) {
|
|
1431
|
+
var n$2 = Error();
|
|
1432
|
+
return n$2.name = "SuppressedError", n$2.error = r$2, n$2.suppressed = e$1, n$2;
|
|
1433
|
+
}, e = {}, n$1 = [];
|
|
1434
|
+
function using(r$2, e$1) {
|
|
1435
|
+
if (null != e$1) {
|
|
1436
|
+
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
1437
|
+
if (r$2) var o$1 = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
1438
|
+
if (void 0 === o$1 && (o$1 = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$2)) var t$1 = o$1;
|
|
1439
|
+
if ("function" != typeof o$1) throw new TypeError("Object is not disposable.");
|
|
1440
|
+
t$1 && (o$1 = function o$2() {
|
|
1441
|
+
try {
|
|
1442
|
+
t$1.call(e$1);
|
|
1443
|
+
} catch (r$3) {
|
|
1444
|
+
return Promise.reject(r$3);
|
|
1445
|
+
}
|
|
1446
|
+
}), n$1.push({
|
|
1447
|
+
v: e$1,
|
|
1448
|
+
d: o$1,
|
|
1449
|
+
a: r$2
|
|
1450
|
+
});
|
|
1451
|
+
} else r$2 && n$1.push({
|
|
1452
|
+
d: e$1,
|
|
1453
|
+
a: r$2
|
|
1454
|
+
});
|
|
1455
|
+
return e$1;
|
|
1456
|
+
}
|
|
1457
|
+
return {
|
|
1458
|
+
e,
|
|
1459
|
+
u: using.bind(null, !1),
|
|
1460
|
+
a: using.bind(null, !0),
|
|
1461
|
+
d: function d() {
|
|
1462
|
+
var o$1, t$1 = this.e, s$1 = 0;
|
|
1463
|
+
function next() {
|
|
1464
|
+
for (; o$1 = n$1.pop();) try {
|
|
1465
|
+
if (!o$1.a && 1 === s$1) return s$1 = 0, n$1.push(o$1), Promise.resolve().then(next);
|
|
1466
|
+
if (o$1.d) {
|
|
1467
|
+
var r$2 = o$1.d.call(o$1.v);
|
|
1468
|
+
if (o$1.a) return s$1 |= 2, Promise.resolve(r$2).then(next, err);
|
|
1469
|
+
} else s$1 |= 1;
|
|
1470
|
+
} catch (r$3) {
|
|
1471
|
+
return err(r$3);
|
|
1472
|
+
}
|
|
1473
|
+
if (1 === s$1) return t$1 !== e ? Promise.reject(t$1) : Promise.resolve();
|
|
1474
|
+
if (t$1 !== e) throw t$1;
|
|
1475
|
+
}
|
|
1476
|
+
function err(n$2) {
|
|
1477
|
+
return t$1 = t$1 !== e ? new r$1(n$2, t$1) : n$2, next();
|
|
1478
|
+
}
|
|
1479
|
+
return next();
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1267
1482
|
}
|
|
1483
|
+
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1484
|
+
} });
|
|
1485
|
+
|
|
1486
|
+
//#endregion
|
|
1487
|
+
//#region src/cli/commands/bundle.ts
|
|
1488
|
+
var import_usingCtx = require_chunk.__toESM(require_usingCtx(), 1);
|
|
1489
|
+
async function bundleWithConfig(configPath, cliOptions) {
|
|
1268
1490
|
if (cliOptions.watch) {
|
|
1269
|
-
|
|
1491
|
+
process.env.ROLLUP_WATCH = "true";
|
|
1492
|
+
process.env.ROLLDOWN_WATCH = "true";
|
|
1493
|
+
}
|
|
1494
|
+
const config = await require_load_config.loadConfig(configPath);
|
|
1495
|
+
if (!config) {
|
|
1496
|
+
logger.error(`No configuration found at ${config}`);
|
|
1270
1497
|
process.exit(1);
|
|
1271
1498
|
}
|
|
1272
|
-
|
|
1499
|
+
if (cliOptions.watch) await watchInner(config, cliOptions);
|
|
1500
|
+
else await bundleInner(config, cliOptions);
|
|
1501
|
+
}
|
|
1502
|
+
async function bundleWithCliOptions(cliOptions) {
|
|
1273
1503
|
try {
|
|
1504
|
+
var _usingCtx$1 = (0, import_usingCtx.default)();
|
|
1505
|
+
if (cliOptions.output.dir || cliOptions.output.file) {
|
|
1506
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
1507
|
+
await operation({}, cliOptions);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (cliOptions.watch) {
|
|
1511
|
+
logger.error("You must specify `output.dir` to use watch mode");
|
|
1512
|
+
process.exit(1);
|
|
1513
|
+
}
|
|
1514
|
+
const build = _usingCtx$1.a(await require_src.rolldown(cliOptions.input));
|
|
1274
1515
|
const { output: outputs } = await build.generate(cliOptions.output);
|
|
1275
1516
|
if (outputs.length === 0) {
|
|
1276
1517
|
logger.error("No output generated");
|
|
1277
1518
|
process.exit(1);
|
|
1278
1519
|
}
|
|
1279
1520
|
for (const file of outputs) {
|
|
1280
|
-
if (outputs.length > 1) logger.log(`\n${
|
|
1521
|
+
if (outputs.length > 1) logger.log(`\n${ansis.default.cyan(ansis.default.bold(`|→ ${file.fileName}:`))}\n`);
|
|
1281
1522
|
console.log(file.type === "asset" ? file.source : file.code);
|
|
1282
1523
|
}
|
|
1524
|
+
} catch (_$1) {
|
|
1525
|
+
_usingCtx$1.e = _$1;
|
|
1283
1526
|
} finally {
|
|
1284
|
-
await
|
|
1527
|
+
await _usingCtx$1.d();
|
|
1285
1528
|
}
|
|
1286
1529
|
}
|
|
1287
1530
|
async function watchInner(config, cliOptions) {
|
|
1288
|
-
let normalizedConfig =
|
|
1531
|
+
let normalizedConfig = require_misc.arraify(config).map((option) => {
|
|
1289
1532
|
return {
|
|
1290
1533
|
...option,
|
|
1291
1534
|
...cliOptions.input,
|
|
1292
|
-
output:
|
|
1535
|
+
output: require_misc.arraify(option.output || {}).map((output) => {
|
|
1293
1536
|
return {
|
|
1294
1537
|
...output,
|
|
1295
1538
|
...cliOptions.output
|
|
@@ -1308,16 +1551,18 @@ async function watchInner(config, cliOptions) {
|
|
|
1308
1551
|
watcher.on("change", (id, event) => {
|
|
1309
1552
|
if (event.event === "update") changedFile.push(id);
|
|
1310
1553
|
});
|
|
1311
|
-
watcher.on("event", (event) => {
|
|
1554
|
+
watcher.on("event", async (event) => {
|
|
1312
1555
|
switch (event.code) {
|
|
1313
1556
|
case "BUNDLE_START":
|
|
1314
|
-
if (changedFile.length > 0) logger.log(`Found ${
|
|
1557
|
+
if (changedFile.length > 0) logger.log(`Found ${ansis.default.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
1315
1558
|
changedFile.length = 0;
|
|
1316
1559
|
break;
|
|
1317
1560
|
case "BUNDLE_END":
|
|
1318
|
-
|
|
1561
|
+
await event.result.close();
|
|
1562
|
+
logger.success(`Rebuilt ${ansis.default.bold(relativeId(event.output[0]))} in ${ansis.default.bold(ms(event.duration))}.`);
|
|
1319
1563
|
break;
|
|
1320
1564
|
case "ERROR":
|
|
1565
|
+
await event.result.close();
|
|
1321
1566
|
logger.error(event.error);
|
|
1322
1567
|
break;
|
|
1323
1568
|
default: break;
|
|
@@ -1328,9 +1573,9 @@ async function watchInner(config, cliOptions) {
|
|
|
1328
1573
|
async function bundleInner(config, cliOptions) {
|
|
1329
1574
|
const startTime = node_perf_hooks.performance.now();
|
|
1330
1575
|
const result = [];
|
|
1331
|
-
const configList =
|
|
1576
|
+
const configList = require_misc.arraify(config);
|
|
1332
1577
|
for (const config$1 of configList) {
|
|
1333
|
-
const outputList =
|
|
1578
|
+
const outputList = require_misc.arraify(config$1.output || {});
|
|
1334
1579
|
const build = await require_src.rolldown({
|
|
1335
1580
|
...config$1,
|
|
1336
1581
|
...cliOptions.input
|
|
@@ -1348,7 +1593,7 @@ async function bundleInner(config, cliOptions) {
|
|
|
1348
1593
|
logger.log(``);
|
|
1349
1594
|
const endTime = node_perf_hooks.performance.now();
|
|
1350
1595
|
const duration = endTime - startTime;
|
|
1351
|
-
logger.success(`Finished in ${
|
|
1596
|
+
logger.success(`Finished in ${ansis.default.bold(ms(duration))}`);
|
|
1352
1597
|
}
|
|
1353
1598
|
function printBundleOutputPretty(output) {
|
|
1354
1599
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -1359,7 +1604,7 @@ function collectOutputEntries(output) {
|
|
|
1359
1604
|
return output.map((chunk) => ({
|
|
1360
1605
|
type: chunk.type,
|
|
1361
1606
|
fileName: chunk.fileName,
|
|
1362
|
-
size: chunk.type === "chunk" ? chunk.code
|
|
1607
|
+
size: chunk.type === "chunk" ? Buffer.byteLength(chunk.code) : Buffer.byteLength(chunk.source)
|
|
1363
1608
|
}));
|
|
1364
1609
|
}
|
|
1365
1610
|
function collectOutputLayoutAdjustmentSizes(entries) {
|
|
@@ -1395,17 +1640,17 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
1395
1640
|
const filtered = entries.filter((e) => e.type === group.type);
|
|
1396
1641
|
if (!filtered.length) continue;
|
|
1397
1642
|
for (const entry of filtered.sort((a$1, z) => a$1.size - z.size)) {
|
|
1398
|
-
let log =
|
|
1399
|
-
log +=
|
|
1400
|
-
log +=
|
|
1401
|
-
log +=
|
|
1643
|
+
let log = ansis.default.dim(withTrailingSlash(distPath));
|
|
1644
|
+
log += ansis.default[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
1645
|
+
log += ansis.default.dim(entry.type);
|
|
1646
|
+
log += ansis.default.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
1402
1647
|
logger.log(log);
|
|
1403
1648
|
}
|
|
1404
1649
|
}
|
|
1405
1650
|
}
|
|
1406
|
-
function withTrailingSlash(path$
|
|
1407
|
-
if (path$
|
|
1408
|
-
return path$
|
|
1651
|
+
function withTrailingSlash(path$1) {
|
|
1652
|
+
if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
|
|
1653
|
+
return path$1;
|
|
1409
1654
|
}
|
|
1410
1655
|
function ms(duration) {
|
|
1411
1656
|
return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
|
|
@@ -1415,229 +1660,11 @@ function relativeId(id) {
|
|
|
1415
1660
|
return node_path.default.relative(node_path.default.resolve(), id);
|
|
1416
1661
|
}
|
|
1417
1662
|
|
|
1418
|
-
//#endregion
|
|
1419
|
-
//#region src/cli/arguments/alias.ts
|
|
1420
|
-
const alias = {
|
|
1421
|
-
config: {
|
|
1422
|
-
abbreviation: "c",
|
|
1423
|
-
hint: "filename"
|
|
1424
|
-
},
|
|
1425
|
-
help: { abbreviation: "h" },
|
|
1426
|
-
version: { abbreviation: "v" },
|
|
1427
|
-
watch: { abbreviation: "w" },
|
|
1428
|
-
dir: { abbreviation: "d" },
|
|
1429
|
-
file: { abbreviation: "o" },
|
|
1430
|
-
external: { abbreviation: "e" },
|
|
1431
|
-
format: { abbreviation: "f" },
|
|
1432
|
-
name: { abbreviation: "n" },
|
|
1433
|
-
globals: { abbreviation: "g" },
|
|
1434
|
-
sourcemap: {
|
|
1435
|
-
abbreviation: "s",
|
|
1436
|
-
default: true
|
|
1437
|
-
},
|
|
1438
|
-
minify: { abbreviation: "m" },
|
|
1439
|
-
platform: { abbreviation: "p" },
|
|
1440
|
-
assetFileNames: { hint: "name" },
|
|
1441
|
-
chunkFileNames: { hint: "name" },
|
|
1442
|
-
entryFileNames: { hint: "name" },
|
|
1443
|
-
externalLiveBindings: {
|
|
1444
|
-
default: true,
|
|
1445
|
-
reverse: true
|
|
1446
|
-
},
|
|
1447
|
-
treeshake: {
|
|
1448
|
-
default: true,
|
|
1449
|
-
reverse: true
|
|
1450
|
-
},
|
|
1451
|
-
moduleTypes: { hint: "types" }
|
|
1452
|
-
};
|
|
1453
|
-
|
|
1454
|
-
//#endregion
|
|
1455
|
-
//#region src/cli/arguments/utils.ts
|
|
1456
|
-
const priority = [
|
|
1457
|
-
"object",
|
|
1458
|
-
"array",
|
|
1459
|
-
"string",
|
|
1460
|
-
"number",
|
|
1461
|
-
"boolean"
|
|
1462
|
-
];
|
|
1463
|
-
function getSchemaType(schema) {
|
|
1464
|
-
if ("anyOf" in schema) {
|
|
1465
|
-
const types = schema.anyOf.map(getSchemaType);
|
|
1466
|
-
let result = priority.find((type) => types.includes(type));
|
|
1467
|
-
if (result) return result;
|
|
1468
|
-
}
|
|
1469
|
-
if ("type" in schema) return schema.type;
|
|
1470
|
-
if ("const" in schema) return typeof schema.const;
|
|
1471
|
-
return "object";
|
|
1472
|
-
}
|
|
1473
|
-
function flattenSchema(schema, base = {}, parent = "") {
|
|
1474
|
-
if (schema === undefined) return base;
|
|
1475
|
-
for (const [k, value] of Object.entries(schema)) {
|
|
1476
|
-
const key = parent ? `${parent}.${k}` : k;
|
|
1477
|
-
if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
|
|
1478
|
-
else base[key] = value;
|
|
1479
|
-
else base[key] = value;
|
|
1480
|
-
}
|
|
1481
|
-
return base;
|
|
1482
|
-
}
|
|
1483
|
-
function setNestedProperty(obj, path$2, value) {
|
|
1484
|
-
const keys = path$2.split(".");
|
|
1485
|
-
let current = obj;
|
|
1486
|
-
for (let i$1 = 0; i$1 < keys.length - 1; i$1++) {
|
|
1487
|
-
if (!current[keys[i$1]]) current[keys[i$1]] = {};
|
|
1488
|
-
current = current[keys[i$1]];
|
|
1489
|
-
}
|
|
1490
|
-
const finalKey = keys[keys.length - 1];
|
|
1491
|
-
Object.defineProperty(current, finalKey, {
|
|
1492
|
-
value,
|
|
1493
|
-
writable: true,
|
|
1494
|
-
enumerable: true,
|
|
1495
|
-
configurable: true
|
|
1496
|
-
});
|
|
1497
|
-
}
|
|
1498
|
-
function camelCaseToKebabCase(str) {
|
|
1499
|
-
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1500
|
-
}
|
|
1501
|
-
function kebabCaseToCamelCase(str) {
|
|
1502
|
-
return str.replace(/-./g, (match) => match[1].toUpperCase());
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
//#endregion
|
|
1506
|
-
//#region src/cli/arguments/normalize.ts
|
|
1507
|
-
function normalizeCliOptions(cliOptions, positionals) {
|
|
1508
|
-
const [data, errors] = require_src.validateCliOptions(cliOptions);
|
|
1509
|
-
if (errors?.length) {
|
|
1510
|
-
errors.forEach((error) => {
|
|
1511
|
-
logger.error(`Invalid value for option ${error}. You can use \`rolldown -h\` to see the help.`);
|
|
1512
|
-
});
|
|
1513
|
-
process.exit(1);
|
|
1514
|
-
}
|
|
1515
|
-
const options$1 = data ?? {};
|
|
1516
|
-
const result = {
|
|
1517
|
-
input: {},
|
|
1518
|
-
output: {},
|
|
1519
|
-
help: options$1.help ?? false,
|
|
1520
|
-
version: options$1.version ?? false,
|
|
1521
|
-
watch: options$1.watch ?? false
|
|
1522
|
-
};
|
|
1523
|
-
if (typeof options$1.config === "string") result.config = options$1.config;
|
|
1524
|
-
const keysOfInput = require_src.getInputCliKeys();
|
|
1525
|
-
const keysOfOutput = require_src.getOutputCliKeys();
|
|
1526
|
-
const reservedKeys = [
|
|
1527
|
-
"help",
|
|
1528
|
-
"version",
|
|
1529
|
-
"config",
|
|
1530
|
-
"watch"
|
|
1531
|
-
];
|
|
1532
|
-
for (let [key, value] of Object.entries(options$1)) {
|
|
1533
|
-
const keys = key.split(".");
|
|
1534
|
-
const [primary] = keys;
|
|
1535
|
-
if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
|
|
1536
|
-
else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
|
|
1537
|
-
else if (!reservedKeys.includes(key)) {
|
|
1538
|
-
logger.error(`Unknown option: ${key}`);
|
|
1539
|
-
process.exit(1);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
if (!result.config && positionals.length > 0) result.input.input = positionals;
|
|
1543
|
-
return result;
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
//#endregion
|
|
1547
|
-
//#region src/cli/arguments/index.ts
|
|
1548
|
-
const objectSchema = require_src.getJsonSchema();
|
|
1549
|
-
const flattenedSchema = flattenSchema(objectSchema.properties);
|
|
1550
|
-
const options = Object.fromEntries(Object.entries(flattenedSchema).map(([key, schema]) => {
|
|
1551
|
-
const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
|
|
1552
|
-
const type = getSchemaType(schema);
|
|
1553
|
-
const result = {
|
|
1554
|
-
type: type === "boolean" ? "boolean" : "string",
|
|
1555
|
-
description: schema?.description ?? config?.description ?? "",
|
|
1556
|
-
hint: config?.hint
|
|
1557
|
-
};
|
|
1558
|
-
if (config && config?.abbreviation) result.short = config?.abbreviation;
|
|
1559
|
-
if (config && config.reverse) if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
|
|
1560
|
-
else result.description = `disable ${result.description}`;
|
|
1561
|
-
key = camelCaseToKebabCase(key);
|
|
1562
|
-
return [config?.reverse ? `no-${key}` : key, result];
|
|
1563
|
-
}));
|
|
1564
|
-
function parseCliArguments() {
|
|
1565
|
-
const { values, tokens, positionals } = (0, node_util.parseArgs)({
|
|
1566
|
-
options,
|
|
1567
|
-
tokens: true,
|
|
1568
|
-
allowPositionals: true,
|
|
1569
|
-
strict: false
|
|
1570
|
-
});
|
|
1571
|
-
tokens.filter((token) => token.kind === "option").forEach((option) => {
|
|
1572
|
-
let negative = false;
|
|
1573
|
-
if (option.name.startsWith("no-")) {
|
|
1574
|
-
const name = kebabCaseToCamelCase(option.name.substring(3));
|
|
1575
|
-
if (name in flattenedSchema) {
|
|
1576
|
-
delete values[option.name];
|
|
1577
|
-
option.name = name;
|
|
1578
|
-
negative = true;
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
delete values[option.name];
|
|
1582
|
-
option.name = kebabCaseToCamelCase(option.name);
|
|
1583
|
-
let originalType = flattenedSchema[option.name];
|
|
1584
|
-
if (!originalType) {
|
|
1585
|
-
logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
|
|
1586
|
-
process.exit(1);
|
|
1587
|
-
}
|
|
1588
|
-
let type = getSchemaType(originalType);
|
|
1589
|
-
if (type === "string" && typeof option.value !== "string") {
|
|
1590
|
-
let opt = option;
|
|
1591
|
-
let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
|
|
1592
|
-
Object.defineProperty(values, opt.name, {
|
|
1593
|
-
value: defaultValue.default ?? "",
|
|
1594
|
-
enumerable: true,
|
|
1595
|
-
configurable: true,
|
|
1596
|
-
writable: true
|
|
1597
|
-
});
|
|
1598
|
-
} else if (type === "object" && typeof option.value === "string") {
|
|
1599
|
-
const [key, value] = option.value.split(",").map((x) => x.split("="))[0];
|
|
1600
|
-
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
1601
|
-
value: {},
|
|
1602
|
-
enumerable: true,
|
|
1603
|
-
configurable: true,
|
|
1604
|
-
writable: true
|
|
1605
|
-
});
|
|
1606
|
-
if (key && value) Object.defineProperty(values[option.name], key, {
|
|
1607
|
-
value,
|
|
1608
|
-
enumerable: true,
|
|
1609
|
-
configurable: true,
|
|
1610
|
-
writable: true
|
|
1611
|
-
});
|
|
1612
|
-
} else if (type === "array" && typeof option.value === "string") {
|
|
1613
|
-
if (!values[option.name]) Object.defineProperty(values, option.name, {
|
|
1614
|
-
value: [],
|
|
1615
|
-
enumerable: true,
|
|
1616
|
-
configurable: true,
|
|
1617
|
-
writable: true
|
|
1618
|
-
});
|
|
1619
|
-
values[option.name].push(option.value);
|
|
1620
|
-
} else if (type === "boolean") Object.defineProperty(values, option.name, {
|
|
1621
|
-
value: !negative,
|
|
1622
|
-
enumerable: true,
|
|
1623
|
-
configurable: true,
|
|
1624
|
-
writable: true
|
|
1625
|
-
});
|
|
1626
|
-
else Object.defineProperty(values, option.name, {
|
|
1627
|
-
value: option.value ?? "",
|
|
1628
|
-
enumerable: true,
|
|
1629
|
-
configurable: true,
|
|
1630
|
-
writable: true
|
|
1631
|
-
});
|
|
1632
|
-
});
|
|
1633
|
-
return normalizeCliOptions(values, positionals);
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
1663
|
//#endregion
|
|
1637
1664
|
//#region src/cli/commands/help.ts
|
|
1638
|
-
const introduction = `${
|
|
1665
|
+
const introduction = `${ansis.default.gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
1639
1666
|
|
|
1640
|
-
${
|
|
1667
|
+
${ansis.default.bold(ansis.default.underline("USAGE"))} ${ansis.default.cyan("rolldown -c <config>")} or ${ansis.default.cyan("rolldown <input> <options>")}`;
|
|
1641
1668
|
const examples = [
|
|
1642
1669
|
{
|
|
1643
1670
|
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
@@ -1669,33 +1696,33 @@ const notes = [
|
|
|
1669
1696
|
function showHelp() {
|
|
1670
1697
|
logger.log(introduction);
|
|
1671
1698
|
logger.log("");
|
|
1672
|
-
logger.log(`${
|
|
1699
|
+
logger.log(`${ansis.default.bold(ansis.default.underline("OPTIONS"))}`);
|
|
1673
1700
|
logger.log("");
|
|
1674
|
-
logger.log(Object.entries(options).sort(([a$1], [b]) => {
|
|
1675
|
-
if (options[a$1].short && !options[b].short) return -1;
|
|
1676
|
-
if (!options[a$1].short && options[b].short) return 1;
|
|
1677
|
-
if (options[a$1].short && options[b].short) return options[a$1].short.localeCompare(options[b].short);
|
|
1678
|
-
return a$1.localeCompare(b);
|
|
1701
|
+
logger.log(Object.entries(options).sort(([a$1], [b$1]) => {
|
|
1702
|
+
if (options[a$1].short && !options[b$1].short) return -1;
|
|
1703
|
+
if (!options[a$1].short && options[b$1].short) return 1;
|
|
1704
|
+
if (options[a$1].short && options[b$1].short) return options[a$1].short.localeCompare(options[b$1].short);
|
|
1705
|
+
return a$1.localeCompare(b$1);
|
|
1679
1706
|
}).map(([option, { type, short, hint, description: description$1 }]) => {
|
|
1680
1707
|
let optionStr = ` --${option} `;
|
|
1681
1708
|
option = camelCaseToKebabCase(option);
|
|
1682
1709
|
if (short) optionStr += `-${short}, `;
|
|
1683
1710
|
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
1684
1711
|
if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
|
|
1685
|
-
return
|
|
1712
|
+
return ansis.default.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1686
1713
|
}).join("\n"));
|
|
1687
1714
|
logger.log("");
|
|
1688
|
-
logger.log(`${
|
|
1715
|
+
logger.log(`${ansis.default.bold(ansis.default.underline("EXAMPLES"))}`);
|
|
1689
1716
|
logger.log("");
|
|
1690
1717
|
examples.forEach(({ title, command }, ord) => {
|
|
1691
1718
|
logger.log(` ${ord + 1}. ${title}:`);
|
|
1692
|
-
logger.log(` ${
|
|
1719
|
+
logger.log(` ${ansis.default.cyan(command)}`);
|
|
1693
1720
|
logger.log("");
|
|
1694
1721
|
});
|
|
1695
|
-
logger.log(`${
|
|
1722
|
+
logger.log(`${ansis.default.bold(ansis.default.underline("NOTES"))}`);
|
|
1696
1723
|
logger.log("");
|
|
1697
1724
|
notes.forEach((note) => {
|
|
1698
|
-
logger.log(` * ${
|
|
1725
|
+
logger.log(` * ${ansis.default.gray(note)}`);
|
|
1699
1726
|
});
|
|
1700
1727
|
}
|
|
1701
1728
|
|
|
@@ -1718,7 +1745,7 @@ async function main() {
|
|
|
1718
1745
|
showHelp();
|
|
1719
1746
|
}
|
|
1720
1747
|
main().catch((err) => {
|
|
1721
|
-
|
|
1748
|
+
logger.error(err);
|
|
1722
1749
|
node_process.default.exit(1);
|
|
1723
1750
|
});
|
|
1724
1751
|
|