rolldown 0.14.0-snapshot-d42ea8a-20241202003632 → 0.15.0-commit.ac58858
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/cjs/cli.cjs +189 -175
- package/dist/cjs/experimental-index.cjs +12 -3
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/parallel-plugin-worker.cjs +2 -2
- package/dist/esm/cli.mjs +282 -268
- package/dist/esm/experimental-index.mjs +10 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{chunk-BK2Ye-xa.cjs → chunk-BFvIen8E.cjs} +0 -11
- package/dist/shared/{consola_36c0034f-_8_dG1Nr.cjs → consola_36c0034f-B7L-radJ.cjs} +2 -2
- package/dist/shared/{consola_36c0034f-DWsVjwtA.mjs → consola_36c0034f-D9ce-831.mjs} +10 -10
- package/dist/shared/{prompt-RFvZMmjc.cjs → prompt-BiXtYIJ2.cjs} +3 -3
- package/dist/shared/{prompt-DGW8ZJmn.mjs → prompt-DlQ-08lk.mjs} +2 -2
- package/dist/shared/{src-CfQyqNSn.cjs → src-Bs7g4_us.cjs} +227 -121
- package/dist/shared/{src-DhHfkqAC.mjs → src-C-NQjnqV.mjs} +226 -136
- package/dist/tsconfig.dts.tsbuildinfo +1 -0
- package/dist/types/api/build.d.ts +16 -0
- package/dist/types/api/experimental.d.ts +7 -0
- package/dist/types/api/rolldown/index.d.ts +3 -0
- package/dist/types/{rolldown-build.d.ts → api/rolldown/rolldown-build.d.ts} +3 -3
- package/dist/types/api/watch/index.d.ts +3 -0
- package/dist/types/{watcher.d.ts → api/watch/watch-emitter.d.ts} +15 -17
- package/dist/types/api/watch/watcher.d.ts +13 -0
- package/dist/types/binding.d.ts +108 -15
- package/dist/types/builtin-plugin/constructors.d.ts +1 -5
- package/dist/types/cli/arguments/index.d.ts +5 -3
- package/dist/types/cli/arguments/schema.d.ts +10 -397
- package/dist/types/cli/colors.d.ts +11 -1
- package/dist/types/cli/utils.d.ts +2 -1
- package/dist/types/constants/plugin.d.ts +8 -1
- package/dist/types/experimental-index.d.ts +1 -1
- package/dist/types/index.d.ts +8 -6
- package/dist/types/log/logging.d.ts +6 -6
- package/dist/types/log/logs.d.ts +1 -0
- package/dist/types/options/input-options-schema.d.ts +3 -595
- package/dist/types/options/input-options.d.ts +16 -1
- package/dist/types/options/normalized-input-options.d.ts +1 -1
- package/dist/types/options/normalized-output-options.d.ts +20 -17
- package/dist/types/options/output-options-schema.d.ts +2 -146
- package/dist/types/options/output-options.d.ts +1 -0
- package/dist/types/plugin/plugin-context-data.d.ts +2 -1
- package/dist/types/rollup.d.ts +4 -0
- package/dist/types/treeshake/module-side-effects.d.ts +14 -115
- package/dist/types/types/rolldown-output.d.ts +6 -0
- package/dist/types/utils/bindingify-input-options.d.ts +1 -1
- package/dist/types/utils/create-bundler-option.d.ts +11 -0
- package/dist/types/utils/error.d.ts +2 -1
- package/dist/types/utils/misc.d.ts +1 -0
- package/dist/types/utils/transform-sourcemap.d.ts +1 -1
- package/dist/types/utils/zod-ext.d.ts +6 -5
- package/package.json +15 -15
- package/dist/types/log/locate-character/index.d.ts +0 -13
- package/dist/types/rolldown.d.ts +0 -12
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,140 +1,13 @@
|
|
|
1
|
-
import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema,
|
|
2
|
-
import { createConsola } from "../shared/consola_36c0034f-
|
|
3
|
-
import { ZodFirstPartyTypeKind,
|
|
1
|
+
import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, arraify, description, rolldown, version, watch } from "../shared/src-C-NQjnqV.mjs";
|
|
2
|
+
import { createConsola } from "../shared/consola_36c0034f-D9ce-831.mjs";
|
|
3
|
+
import { ZodFirstPartyTypeKind, z } from "zod";
|
|
4
4
|
import nodePath, { default as path } from "node:path";
|
|
5
5
|
import process$1, { env } from "node:process";
|
|
6
6
|
import { performance } from "node:perf_hooks";
|
|
7
|
+
import * as tty from "tty";
|
|
7
8
|
import { pathToFileURL } from "node:url";
|
|
8
9
|
import { parseArgs } from "node:util";
|
|
9
|
-
import * as tty from "tty";
|
|
10
|
-
|
|
11
|
-
//#region src/cli/utils.ts
|
|
12
|
-
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
|
|
13
|
-
function createTestingLogger() {
|
|
14
|
-
const types = [
|
|
15
|
-
"silent",
|
|
16
|
-
"fatal",
|
|
17
|
-
"error",
|
|
18
|
-
"warn",
|
|
19
|
-
"log",
|
|
20
|
-
"info",
|
|
21
|
-
"success",
|
|
22
|
-
"fail",
|
|
23
|
-
"ready",
|
|
24
|
-
"start",
|
|
25
|
-
"box",
|
|
26
|
-
"debug",
|
|
27
|
-
"trace",
|
|
28
|
-
"verbose"
|
|
29
|
-
];
|
|
30
|
-
const ret = Object.create(null);
|
|
31
|
-
for (const type of types) ret[type] = console.log;
|
|
32
|
-
return ret;
|
|
33
|
-
}
|
|
34
|
-
async function ensureConfig(configPath) {
|
|
35
|
-
const fileUrl = pathToFileURL(configPath).toString();
|
|
36
|
-
let configExports;
|
|
37
|
-
try {
|
|
38
|
-
configExports = await import(fileUrl);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
let errorMessage = "Error happened while loading config.";
|
|
41
|
-
if (!isSupportedFormat(configPath)) errorMessage += ` Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${nodePath.extname(configPath)}\``;
|
|
42
|
-
throw new Error(errorMessage, { cause: err });
|
|
43
|
-
}
|
|
44
|
-
return configExports.default;
|
|
45
|
-
}
|
|
46
|
-
const SUPPORTED_CONFIG_FORMATS = [
|
|
47
|
-
".js",
|
|
48
|
-
".mjs",
|
|
49
|
-
".cjs"
|
|
50
|
-
];
|
|
51
|
-
/**
|
|
52
|
-
* Check whether the configuration file is supported
|
|
53
|
-
*/
|
|
54
|
-
function isSupportedFormat(configPath) {
|
|
55
|
-
const ext = nodePath.extname(configPath);
|
|
56
|
-
return SUPPORTED_CONFIG_FORMATS.includes(ext);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
61
|
-
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
62
|
-
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
63
|
-
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
64
|
-
const isWindows = platform === "win32";
|
|
65
|
-
const isDumbTerminal = env$1.TERM === "dumb";
|
|
66
|
-
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
67
|
-
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
68
|
-
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
69
|
-
const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
70
|
-
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
71
|
-
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
72
|
-
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
73
|
-
const colors = {
|
|
74
|
-
reset: init(0, 0),
|
|
75
|
-
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
76
|
-
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
77
|
-
italic: init(3, 23),
|
|
78
|
-
underline: init(4, 24),
|
|
79
|
-
inverse: init(7, 27),
|
|
80
|
-
hidden: init(8, 28),
|
|
81
|
-
strikethrough: init(9, 29),
|
|
82
|
-
black: init(30, 39),
|
|
83
|
-
red: init(31, 39),
|
|
84
|
-
green: init(32, 39),
|
|
85
|
-
yellow: init(33, 39),
|
|
86
|
-
blue: init(34, 39),
|
|
87
|
-
magenta: init(35, 39),
|
|
88
|
-
cyan: init(36, 39),
|
|
89
|
-
white: init(37, 39),
|
|
90
|
-
gray: init(90, 39),
|
|
91
|
-
bgBlack: init(40, 49),
|
|
92
|
-
bgRed: init(41, 49),
|
|
93
|
-
bgGreen: init(42, 49),
|
|
94
|
-
bgYellow: init(43, 49),
|
|
95
|
-
bgBlue: init(44, 49),
|
|
96
|
-
bgMagenta: init(45, 49),
|
|
97
|
-
bgCyan: init(46, 49),
|
|
98
|
-
bgWhite: init(47, 49),
|
|
99
|
-
blackBright: init(90, 39),
|
|
100
|
-
redBright: init(91, 39),
|
|
101
|
-
greenBright: init(92, 39),
|
|
102
|
-
yellowBright: init(93, 39),
|
|
103
|
-
blueBright: init(94, 39),
|
|
104
|
-
magentaBright: init(95, 39),
|
|
105
|
-
cyanBright: init(96, 39),
|
|
106
|
-
whiteBright: init(97, 39),
|
|
107
|
-
bgBlackBright: init(100, 49),
|
|
108
|
-
bgRedBright: init(101, 49),
|
|
109
|
-
bgGreenBright: init(102, 49),
|
|
110
|
-
bgYellowBright: init(103, 49),
|
|
111
|
-
bgBlueBright: init(104, 49),
|
|
112
|
-
bgMagentaBright: init(105, 49),
|
|
113
|
-
bgCyanBright: init(106, 49),
|
|
114
|
-
bgWhiteBright: init(107, 49)
|
|
115
|
-
};
|
|
116
|
-
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors : Object.keys(colors).reduce((colors$1, key) => ({
|
|
117
|
-
...colors$1,
|
|
118
|
-
[key]: String
|
|
119
|
-
}), {});
|
|
120
|
-
const { reset, bold: bold$1, dim: dim$1, italic, underline: underline$1, inverse, hidden, strikethrough, black, red: red$1, green: green$1, yellow: yellow$1, blue, magenta, cyan: cyan$1, white, gray: gray$1, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
|
|
121
|
-
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/cli/colors.ts
|
|
124
|
-
var colors_exports = {};
|
|
125
|
-
__export(colors_exports, {
|
|
126
|
-
bold: () => bold,
|
|
127
|
-
cyan: () => cyan,
|
|
128
|
-
dim: () => dim,
|
|
129
|
-
gray: () => gray,
|
|
130
|
-
green: () => green,
|
|
131
|
-
red: () => red,
|
|
132
|
-
underline: () => underline,
|
|
133
|
-
yellow: () => yellow
|
|
134
|
-
});
|
|
135
|
-
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR });
|
|
136
10
|
|
|
137
|
-
//#endregion
|
|
138
11
|
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
139
12
|
const signals = [];
|
|
140
13
|
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
@@ -306,6 +179,132 @@ var SignalExit = class extends SignalExitBase {
|
|
|
306
179
|
const process$2 = globalThis.process;
|
|
307
180
|
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
308
181
|
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
184
|
+
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
185
|
+
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
186
|
+
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
187
|
+
const isWindows = platform === "win32";
|
|
188
|
+
const isDumbTerminal = env$1.TERM === "dumb";
|
|
189
|
+
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
190
|
+
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
191
|
+
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
192
|
+
const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
193
|
+
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
194
|
+
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
195
|
+
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
196
|
+
const colors$1 = {
|
|
197
|
+
reset: init(0, 0),
|
|
198
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
199
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
200
|
+
italic: init(3, 23),
|
|
201
|
+
underline: init(4, 24),
|
|
202
|
+
inverse: init(7, 27),
|
|
203
|
+
hidden: init(8, 28),
|
|
204
|
+
strikethrough: init(9, 29),
|
|
205
|
+
black: init(30, 39),
|
|
206
|
+
red: init(31, 39),
|
|
207
|
+
green: init(32, 39),
|
|
208
|
+
yellow: init(33, 39),
|
|
209
|
+
blue: init(34, 39),
|
|
210
|
+
magenta: init(35, 39),
|
|
211
|
+
cyan: init(36, 39),
|
|
212
|
+
white: init(37, 39),
|
|
213
|
+
gray: init(90, 39),
|
|
214
|
+
bgBlack: init(40, 49),
|
|
215
|
+
bgRed: init(41, 49),
|
|
216
|
+
bgGreen: init(42, 49),
|
|
217
|
+
bgYellow: init(43, 49),
|
|
218
|
+
bgBlue: init(44, 49),
|
|
219
|
+
bgMagenta: init(45, 49),
|
|
220
|
+
bgCyan: init(46, 49),
|
|
221
|
+
bgWhite: init(47, 49),
|
|
222
|
+
blackBright: init(90, 39),
|
|
223
|
+
redBright: init(91, 39),
|
|
224
|
+
greenBright: init(92, 39),
|
|
225
|
+
yellowBright: init(93, 39),
|
|
226
|
+
blueBright: init(94, 39),
|
|
227
|
+
magentaBright: init(95, 39),
|
|
228
|
+
cyanBright: init(96, 39),
|
|
229
|
+
whiteBright: init(97, 39),
|
|
230
|
+
bgBlackBright: init(100, 49),
|
|
231
|
+
bgRedBright: init(101, 49),
|
|
232
|
+
bgGreenBright: init(102, 49),
|
|
233
|
+
bgYellowBright: init(103, 49),
|
|
234
|
+
bgBlueBright: init(104, 49),
|
|
235
|
+
bgMagentaBright: init(105, 49),
|
|
236
|
+
bgCyanBright: init(106, 49),
|
|
237
|
+
bgWhiteBright: init(107, 49)
|
|
238
|
+
};
|
|
239
|
+
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
|
|
240
|
+
...colors$2,
|
|
241
|
+
[key]: String
|
|
242
|
+
}), {});
|
|
243
|
+
const { reset, bold: bold$1, dim: dim$1, italic, underline: underline$1, inverse, hidden, strikethrough, black, red: red$1, green: green$1, yellow: yellow$1, blue, magenta, cyan: cyan$1, white, gray: gray$1, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
|
|
244
|
+
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/cli/colors.ts
|
|
247
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR });
|
|
248
|
+
const colors = {
|
|
249
|
+
bold,
|
|
250
|
+
cyan,
|
|
251
|
+
dim,
|
|
252
|
+
gray,
|
|
253
|
+
green,
|
|
254
|
+
red,
|
|
255
|
+
underline,
|
|
256
|
+
yellow
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/cli/utils.ts
|
|
261
|
+
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
|
|
262
|
+
function createTestingLogger() {
|
|
263
|
+
const types = [
|
|
264
|
+
"silent",
|
|
265
|
+
"fatal",
|
|
266
|
+
"error",
|
|
267
|
+
"warn",
|
|
268
|
+
"log",
|
|
269
|
+
"info",
|
|
270
|
+
"success",
|
|
271
|
+
"fail",
|
|
272
|
+
"ready",
|
|
273
|
+
"start",
|
|
274
|
+
"box",
|
|
275
|
+
"debug",
|
|
276
|
+
"trace",
|
|
277
|
+
"verbose"
|
|
278
|
+
];
|
|
279
|
+
const ret = Object.create(null);
|
|
280
|
+
for (const type of types) ret[type] = console.log;
|
|
281
|
+
return ret;
|
|
282
|
+
}
|
|
283
|
+
async function ensureConfig(configPath) {
|
|
284
|
+
const fileUrl = pathToFileURL(configPath).toString();
|
|
285
|
+
let configExports;
|
|
286
|
+
try {
|
|
287
|
+
configExports = await import(fileUrl);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
let errorMessage = "Error happened while loading config.";
|
|
290
|
+
if (!isSupportedFormat(configPath)) errorMessage += ` Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${nodePath.extname(configPath)}\``;
|
|
291
|
+
throw new Error(errorMessage, { cause: err });
|
|
292
|
+
}
|
|
293
|
+
return configExports.default;
|
|
294
|
+
}
|
|
295
|
+
const SUPPORTED_CONFIG_FORMATS = [
|
|
296
|
+
".js",
|
|
297
|
+
".mjs",
|
|
298
|
+
".cjs"
|
|
299
|
+
];
|
|
300
|
+
/**
|
|
301
|
+
* Check whether the configuration file is supported
|
|
302
|
+
*/
|
|
303
|
+
function isSupportedFormat(configPath) {
|
|
304
|
+
const ext = nodePath.extname(configPath);
|
|
305
|
+
return SUPPORTED_CONFIG_FORMATS.includes(ext);
|
|
306
|
+
}
|
|
307
|
+
|
|
309
308
|
//#endregion
|
|
310
309
|
//#region src/cli/commands/bundle.ts
|
|
311
310
|
async function bundleWithConfig(configPath, cliOptions) {
|
|
@@ -315,24 +314,33 @@ async function bundleWithConfig(configPath, cliOptions) {
|
|
|
315
314
|
process.exit(1);
|
|
316
315
|
}
|
|
317
316
|
const configList = arraify(config);
|
|
318
|
-
|
|
317
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
318
|
+
for (const config$1 of configList) await operation(config$1, cliOptions);
|
|
319
319
|
}
|
|
320
320
|
async function bundleWithCliOptions(cliOptions) {
|
|
321
|
-
if (cliOptions.output.dir)
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
process.exit(1);
|
|
328
|
-
} else if (output.length === 0) {
|
|
329
|
-
logger.error("No output generated");
|
|
330
|
-
process.exit(1);
|
|
331
|
-
} else logger.log(output[0].code);
|
|
332
|
-
} else {
|
|
321
|
+
if (cliOptions.output.dir) {
|
|
322
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
323
|
+
await operation({}, cliOptions);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (cliOptions.watch) {
|
|
333
327
|
logger.error("You must specify `output.dir` to use watch mode");
|
|
334
328
|
process.exit(1);
|
|
335
329
|
}
|
|
330
|
+
const build = await rolldown(cliOptions.input);
|
|
331
|
+
try {
|
|
332
|
+
const { output: outputs } = await build.generate(cliOptions.output);
|
|
333
|
+
if (outputs.length === 0) {
|
|
334
|
+
logger.error("No output generated");
|
|
335
|
+
process.exit(1);
|
|
336
|
+
}
|
|
337
|
+
for (const file of outputs) {
|
|
338
|
+
if (outputs.length > 1) logger.log(`\n${colors.cyan(colors.bold(`|→ ${file.fileName}:`))}\n`);
|
|
339
|
+
logger.log(file.type === "asset" ? file.source : file.code);
|
|
340
|
+
}
|
|
341
|
+
} finally {
|
|
342
|
+
await build.close();
|
|
343
|
+
}
|
|
336
344
|
}
|
|
337
345
|
async function watchInner(options$1, cliOptions) {
|
|
338
346
|
const watcher = await watch({
|
|
@@ -352,11 +360,11 @@ async function watchInner(options$1, cliOptions) {
|
|
|
352
360
|
watcher.on("event", (event) => {
|
|
353
361
|
switch (event.code) {
|
|
354
362
|
case "BUNDLE_START":
|
|
355
|
-
if (changedFile.length > 0) logger.log(`Found ${bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
363
|
+
if (changedFile.length > 0) logger.log(`Found ${colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
356
364
|
changedFile.length = 0;
|
|
357
365
|
break;
|
|
358
366
|
case "BUNDLE_END":
|
|
359
|
-
logger.success(`Rebuilt ${bold(relativeId(event.output[0]))} in ${bold(ms(event.duration))}.`);
|
|
367
|
+
logger.success(`Rebuilt ${colors.bold(relativeId(event.output[0]))} in ${colors.bold(ms(event.duration))}.`);
|
|
360
368
|
break;
|
|
361
369
|
case "ERROR":
|
|
362
370
|
logger.error(event.error);
|
|
@@ -372,15 +380,19 @@ async function bundleInner(options$1, cliOptions) {
|
|
|
372
380
|
...options$1,
|
|
373
381
|
...cliOptions.input
|
|
374
382
|
});
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
try {
|
|
384
|
+
const bundleOutput = await build.write({
|
|
385
|
+
...options$1?.output,
|
|
386
|
+
...cliOptions.output
|
|
387
|
+
});
|
|
388
|
+
const endTime = performance.now();
|
|
389
|
+
printBundleOutputPretty(bundleOutput);
|
|
390
|
+
logger.log(``);
|
|
391
|
+
const duration = endTime - startTime;
|
|
392
|
+
logger.success(`Finished in ${colors.bold(ms(duration))}`);
|
|
393
|
+
} finally {
|
|
394
|
+
await build.close();
|
|
395
|
+
}
|
|
384
396
|
}
|
|
385
397
|
function printBundleOutputPretty(output) {
|
|
386
398
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -426,11 +438,11 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
426
438
|
for (const group of CHUNK_GROUPS) {
|
|
427
439
|
const filtered = entries.filter((e) => e.type === group.type);
|
|
428
440
|
if (!filtered.length) continue;
|
|
429
|
-
for (const entry of filtered.sort((a, z$
|
|
430
|
-
let log = dim(withTrailingSlash(distPath));
|
|
431
|
-
log +=
|
|
432
|
-
log += dim(entry.type);
|
|
433
|
-
log += dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
441
|
+
for (const entry of filtered.sort((a, z$1) => a.size - z$1.size)) {
|
|
442
|
+
let log = colors.dim(withTrailingSlash(distPath));
|
|
443
|
+
log += colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
444
|
+
log += colors.dim(entry.type);
|
|
445
|
+
log += colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
434
446
|
logger.log(log);
|
|
435
447
|
}
|
|
436
448
|
}
|
|
@@ -528,7 +540,7 @@ function parseAnyDef() {
|
|
|
528
540
|
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
529
541
|
function parseArrayDef(def, refs) {
|
|
530
542
|
const res = { type: "array" };
|
|
531
|
-
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind
|
|
543
|
+
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {
|
|
532
544
|
...refs,
|
|
533
545
|
currentPath: [...refs.currentPath, "items"]
|
|
534
546
|
});
|
|
@@ -937,7 +949,7 @@ else if (!inCharGroup && source[i] === "[") inCharGroup = true;
|
|
|
937
949
|
//#endregion
|
|
938
950
|
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
939
951
|
function parseRecordDef(def, refs) {
|
|
940
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
952
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
941
953
|
type: "object",
|
|
942
954
|
required: def.keyType._def.values,
|
|
943
955
|
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
@@ -961,17 +973,17 @@ function parseRecordDef(def, refs) {
|
|
|
961
973
|
}) ?? {}
|
|
962
974
|
};
|
|
963
975
|
if (refs.target === "openApi3") return schema$1;
|
|
964
|
-
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
976
|
+
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
965
977
|
const { type,...keyType } = parseStringDef(def.keyType._def, refs);
|
|
966
978
|
return {
|
|
967
979
|
...schema$1,
|
|
968
980
|
propertyNames: keyType
|
|
969
981
|
};
|
|
970
|
-
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
982
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
971
983
|
...schema$1,
|
|
972
984
|
propertyNames: { enum: def.keyType._def.values }
|
|
973
985
|
};
|
|
974
|
-
else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
986
|
+
else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
975
987
|
const { type,...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
976
988
|
return {
|
|
977
989
|
...schema$1,
|
|
@@ -1479,84 +1491,86 @@ else if (refs.target === "jsonSchema2019-09") combined.$schema = "https://json-s
|
|
|
1479
1491
|
|
|
1480
1492
|
//#endregion
|
|
1481
1493
|
//#region src/utils/zod-ext.ts
|
|
1482
|
-
const stringOrRegExp = () => z
|
|
1483
|
-
const optionalStringArray = () => z
|
|
1494
|
+
const stringOrRegExp = () => z.string().or(z.instanceof(RegExp));
|
|
1495
|
+
const optionalStringArray = () => z.string().array().optional();
|
|
1484
1496
|
const returnTrue = () => true;
|
|
1485
|
-
const phantom = () => z
|
|
1497
|
+
const phantom = () => z.custom(returnTrue);
|
|
1486
1498
|
const voidNullableWith = (t) => {
|
|
1487
1499
|
return voidNullable().or(t);
|
|
1488
1500
|
};
|
|
1489
1501
|
const voidNullable = () => {
|
|
1490
|
-
return z
|
|
1502
|
+
return z.void().or(z.null()).or(z.undefined());
|
|
1491
1503
|
};
|
|
1492
1504
|
|
|
1493
1505
|
//#endregion
|
|
1494
1506
|
//#region src/options/input-options-schema.ts
|
|
1495
|
-
const inputOptionSchema = z
|
|
1496
|
-
const externalSchema = stringOrRegExp().or(stringOrRegExp().array()).or(z
|
|
1497
|
-
const moduleTypesSchema = z
|
|
1498
|
-
const jsxOptionsSchema = z
|
|
1499
|
-
mode: z
|
|
1500
|
-
factory: z
|
|
1501
|
-
fragment: z
|
|
1502
|
-
importSource: z
|
|
1503
|
-
jsxImportSource: z
|
|
1504
|
-
refresh: z
|
|
1505
|
-
development: z
|
|
1507
|
+
const inputOptionSchema = z.string().or(z.string().array()).or(z.record(z.string()));
|
|
1508
|
+
const externalSchema = stringOrRegExp().or(stringOrRegExp().array()).or(z.function().args(z.string(), z.string().optional(), z.boolean()).returns(voidNullableWith(z.boolean())));
|
|
1509
|
+
const moduleTypesSchema = z.record(z.literal("js").or(z.literal("jsx")).or(z.literal("ts")).or(z.literal("tsx")).or(z.literal("json")).or(z.literal("text")).or(z.literal("base64")).or(z.literal("dataurl")).or(z.literal("binary")).or(z.literal("empty")).or(z.literal("css")));
|
|
1510
|
+
const jsxOptionsSchema = z.strictObject({
|
|
1511
|
+
mode: z.literal("classic").or(z.literal("automatic")).describe("Jsx transformation mode").optional(),
|
|
1512
|
+
factory: z.string().describe("Jsx element transformation").optional(),
|
|
1513
|
+
fragment: z.string().describe("Jsx fragment transformation").optional(),
|
|
1514
|
+
importSource: z.string().describe("Import the factory of element and fragment if mode is classic").optional(),
|
|
1515
|
+
jsxImportSource: z.string().describe("Import the factory of element and fragment if mode is automatic").optional(),
|
|
1516
|
+
refresh: z.boolean().describe("React refresh transformation").optional(),
|
|
1517
|
+
development: z.boolean().describe("Development specific information").optional()
|
|
1506
1518
|
});
|
|
1507
1519
|
const stringOrRegExpSchema = stringOrRegExp().or(stringOrRegExp().array());
|
|
1508
|
-
const watchOptionsSchema = z
|
|
1509
|
-
skipWrite: z
|
|
1510
|
-
notify: z
|
|
1511
|
-
pollInterval: z
|
|
1512
|
-
compareContents: z
|
|
1520
|
+
const watchOptionsSchema = z.strictObject({
|
|
1521
|
+
skipWrite: z.boolean().describe("Skip the bundle.write() step").optional(),
|
|
1522
|
+
notify: z.strictObject({
|
|
1523
|
+
pollInterval: z.number().optional(),
|
|
1524
|
+
compareContents: z.boolean().optional()
|
|
1513
1525
|
}).describe("Notify options").optional(),
|
|
1514
1526
|
include: stringOrRegExpSchema.optional(),
|
|
1515
1527
|
exclude: stringOrRegExpSchema.optional(),
|
|
1516
|
-
chokidar: z
|
|
1528
|
+
chokidar: z.any().optional()
|
|
1517
1529
|
});
|
|
1518
|
-
const
|
|
1530
|
+
const checksOptionsSchema = z.strictObject({ circularDependency: z.boolean().describe("Wether to emit warnings when detecting circular dependencies").optional() });
|
|
1531
|
+
const inputOptionsSchema = z.strictObject({
|
|
1519
1532
|
input: inputOptionSchema.optional(),
|
|
1520
1533
|
plugins: phantom().optional(),
|
|
1521
1534
|
external: externalSchema.optional(),
|
|
1522
|
-
resolve: z
|
|
1523
|
-
alias: z
|
|
1524
|
-
aliasFields: z
|
|
1535
|
+
resolve: z.strictObject({
|
|
1536
|
+
alias: z.record(z.array(z.string()).or(z.string())).optional(),
|
|
1537
|
+
aliasFields: z.array(z.array(z.string())).optional(),
|
|
1525
1538
|
conditionNames: optionalStringArray(),
|
|
1526
|
-
extensionAlias: z
|
|
1527
|
-
exportsFields: z
|
|
1539
|
+
extensionAlias: z.record(z.string(), z.array(z.string())).optional(),
|
|
1540
|
+
exportsFields: z.array(z.array(z.string())).optional(),
|
|
1528
1541
|
extensions: optionalStringArray(),
|
|
1529
1542
|
mainFields: optionalStringArray(),
|
|
1530
1543
|
mainFiles: optionalStringArray(),
|
|
1531
1544
|
modules: optionalStringArray(),
|
|
1532
|
-
symlinks: z
|
|
1533
|
-
tsconfigFilename: z
|
|
1545
|
+
symlinks: z.boolean().optional(),
|
|
1546
|
+
tsconfigFilename: z.string().optional()
|
|
1534
1547
|
}).optional(),
|
|
1535
|
-
cwd: z
|
|
1536
|
-
platform: z
|
|
1537
|
-
shimMissingExports: z
|
|
1548
|
+
cwd: z.string().describe("Current working directory").optional(),
|
|
1549
|
+
platform: z.literal("node").or(z.literal("browser")).or(z.literal("neutral")).describe(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`).optional(),
|
|
1550
|
+
shimMissingExports: z.boolean().describe(`Create shim variables for missing exports`).optional(),
|
|
1538
1551
|
treeshake: TreeshakingOptionsSchema.optional(),
|
|
1539
|
-
logLevel: LogLevelOptionSchema.describe(`Log level (${dim("silent")}, ${underline(gray("info"))}, debug, ${yellow("warn")})`).optional(),
|
|
1540
|
-
onLog: z
|
|
1541
|
-
onwarn: z
|
|
1552
|
+
logLevel: LogLevelOptionSchema.describe(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`).optional(),
|
|
1553
|
+
onLog: z.function().args(LogLevelSchema, RollupLogSchema, z.function().args(LogLevelWithErrorSchema, RollupLogWithStringSchema)).optional(),
|
|
1554
|
+
onwarn: z.function().args(RollupLogSchema, z.function().args(RollupLogWithStringSchema.or(z.function().returns(RollupLogWithStringSchema)))).optional(),
|
|
1542
1555
|
moduleTypes: moduleTypesSchema.describe("Module types for customized extensions").optional(),
|
|
1543
|
-
experimental: z
|
|
1544
|
-
enableComposingJsPlugins: z
|
|
1545
|
-
strictExecutionOrder: z
|
|
1546
|
-
disableLiveBindings: z
|
|
1547
|
-
resolveNewUrlToAsset: z
|
|
1556
|
+
experimental: z.strictObject({
|
|
1557
|
+
enableComposingJsPlugins: z.boolean().optional(),
|
|
1558
|
+
strictExecutionOrder: z.boolean().optional(),
|
|
1559
|
+
disableLiveBindings: z.boolean().optional(),
|
|
1560
|
+
resolveNewUrlToAsset: z.boolean().optional()
|
|
1548
1561
|
}).optional(),
|
|
1549
|
-
define: z
|
|
1550
|
-
inject: z
|
|
1551
|
-
profilerNames: z
|
|
1562
|
+
define: z.record(z.string()).describe("Define global variables").optional(),
|
|
1563
|
+
inject: z.record(z.string().or(z.tuple([z.string(), z.string()]))).optional(),
|
|
1564
|
+
profilerNames: z.boolean().optional(),
|
|
1552
1565
|
jsx: jsxOptionsSchema.optional(),
|
|
1553
|
-
watch: watchOptionsSchema.or(z
|
|
1554
|
-
dropLabels: z
|
|
1566
|
+
watch: watchOptionsSchema.or(z.literal(false)).optional(),
|
|
1567
|
+
dropLabels: z.array(z.string()).describe("Remove labeled statements with these label names").optional(),
|
|
1568
|
+
checks: checksOptionsSchema.optional()
|
|
1555
1569
|
});
|
|
1556
1570
|
const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
1557
|
-
external: z
|
|
1558
|
-
inject: z
|
|
1559
|
-
treeshake: z
|
|
1571
|
+
external: z.array(z.string()).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`").optional(),
|
|
1572
|
+
inject: z.record(z.string()).describe("Inject import statements on demand").optional(),
|
|
1573
|
+
treeshake: z.boolean().describe("enable treeshaking").default(true).optional()
|
|
1560
1574
|
}).omit({
|
|
1561
1575
|
input: true,
|
|
1562
1576
|
plugins: true,
|
|
@@ -1570,61 +1584,61 @@ const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
|
1570
1584
|
|
|
1571
1585
|
//#endregion
|
|
1572
1586
|
//#region src/options/output-options-schema.ts
|
|
1573
|
-
const ModuleFormatSchema = z
|
|
1574
|
-
const addonFunctionSchema = z
|
|
1575
|
-
const chunkFileNamesFunctionSchema = z
|
|
1576
|
-
const GlobalsFunctionSchema = z
|
|
1577
|
-
const outputOptionsSchema = z
|
|
1578
|
-
dir: z
|
|
1579
|
-
file: z
|
|
1580
|
-
exports: z
|
|
1581
|
-
hashCharacters: z
|
|
1587
|
+
const ModuleFormatSchema = z.literal("es").or(z.literal("cjs")).or(z.literal("esm")).or(z.literal("module")).or(z.literal("commonjs")).or(z.literal("iife")).or(z.literal("umd")).describe(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`);
|
|
1588
|
+
const addonFunctionSchema = z.function().args(phantom()).returns(z.string().or(z.promise(z.string())));
|
|
1589
|
+
const chunkFileNamesFunctionSchema = z.function().args(phantom()).returns(z.string());
|
|
1590
|
+
const GlobalsFunctionSchema = z.function().args(z.string()).returns(z.string());
|
|
1591
|
+
const outputOptionsSchema = z.strictObject({
|
|
1592
|
+
dir: z.string().describe("Output directory, defaults to `dist` if `file` is not set").optional(),
|
|
1593
|
+
file: z.string().describe("Single output file").optional(),
|
|
1594
|
+
exports: z.literal("auto").or(z.literal("named")).or(z.literal("default")).or(z.literal("none")).describe(`Specify a export mode (${colors.underline("auto")}, named, default, none)`).optional(),
|
|
1595
|
+
hashCharacters: z.literal("base64").or(z.literal("base36")).or(z.literal("hex")).describe("Use the specified character set for file hashes").optional(),
|
|
1582
1596
|
format: ModuleFormatSchema.optional(),
|
|
1583
|
-
sourcemap: z
|
|
1584
|
-
sourcemapIgnoreList: z
|
|
1597
|
+
sourcemap: z.boolean().or(z.literal("inline")).or(z.literal("hidden")).describe(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`).optional(),
|
|
1598
|
+
sourcemapIgnoreList: z.boolean().or(phantom()).optional(),
|
|
1585
1599
|
sourcemapPathTransform: phantom().optional(),
|
|
1586
|
-
banner: z
|
|
1587
|
-
footer: z
|
|
1588
|
-
intro: z
|
|
1589
|
-
outro: z
|
|
1590
|
-
extend: z
|
|
1591
|
-
esModule: z
|
|
1592
|
-
assetFileNames: z
|
|
1593
|
-
entryFileNames: z
|
|
1594
|
-
chunkFileNames: z
|
|
1595
|
-
cssEntryFileNames: z
|
|
1596
|
-
cssChunkFileNames: z
|
|
1597
|
-
minify: z
|
|
1598
|
-
name: z
|
|
1599
|
-
globals: z
|
|
1600
|
-
externalLiveBindings: z
|
|
1601
|
-
inlineDynamicImports: z
|
|
1602
|
-
advancedChunks: z
|
|
1603
|
-
minSize: z
|
|
1604
|
-
minShareCount: z
|
|
1605
|
-
groups: z
|
|
1606
|
-
name: z
|
|
1607
|
-
test: z
|
|
1608
|
-
priority: z
|
|
1609
|
-
minSize: z
|
|
1610
|
-
minShareCount: z
|
|
1600
|
+
banner: z.string().or(addonFunctionSchema).optional(),
|
|
1601
|
+
footer: z.string().or(addonFunctionSchema).optional(),
|
|
1602
|
+
intro: z.string().or(addonFunctionSchema).optional(),
|
|
1603
|
+
outro: z.string().or(addonFunctionSchema).optional(),
|
|
1604
|
+
extend: z.boolean().describe("Extend global variable defined by name in IIFE / UMD formats").optional(),
|
|
1605
|
+
esModule: z.literal("if-default-prop").or(z.boolean()).optional(),
|
|
1606
|
+
assetFileNames: z.string().describe("Name pattern for asset files").optional(),
|
|
1607
|
+
entryFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted entry chunks").optional(),
|
|
1608
|
+
chunkFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted secondary chunks").optional(),
|
|
1609
|
+
cssEntryFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css entry chunks").optional(),
|
|
1610
|
+
cssChunkFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css secondary chunks").optional(),
|
|
1611
|
+
minify: z.boolean().describe("Minify the bundled file.").optional(),
|
|
1612
|
+
name: z.string().describe("Name for UMD / IIFE format outputs").optional(),
|
|
1613
|
+
globals: z.record(z.string()).or(GlobalsFunctionSchema).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
|
|
1614
|
+
externalLiveBindings: z.boolean().describe("external live bindings").default(true).optional(),
|
|
1615
|
+
inlineDynamicImports: z.boolean().describe("Inline dynamic imports").default(false).optional(),
|
|
1616
|
+
advancedChunks: z.strictObject({
|
|
1617
|
+
minSize: z.number().optional(),
|
|
1618
|
+
minShareCount: z.number().optional(),
|
|
1619
|
+
groups: z.array(z.strictObject({
|
|
1620
|
+
name: z.string(),
|
|
1621
|
+
test: z.string().or(z.instanceof(RegExp)).optional(),
|
|
1622
|
+
priority: z.number().optional(),
|
|
1623
|
+
minSize: z.number().optional(),
|
|
1624
|
+
minShareCount: z.number().optional()
|
|
1611
1625
|
})).optional()
|
|
1612
1626
|
}).optional(),
|
|
1613
|
-
comments: z
|
|
1627
|
+
comments: z.enum(["none", "preserve-legal"]).describe("Control comments in the output").optional()
|
|
1614
1628
|
});
|
|
1615
1629
|
const getAddonDescription = (placement, wrapper) => {
|
|
1616
|
-
return `Code to insert the ${bold(placement)} of the bundled file (${bold(wrapper)} the wrapper function)`;
|
|
1630
|
+
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
1617
1631
|
};
|
|
1618
1632
|
const outputCliOptionsSchema = outputOptionsSchema.extend({
|
|
1619
|
-
banner: z
|
|
1620
|
-
footer: z
|
|
1621
|
-
intro: z
|
|
1622
|
-
outro: z
|
|
1623
|
-
esModule: z
|
|
1624
|
-
globals: z
|
|
1625
|
-
advancedChunks: z
|
|
1626
|
-
minSize: z
|
|
1627
|
-
minShareCount: z
|
|
1633
|
+
banner: z.string().describe(getAddonDescription("top", "outside")).optional(),
|
|
1634
|
+
footer: z.string().describe(getAddonDescription("bottom", "outside")).optional(),
|
|
1635
|
+
intro: z.string().describe(getAddonDescription("top", "inside")).optional(),
|
|
1636
|
+
outro: z.string().describe(getAddonDescription("bottom", "inside")).optional(),
|
|
1637
|
+
esModule: z.boolean().describe("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)").optional(),
|
|
1638
|
+
globals: z.record(z.string()).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
|
|
1639
|
+
advancedChunks: z.strictObject({
|
|
1640
|
+
minSize: z.number().describe("Minimum size of the chunk").optional(),
|
|
1641
|
+
minShareCount: z.number().describe("Minimum share count of the chunk").optional()
|
|
1628
1642
|
}).optional()
|
|
1629
1643
|
}).omit({
|
|
1630
1644
|
sourcemapPathTransform: true,
|
|
@@ -1855,9 +1869,9 @@ else Object.defineProperty(values, option.name, {
|
|
|
1855
1869
|
|
|
1856
1870
|
//#endregion
|
|
1857
1871
|
//#region src/cli/commands/help.ts
|
|
1858
|
-
const introduction = `${gray(`${description} (rolldown v${version})`)}
|
|
1872
|
+
const introduction = `${colors.gray(`${description} (rolldown v${version})`)}
|
|
1859
1873
|
|
|
1860
|
-
${bold(underline("USAGE"))} ${cyan("rolldown -c <config>")} or ${cyan("rolldown <input> <options>")}`;
|
|
1874
|
+
${colors.bold(colors.underline("USAGE"))} ${colors.cyan("rolldown -c <config>")} or ${colors.cyan("rolldown <input> <options>")}`;
|
|
1861
1875
|
const examples = [
|
|
1862
1876
|
{
|
|
1863
1877
|
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
@@ -1889,7 +1903,7 @@ const notes = [
|
|
|
1889
1903
|
function showHelp() {
|
|
1890
1904
|
logger.log(introduction);
|
|
1891
1905
|
logger.log("");
|
|
1892
|
-
logger.log(`${bold(underline("OPTIONS"))}`);
|
|
1906
|
+
logger.log(`${colors.bold(colors.underline("OPTIONS"))}`);
|
|
1893
1907
|
logger.log("");
|
|
1894
1908
|
logger.log(Object.entries(options).sort(([a], [b]) => {
|
|
1895
1909
|
if (options[a].short && !options[b].short) return -1;
|
|
@@ -1902,20 +1916,20 @@ function showHelp() {
|
|
|
1902
1916
|
if (short) optionStr += `-${short}, `;
|
|
1903
1917
|
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
1904
1918
|
if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
|
|
1905
|
-
return cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1919
|
+
return colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1906
1920
|
}).join("\n"));
|
|
1907
1921
|
logger.log("");
|
|
1908
|
-
logger.log(`${bold(underline("EXAMPLES"))}`);
|
|
1922
|
+
logger.log(`${colors.bold(colors.underline("EXAMPLES"))}`);
|
|
1909
1923
|
logger.log("");
|
|
1910
1924
|
examples.forEach(({ title, command }, ord) => {
|
|
1911
1925
|
logger.log(` ${ord + 1}. ${title}:`);
|
|
1912
|
-
logger.log(` ${cyan(command)}`);
|
|
1926
|
+
logger.log(` ${colors.cyan(command)}`);
|
|
1913
1927
|
logger.log("");
|
|
1914
1928
|
});
|
|
1915
|
-
logger.log(`${bold(underline("NOTES"))}`);
|
|
1929
|
+
logger.log(`${colors.bold(colors.underline("NOTES"))}`);
|
|
1916
1930
|
logger.log("");
|
|
1917
1931
|
notes.forEach((note) => {
|
|
1918
|
-
logger.log(` * ${gray(note)}`);
|
|
1932
|
+
logger.log(` * ${colors.gray(note)}`);
|
|
1919
1933
|
});
|
|
1920
1934
|
}
|
|
1921
1935
|
|