rolldown 0.15.0 → 0.15.1-commit.09cccaf
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 +249 -183
- package/dist/cjs/experimental-index.cjs +2 -2
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/parallel-plugin-worker.cjs +2 -2
- package/dist/esm/cli.mjs +343 -277
- package/dist/esm/experimental-index.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- 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-COU7qQBJ.cjs → src-BKghi7SX.cjs} +321 -216
- package/dist/shared/{src-DEPa5yhI.mjs → src-BKlslLnW.mjs} +332 -233
- package/dist/tsconfig.dts.tsbuildinfo +1 -0
- package/dist/types/api/build.d.ts +2 -0
- package/dist/types/api/watch/index.d.ts +2 -2
- package/dist/types/api/watch/watch-emitter.d.ts +31 -0
- package/dist/types/api/watch/watcher.d.ts +7 -27
- package/dist/types/binding.d.ts +114 -19
- 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/load-config.d.ts +3 -0
- package/dist/types/cli/logger.d.ts +5 -0
- package/dist/types/constants/plugin.d.ts +8 -1
- package/dist/types/index.d.ts +4 -5
- package/dist/types/log/logHandler.d.ts +1 -1
- package/dist/types/log/logger.d.ts +1 -1
- package/dist/types/log/logging.d.ts +6 -6
- package/dist/types/log/logs.d.ts +3 -1
- package/dist/types/options/input-options-schema.d.ts +3 -595
- package/dist/types/options/input-options.d.ts +26 -3
- package/dist/types/options/normalized-input-options.d.ts +2 -2
- package/dist/types/options/normalized-output-options.d.ts +22 -18
- package/dist/types/options/output-options-schema.d.ts +2 -146
- package/dist/types/options/output-options.d.ts +4 -3
- package/dist/types/plugin/bindingify-plugin.d.ts +1 -1
- package/dist/types/plugin/index.d.ts +6 -6
- package/dist/types/plugin/minimal-plugin-context.d.ts +4 -4
- package/dist/types/plugin/plugin-context-data.d.ts +2 -1
- package/dist/types/plugin/plugin-context.d.ts +15 -11
- package/dist/types/plugin/transform-plugin-context.d.ts +8 -5
- package/dist/types/treeshake/module-side-effects.d.ts +14 -115
- package/dist/types/types/misc.d.ts +40 -0
- package/dist/types/types/module-info.d.ts +1 -0
- package/dist/types/types/output-bundle.d.ts +2 -2
- package/dist/types/types/rolldown-output.d.ts +14 -11
- package/dist/types/utils/bindingify-input-options.d.ts +2 -2
- 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 -1
- package/dist/types/utils/normalize-plugin-option.d.ts +1 -1
- package/dist/types/utils/transform-rendered-chunk.d.ts +4 -4
- package/dist/types/utils/transform-rendered-module.d.ts +2 -2
- package/dist/types/utils/transform-sourcemap.d.ts +1 -1
- package/dist/types/utils/zod-ext.d.ts +6 -5
- package/package.json +17 -17
- package/dist/types/cli/utils.d.ts +0 -6
- package/dist/types/log/locate-character/index.d.ts +0 -13
- package/dist/types/rollup-types.d.ts +0 -1
- package/dist/types/rollup.d.ts +0 -1114
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,140 +1,14 @@
|
|
|
1
|
-
import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema,
|
|
2
|
-
import { createConsola } from "../shared/consola_36c0034f-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, arraify, description, rolldown, version, watch } from "../shared/src-BKlslLnW.mjs";
|
|
2
|
+
import { createConsola } from "../shared/consola_36c0034f-D9ce-831.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { ZodFirstPartyTypeKind, z } from "zod";
|
|
5
|
+
import path, { default as path$1 } from "node:path";
|
|
5
6
|
import process$1, { env } from "node:process";
|
|
6
7
|
import { performance } from "node:perf_hooks";
|
|
7
|
-
import { pathToFileURL } from "node:url";
|
|
8
|
-
import { parseArgs } from "node:util";
|
|
9
8
|
import * as tty from "tty";
|
|
9
|
+
import { parseArgs } from "node:util";
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
10
11
|
|
|
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
|
-
|
|
137
|
-
//#endregion
|
|
138
12
|
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
139
13
|
const signals = [];
|
|
140
14
|
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
@@ -306,38 +180,224 @@ var SignalExit = class extends SignalExitBase {
|
|
|
306
180
|
const process$2 = globalThis.process;
|
|
307
181
|
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
308
182
|
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
185
|
+
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
186
|
+
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
187
|
+
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
188
|
+
const isWindows = platform === "win32";
|
|
189
|
+
const isDumbTerminal = env$1.TERM === "dumb";
|
|
190
|
+
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
191
|
+
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
192
|
+
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
193
|
+
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));
|
|
194
|
+
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
195
|
+
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
196
|
+
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
197
|
+
const colors$1 = {
|
|
198
|
+
reset: init(0, 0),
|
|
199
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
200
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
201
|
+
italic: init(3, 23),
|
|
202
|
+
underline: init(4, 24),
|
|
203
|
+
inverse: init(7, 27),
|
|
204
|
+
hidden: init(8, 28),
|
|
205
|
+
strikethrough: init(9, 29),
|
|
206
|
+
black: init(30, 39),
|
|
207
|
+
red: init(31, 39),
|
|
208
|
+
green: init(32, 39),
|
|
209
|
+
yellow: init(33, 39),
|
|
210
|
+
blue: init(34, 39),
|
|
211
|
+
magenta: init(35, 39),
|
|
212
|
+
cyan: init(36, 39),
|
|
213
|
+
white: init(37, 39),
|
|
214
|
+
gray: init(90, 39),
|
|
215
|
+
bgBlack: init(40, 49),
|
|
216
|
+
bgRed: init(41, 49),
|
|
217
|
+
bgGreen: init(42, 49),
|
|
218
|
+
bgYellow: init(43, 49),
|
|
219
|
+
bgBlue: init(44, 49),
|
|
220
|
+
bgMagenta: init(45, 49),
|
|
221
|
+
bgCyan: init(46, 49),
|
|
222
|
+
bgWhite: init(47, 49),
|
|
223
|
+
blackBright: init(90, 39),
|
|
224
|
+
redBright: init(91, 39),
|
|
225
|
+
greenBright: init(92, 39),
|
|
226
|
+
yellowBright: init(93, 39),
|
|
227
|
+
blueBright: init(94, 39),
|
|
228
|
+
magentaBright: init(95, 39),
|
|
229
|
+
cyanBright: init(96, 39),
|
|
230
|
+
whiteBright: init(97, 39),
|
|
231
|
+
bgBlackBright: init(100, 49),
|
|
232
|
+
bgRedBright: init(101, 49),
|
|
233
|
+
bgGreenBright: init(102, 49),
|
|
234
|
+
bgYellowBright: init(103, 49),
|
|
235
|
+
bgBlueBright: init(104, 49),
|
|
236
|
+
bgMagentaBright: init(105, 49),
|
|
237
|
+
bgCyanBright: init(106, 49),
|
|
238
|
+
bgWhiteBright: init(107, 49)
|
|
239
|
+
};
|
|
240
|
+
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
|
|
241
|
+
...colors$2,
|
|
242
|
+
[key]: String
|
|
243
|
+
}), {});
|
|
244
|
+
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();
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/cli/colors.ts
|
|
248
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR });
|
|
249
|
+
const colors = {
|
|
250
|
+
bold,
|
|
251
|
+
cyan,
|
|
252
|
+
dim,
|
|
253
|
+
gray,
|
|
254
|
+
green,
|
|
255
|
+
red,
|
|
256
|
+
underline,
|
|
257
|
+
yellow
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/cli/logger.ts
|
|
262
|
+
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
|
|
263
|
+
function createTestingLogger() {
|
|
264
|
+
const types = [
|
|
265
|
+
"silent",
|
|
266
|
+
"fatal",
|
|
267
|
+
"error",
|
|
268
|
+
"warn",
|
|
269
|
+
"log",
|
|
270
|
+
"info",
|
|
271
|
+
"success",
|
|
272
|
+
"fail",
|
|
273
|
+
"ready",
|
|
274
|
+
"start",
|
|
275
|
+
"box",
|
|
276
|
+
"debug",
|
|
277
|
+
"trace",
|
|
278
|
+
"verbose"
|
|
279
|
+
];
|
|
280
|
+
const ret = Object.create(null);
|
|
281
|
+
for (const type of types) ret[type] = console.log;
|
|
282
|
+
return ret;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/cli/load-config.ts
|
|
287
|
+
async function loadTsConfig(configFile) {
|
|
288
|
+
const file = await bundleTsConfig(configFile);
|
|
289
|
+
try {
|
|
290
|
+
return (await import(pathToFileURL(file).href)).default;
|
|
291
|
+
} finally {
|
|
292
|
+
fs.unlink(file, () => {});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async function bundleTsConfig(configFile) {
|
|
296
|
+
const dirnameVarName = "injected_original_dirname";
|
|
297
|
+
const filenameVarName = "injected_original_filename";
|
|
298
|
+
const importMetaUrlVarName = "injected_original_import_meta_url";
|
|
299
|
+
const bundle = await rolldown({
|
|
300
|
+
input: configFile,
|
|
301
|
+
platform: "node",
|
|
302
|
+
resolve: { mainFields: ["main"] },
|
|
303
|
+
define: {
|
|
304
|
+
__dirname: dirnameVarName,
|
|
305
|
+
__filename: filenameVarName,
|
|
306
|
+
"import.meta.url": importMetaUrlVarName,
|
|
307
|
+
"import.meta.dirname": dirnameVarName,
|
|
308
|
+
"import.meta.filename": filenameVarName
|
|
309
|
+
},
|
|
310
|
+
treeshake: false,
|
|
311
|
+
external: [/^[\w@][^:]/],
|
|
312
|
+
plugins: [{
|
|
313
|
+
name: "inject-file-scope-variables",
|
|
314
|
+
transform: {
|
|
315
|
+
filter: { id: /\.[cm]?[jt]s$/ },
|
|
316
|
+
async handler(code, id) {
|
|
317
|
+
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path$1.dirname(id))};` + `const ${filenameVarName} = ${JSON.stringify(id)};` + `const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};`;
|
|
318
|
+
return {
|
|
319
|
+
code: injectValues + code,
|
|
320
|
+
map: null
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}]
|
|
325
|
+
});
|
|
326
|
+
const result = await bundle.write({
|
|
327
|
+
dir: path$1.dirname(configFile),
|
|
328
|
+
format: "esm",
|
|
329
|
+
sourcemap: "inline",
|
|
330
|
+
entryFileNames: "rolldown.config.[hash].js"
|
|
331
|
+
});
|
|
332
|
+
return result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
|
|
333
|
+
}
|
|
334
|
+
const SUPPORTED_JS_CONFIG_FORMATS = [
|
|
335
|
+
".js",
|
|
336
|
+
".mjs",
|
|
337
|
+
".cjs"
|
|
338
|
+
];
|
|
339
|
+
const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
340
|
+
".ts",
|
|
341
|
+
".mts",
|
|
342
|
+
".cts"
|
|
343
|
+
];
|
|
344
|
+
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
345
|
+
async function loadConfig(configPath) {
|
|
346
|
+
const ext = path$1.extname(configPath);
|
|
347
|
+
try {
|
|
348
|
+
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
|
|
349
|
+
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(configPath);
|
|
350
|
+
else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
|
|
351
|
+
} catch (err) {
|
|
352
|
+
throw new Error("Error happened while loading config.", { cause: err });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
309
356
|
//#endregion
|
|
310
357
|
//#region src/cli/commands/bundle.ts
|
|
311
358
|
async function bundleWithConfig(configPath, cliOptions) {
|
|
312
|
-
const config = await
|
|
359
|
+
const config = await loadConfig(configPath);
|
|
313
360
|
if (!config) {
|
|
314
361
|
logger.error(`No configuration found at ${config}`);
|
|
315
362
|
process.exit(1);
|
|
316
363
|
}
|
|
317
364
|
const configList = arraify(config);
|
|
318
|
-
|
|
365
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
366
|
+
for (const config$1 of configList) await operation(config$1, cliOptions);
|
|
319
367
|
}
|
|
320
368
|
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 {
|
|
369
|
+
if (cliOptions.output.dir) {
|
|
370
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
371
|
+
await operation({}, cliOptions);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (cliOptions.watch) {
|
|
333
375
|
logger.error("You must specify `output.dir` to use watch mode");
|
|
334
376
|
process.exit(1);
|
|
335
377
|
}
|
|
378
|
+
const build = await rolldown(cliOptions.input);
|
|
379
|
+
try {
|
|
380
|
+
const { output: outputs } = await build.generate(cliOptions.output);
|
|
381
|
+
if (outputs.length === 0) {
|
|
382
|
+
logger.error("No output generated");
|
|
383
|
+
process.exit(1);
|
|
384
|
+
}
|
|
385
|
+
for (const file of outputs) {
|
|
386
|
+
if (outputs.length > 1) logger.log(`\n${colors.cyan(colors.bold(`|→ ${file.fileName}:`))}\n`);
|
|
387
|
+
console.log(file.type === "asset" ? file.source : file.code);
|
|
388
|
+
}
|
|
389
|
+
} finally {
|
|
390
|
+
await build.close();
|
|
391
|
+
}
|
|
336
392
|
}
|
|
337
393
|
async function watchInner(options$1, cliOptions) {
|
|
338
394
|
const watcher = await watch({
|
|
339
395
|
...options$1,
|
|
340
|
-
...cliOptions.input
|
|
396
|
+
...cliOptions.input,
|
|
397
|
+
output: {
|
|
398
|
+
...options$1?.output,
|
|
399
|
+
...cliOptions.output
|
|
400
|
+
}
|
|
341
401
|
});
|
|
342
402
|
onExit((code) => {
|
|
343
403
|
Promise.resolve(watcher.close()).finally(() => {
|
|
@@ -352,11 +412,11 @@ async function watchInner(options$1, cliOptions) {
|
|
|
352
412
|
watcher.on("event", (event) => {
|
|
353
413
|
switch (event.code) {
|
|
354
414
|
case "BUNDLE_START":
|
|
355
|
-
if (changedFile.length > 0) logger.log(`Found ${bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
415
|
+
if (changedFile.length > 0) logger.log(`Found ${colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
356
416
|
changedFile.length = 0;
|
|
357
417
|
break;
|
|
358
418
|
case "BUNDLE_END":
|
|
359
|
-
logger.success(`Rebuilt ${bold(relativeId(event.output[0]))} in ${bold(ms(event.duration))}.`);
|
|
419
|
+
logger.success(`Rebuilt ${colors.bold(relativeId(event.output[0]))} in ${colors.bold(ms(event.duration))}.`);
|
|
360
420
|
break;
|
|
361
421
|
case "ERROR":
|
|
362
422
|
logger.error(event.error);
|
|
@@ -372,15 +432,19 @@ async function bundleInner(options$1, cliOptions) {
|
|
|
372
432
|
...options$1,
|
|
373
433
|
...cliOptions.input
|
|
374
434
|
});
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
435
|
+
try {
|
|
436
|
+
const bundleOutput = await build.write({
|
|
437
|
+
...options$1?.output,
|
|
438
|
+
...cliOptions.output
|
|
439
|
+
});
|
|
440
|
+
const endTime = performance.now();
|
|
441
|
+
printBundleOutputPretty(bundleOutput);
|
|
442
|
+
logger.log(``);
|
|
443
|
+
const duration = endTime - startTime;
|
|
444
|
+
logger.success(`Finished in ${colors.bold(ms(duration))}`);
|
|
445
|
+
} finally {
|
|
446
|
+
await build.close();
|
|
447
|
+
}
|
|
384
448
|
}
|
|
385
449
|
function printBundleOutputPretty(output) {
|
|
386
450
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -426,18 +490,18 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
426
490
|
for (const group of CHUNK_GROUPS) {
|
|
427
491
|
const filtered = entries.filter((e) => e.type === group.type);
|
|
428
492
|
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)}`);
|
|
493
|
+
for (const entry of filtered.sort((a, z$1) => a.size - z$1.size)) {
|
|
494
|
+
let log = colors.dim(withTrailingSlash(distPath));
|
|
495
|
+
log += colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
496
|
+
log += colors.dim(entry.type);
|
|
497
|
+
log += colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
434
498
|
logger.log(log);
|
|
435
499
|
}
|
|
436
500
|
}
|
|
437
501
|
}
|
|
438
|
-
function withTrailingSlash(path$
|
|
439
|
-
if (path$
|
|
440
|
-
return path$
|
|
502
|
+
function withTrailingSlash(path$2) {
|
|
503
|
+
if (path$2[path$2.length - 1] !== "/") return `${path$2}/`;
|
|
504
|
+
return path$2;
|
|
441
505
|
}
|
|
442
506
|
function ms(duration) {
|
|
443
507
|
return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
|
|
@@ -528,7 +592,7 @@ function parseAnyDef() {
|
|
|
528
592
|
//#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
593
|
function parseArrayDef(def, refs) {
|
|
530
594
|
const res = { type: "array" };
|
|
531
|
-
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind
|
|
595
|
+
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {
|
|
532
596
|
...refs,
|
|
533
597
|
currentPath: [...refs.currentPath, "items"]
|
|
534
598
|
});
|
|
@@ -937,7 +1001,7 @@ else if (!inCharGroup && source[i] === "[") inCharGroup = true;
|
|
|
937
1001
|
//#endregion
|
|
938
1002
|
//#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
1003
|
function parseRecordDef(def, refs) {
|
|
940
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
1004
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
941
1005
|
type: "object",
|
|
942
1006
|
required: def.keyType._def.values,
|
|
943
1007
|
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
@@ -961,17 +1025,17 @@ function parseRecordDef(def, refs) {
|
|
|
961
1025
|
}) ?? {}
|
|
962
1026
|
};
|
|
963
1027
|
if (refs.target === "openApi3") return schema$1;
|
|
964
|
-
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
1028
|
+
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
965
1029
|
const { type,...keyType } = parseStringDef(def.keyType._def, refs);
|
|
966
1030
|
return {
|
|
967
1031
|
...schema$1,
|
|
968
1032
|
propertyNames: keyType
|
|
969
1033
|
};
|
|
970
|
-
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
1034
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
971
1035
|
...schema$1,
|
|
972
1036
|
propertyNames: { enum: def.keyType._def.values }
|
|
973
1037
|
};
|
|
974
|
-
else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind
|
|
1038
|
+
else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
975
1039
|
const { type,...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
976
1040
|
return {
|
|
977
1041
|
...schema$1,
|
|
@@ -1479,84 +1543,86 @@ else if (refs.target === "jsonSchema2019-09") combined.$schema = "https://json-s
|
|
|
1479
1543
|
|
|
1480
1544
|
//#endregion
|
|
1481
1545
|
//#region src/utils/zod-ext.ts
|
|
1482
|
-
const stringOrRegExp = () => z
|
|
1483
|
-
const optionalStringArray = () => z
|
|
1546
|
+
const stringOrRegExp = () => z.string().or(z.instanceof(RegExp));
|
|
1547
|
+
const optionalStringArray = () => z.string().array().optional();
|
|
1484
1548
|
const returnTrue = () => true;
|
|
1485
|
-
const phantom = () => z
|
|
1549
|
+
const phantom = () => z.custom(returnTrue);
|
|
1486
1550
|
const voidNullableWith = (t) => {
|
|
1487
1551
|
return voidNullable().or(t);
|
|
1488
1552
|
};
|
|
1489
1553
|
const voidNullable = () => {
|
|
1490
|
-
return z
|
|
1554
|
+
return z.void().or(z.null()).or(z.undefined());
|
|
1491
1555
|
};
|
|
1492
1556
|
|
|
1493
1557
|
//#endregion
|
|
1494
1558
|
//#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
|
|
1559
|
+
const inputOptionSchema = z.string().or(z.string().array()).or(z.record(z.string()));
|
|
1560
|
+
const externalSchema = stringOrRegExp().or(stringOrRegExp().array()).or(z.function().args(z.string(), z.string().optional(), z.boolean()).returns(voidNullableWith(z.boolean())));
|
|
1561
|
+
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")));
|
|
1562
|
+
const jsxOptionsSchema = z.strictObject({
|
|
1563
|
+
mode: z.literal("classic").or(z.literal("automatic")).describe("Jsx transformation mode").optional(),
|
|
1564
|
+
factory: z.string().describe("Jsx element transformation").optional(),
|
|
1565
|
+
fragment: z.string().describe("Jsx fragment transformation").optional(),
|
|
1566
|
+
importSource: z.string().describe("Import the factory of element and fragment if mode is classic").optional(),
|
|
1567
|
+
jsxImportSource: z.string().describe("Import the factory of element and fragment if mode is automatic").optional(),
|
|
1568
|
+
refresh: z.boolean().describe("React refresh transformation").optional(),
|
|
1569
|
+
development: z.boolean().describe("Development specific information").optional()
|
|
1506
1570
|
});
|
|
1507
1571
|
const stringOrRegExpSchema = stringOrRegExp().or(stringOrRegExp().array());
|
|
1508
|
-
const watchOptionsSchema = z
|
|
1509
|
-
skipWrite: z
|
|
1510
|
-
notify: z
|
|
1511
|
-
pollInterval: z
|
|
1512
|
-
compareContents: z
|
|
1572
|
+
const watchOptionsSchema = z.strictObject({
|
|
1573
|
+
skipWrite: z.boolean().describe("Skip the bundle.write() step").optional(),
|
|
1574
|
+
notify: z.strictObject({
|
|
1575
|
+
pollInterval: z.number().optional(),
|
|
1576
|
+
compareContents: z.boolean().optional()
|
|
1513
1577
|
}).describe("Notify options").optional(),
|
|
1514
1578
|
include: stringOrRegExpSchema.optional(),
|
|
1515
1579
|
exclude: stringOrRegExpSchema.optional(),
|
|
1516
|
-
chokidar: z
|
|
1580
|
+
chokidar: z.any().optional()
|
|
1517
1581
|
});
|
|
1518
|
-
const
|
|
1582
|
+
const checksOptionsSchema = z.strictObject({ circularDependency: z.boolean().describe("Wether to emit warnings when detecting circular dependencies").optional() });
|
|
1583
|
+
const inputOptionsSchema = z.strictObject({
|
|
1519
1584
|
input: inputOptionSchema.optional(),
|
|
1520
1585
|
plugins: phantom().optional(),
|
|
1521
1586
|
external: externalSchema.optional(),
|
|
1522
|
-
resolve: z
|
|
1523
|
-
alias: z
|
|
1524
|
-
aliasFields: z
|
|
1587
|
+
resolve: z.strictObject({
|
|
1588
|
+
alias: z.record(z.array(z.string()).or(z.string())).optional(),
|
|
1589
|
+
aliasFields: z.array(z.array(z.string())).optional(),
|
|
1525
1590
|
conditionNames: optionalStringArray(),
|
|
1526
|
-
extensionAlias: z
|
|
1527
|
-
exportsFields: z
|
|
1591
|
+
extensionAlias: z.record(z.string(), z.array(z.string())).optional(),
|
|
1592
|
+
exportsFields: z.array(z.array(z.string())).optional(),
|
|
1528
1593
|
extensions: optionalStringArray(),
|
|
1529
1594
|
mainFields: optionalStringArray(),
|
|
1530
1595
|
mainFiles: optionalStringArray(),
|
|
1531
1596
|
modules: optionalStringArray(),
|
|
1532
|
-
symlinks: z
|
|
1533
|
-
tsconfigFilename: z
|
|
1597
|
+
symlinks: z.boolean().optional(),
|
|
1598
|
+
tsconfigFilename: z.string().optional()
|
|
1534
1599
|
}).optional(),
|
|
1535
|
-
cwd: z
|
|
1536
|
-
platform: z
|
|
1537
|
-
shimMissingExports: z
|
|
1600
|
+
cwd: z.string().describe("Current working directory").optional(),
|
|
1601
|
+
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(),
|
|
1602
|
+
shimMissingExports: z.boolean().describe(`Create shim variables for missing exports`).optional(),
|
|
1538
1603
|
treeshake: TreeshakingOptionsSchema.optional(),
|
|
1539
|
-
logLevel: LogLevelOptionSchema.describe(`Log level (${dim("silent")}, ${underline(gray("info"))}, debug, ${yellow("warn")})`).optional(),
|
|
1540
|
-
onLog: z
|
|
1541
|
-
onwarn: z
|
|
1604
|
+
logLevel: LogLevelOptionSchema.describe(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`).optional(),
|
|
1605
|
+
onLog: z.function().args(LogLevelSchema, RollupLogSchema, z.function().args(LogLevelWithErrorSchema, RollupLogWithStringSchema)).optional(),
|
|
1606
|
+
onwarn: z.function().args(RollupLogSchema, z.function().args(RollupLogWithStringSchema.or(z.function().returns(RollupLogWithStringSchema)))).optional(),
|
|
1542
1607
|
moduleTypes: moduleTypesSchema.describe("Module types for customized extensions").optional(),
|
|
1543
|
-
experimental: z
|
|
1544
|
-
enableComposingJsPlugins: z
|
|
1545
|
-
strictExecutionOrder: z
|
|
1546
|
-
disableLiveBindings: z
|
|
1547
|
-
resolveNewUrlToAsset: z
|
|
1608
|
+
experimental: z.strictObject({
|
|
1609
|
+
enableComposingJsPlugins: z.boolean().optional(),
|
|
1610
|
+
strictExecutionOrder: z.boolean().optional(),
|
|
1611
|
+
disableLiveBindings: z.boolean().optional(),
|
|
1612
|
+
resolveNewUrlToAsset: z.boolean().optional()
|
|
1548
1613
|
}).optional(),
|
|
1549
|
-
define: z
|
|
1550
|
-
inject: z
|
|
1551
|
-
profilerNames: z
|
|
1614
|
+
define: z.record(z.string()).describe("Define global variables").optional(),
|
|
1615
|
+
inject: z.record(z.string().or(z.tuple([z.string(), z.string()]))).optional(),
|
|
1616
|
+
profilerNames: z.boolean().optional(),
|
|
1552
1617
|
jsx: jsxOptionsSchema.optional(),
|
|
1553
|
-
watch: watchOptionsSchema.or(z
|
|
1554
|
-
dropLabels: z
|
|
1618
|
+
watch: watchOptionsSchema.or(z.literal(false)).optional(),
|
|
1619
|
+
dropLabels: z.array(z.string()).describe("Remove labeled statements with these label names").optional(),
|
|
1620
|
+
checks: checksOptionsSchema.optional()
|
|
1555
1621
|
});
|
|
1556
1622
|
const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
1557
|
-
external: z
|
|
1558
|
-
inject: z
|
|
1559
|
-
treeshake: z
|
|
1623
|
+
external: z.array(z.string()).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`").optional(),
|
|
1624
|
+
inject: z.record(z.string()).describe("Inject import statements on demand").optional(),
|
|
1625
|
+
treeshake: z.boolean().describe("enable treeshaking").default(true).optional()
|
|
1560
1626
|
}).omit({
|
|
1561
1627
|
input: true,
|
|
1562
1628
|
plugins: true,
|
|
@@ -1570,61 +1636,61 @@ const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
|
1570
1636
|
|
|
1571
1637
|
//#endregion
|
|
1572
1638
|
//#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
|
|
1639
|
+
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)`);
|
|
1640
|
+
const addonFunctionSchema = z.function().args(phantom()).returns(z.string().or(z.promise(z.string())));
|
|
1641
|
+
const chunkFileNamesFunctionSchema = z.function().args(phantom()).returns(z.string());
|
|
1642
|
+
const GlobalsFunctionSchema = z.function().args(z.string()).returns(z.string());
|
|
1643
|
+
const outputOptionsSchema = z.strictObject({
|
|
1644
|
+
dir: z.string().describe("Output directory, defaults to `dist` if `file` is not set").optional(),
|
|
1645
|
+
file: z.string().describe("Single output file").optional(),
|
|
1646
|
+
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(),
|
|
1647
|
+
hashCharacters: z.literal("base64").or(z.literal("base36")).or(z.literal("hex")).describe("Use the specified character set for file hashes").optional(),
|
|
1582
1648
|
format: ModuleFormatSchema.optional(),
|
|
1583
|
-
sourcemap: z
|
|
1584
|
-
sourcemapIgnoreList: z
|
|
1649
|
+
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(),
|
|
1650
|
+
sourcemapIgnoreList: z.boolean().or(phantom()).optional(),
|
|
1585
1651
|
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
|
|
1652
|
+
banner: z.string().or(addonFunctionSchema).optional(),
|
|
1653
|
+
footer: z.string().or(addonFunctionSchema).optional(),
|
|
1654
|
+
intro: z.string().or(addonFunctionSchema).optional(),
|
|
1655
|
+
outro: z.string().or(addonFunctionSchema).optional(),
|
|
1656
|
+
extend: z.boolean().describe("Extend global variable defined by name in IIFE / UMD formats").optional(),
|
|
1657
|
+
esModule: z.literal("if-default-prop").or(z.boolean()).optional(),
|
|
1658
|
+
assetFileNames: z.string().describe("Name pattern for asset files").optional(),
|
|
1659
|
+
entryFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted entry chunks").optional(),
|
|
1660
|
+
chunkFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted secondary chunks").optional(),
|
|
1661
|
+
cssEntryFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css entry chunks").optional(),
|
|
1662
|
+
cssChunkFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css secondary chunks").optional(),
|
|
1663
|
+
minify: z.boolean().describe("Minify the bundled file.").optional(),
|
|
1664
|
+
name: z.string().describe("Name for UMD / IIFE format outputs").optional(),
|
|
1665
|
+
globals: z.record(z.string()).or(GlobalsFunctionSchema).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
|
|
1666
|
+
externalLiveBindings: z.boolean().describe("external live bindings").default(true).optional(),
|
|
1667
|
+
inlineDynamicImports: z.boolean().describe("Inline dynamic imports").default(false).optional(),
|
|
1668
|
+
advancedChunks: z.strictObject({
|
|
1669
|
+
minSize: z.number().optional(),
|
|
1670
|
+
minShareCount: z.number().optional(),
|
|
1671
|
+
groups: z.array(z.strictObject({
|
|
1672
|
+
name: z.string(),
|
|
1673
|
+
test: z.string().or(z.instanceof(RegExp)).optional(),
|
|
1674
|
+
priority: z.number().optional(),
|
|
1675
|
+
minSize: z.number().optional(),
|
|
1676
|
+
minShareCount: z.number().optional()
|
|
1611
1677
|
})).optional()
|
|
1612
1678
|
}).optional(),
|
|
1613
|
-
comments: z
|
|
1679
|
+
comments: z.enum(["none", "preserve-legal"]).describe("Control comments in the output").optional()
|
|
1614
1680
|
});
|
|
1615
1681
|
const getAddonDescription = (placement, wrapper) => {
|
|
1616
|
-
return `Code to insert the ${bold(placement)} of the bundled file (${bold(wrapper)} the wrapper function)`;
|
|
1682
|
+
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
1617
1683
|
};
|
|
1618
1684
|
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
|
|
1685
|
+
banner: z.string().describe(getAddonDescription("top", "outside")).optional(),
|
|
1686
|
+
footer: z.string().describe(getAddonDescription("bottom", "outside")).optional(),
|
|
1687
|
+
intro: z.string().describe(getAddonDescription("top", "inside")).optional(),
|
|
1688
|
+
outro: z.string().describe(getAddonDescription("bottom", "inside")).optional(),
|
|
1689
|
+
esModule: z.boolean().describe("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)").optional(),
|
|
1690
|
+
globals: z.record(z.string()).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
|
|
1691
|
+
advancedChunks: z.strictObject({
|
|
1692
|
+
minSize: z.number().describe("Minimum size of the chunk").optional(),
|
|
1693
|
+
minShareCount: z.number().describe("Minimum share count of the chunk").optional()
|
|
1628
1694
|
}).optional()
|
|
1629
1695
|
}).omit({
|
|
1630
1696
|
sourcemapPathTransform: true,
|
|
@@ -1701,8 +1767,8 @@ else base[key] = value;
|
|
|
1701
1767
|
}
|
|
1702
1768
|
return base;
|
|
1703
1769
|
}
|
|
1704
|
-
function setNestedProperty(obj, path$
|
|
1705
|
-
const keys = path$
|
|
1770
|
+
function setNestedProperty(obj, path$2, value) {
|
|
1771
|
+
const keys = path$2.split(".");
|
|
1706
1772
|
let current = obj;
|
|
1707
1773
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
1708
1774
|
if (!current[keys[i]]) current[keys[i]] = {};
|
|
@@ -1855,9 +1921,9 @@ else Object.defineProperty(values, option.name, {
|
|
|
1855
1921
|
|
|
1856
1922
|
//#endregion
|
|
1857
1923
|
//#region src/cli/commands/help.ts
|
|
1858
|
-
const introduction = `${gray(`${description} (rolldown v${version})`)}
|
|
1924
|
+
const introduction = `${colors.gray(`${description} (rolldown v${version})`)}
|
|
1859
1925
|
|
|
1860
|
-
${bold(underline("USAGE"))} ${cyan("rolldown -c <config>")} or ${cyan("rolldown <input> <options>")}`;
|
|
1926
|
+
${colors.bold(colors.underline("USAGE"))} ${colors.cyan("rolldown -c <config>")} or ${colors.cyan("rolldown <input> <options>")}`;
|
|
1861
1927
|
const examples = [
|
|
1862
1928
|
{
|
|
1863
1929
|
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
@@ -1889,7 +1955,7 @@ const notes = [
|
|
|
1889
1955
|
function showHelp() {
|
|
1890
1956
|
logger.log(introduction);
|
|
1891
1957
|
logger.log("");
|
|
1892
|
-
logger.log(`${bold(underline("OPTIONS"))}`);
|
|
1958
|
+
logger.log(`${colors.bold(colors.underline("OPTIONS"))}`);
|
|
1893
1959
|
logger.log("");
|
|
1894
1960
|
logger.log(Object.entries(options).sort(([a], [b]) => {
|
|
1895
1961
|
if (options[a].short && !options[b].short) return -1;
|
|
@@ -1902,20 +1968,20 @@ function showHelp() {
|
|
|
1902
1968
|
if (short) optionStr += `-${short}, `;
|
|
1903
1969
|
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
1904
1970
|
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(".") ? "" : ".");
|
|
1971
|
+
return colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1906
1972
|
}).join("\n"));
|
|
1907
1973
|
logger.log("");
|
|
1908
|
-
logger.log(`${bold(underline("EXAMPLES"))}`);
|
|
1974
|
+
logger.log(`${colors.bold(colors.underline("EXAMPLES"))}`);
|
|
1909
1975
|
logger.log("");
|
|
1910
1976
|
examples.forEach(({ title, command }, ord) => {
|
|
1911
1977
|
logger.log(` ${ord + 1}. ${title}:`);
|
|
1912
|
-
logger.log(` ${cyan(command)}`);
|
|
1978
|
+
logger.log(` ${colors.cyan(command)}`);
|
|
1913
1979
|
logger.log("");
|
|
1914
1980
|
});
|
|
1915
|
-
logger.log(`${bold(underline("NOTES"))}`);
|
|
1981
|
+
logger.log(`${colors.bold(colors.underline("NOTES"))}`);
|
|
1916
1982
|
logger.log("");
|
|
1917
1983
|
notes.forEach((note) => {
|
|
1918
|
-
logger.log(` * ${gray(note)}`);
|
|
1984
|
+
logger.log(` * ${colors.gray(note)}`);
|
|
1919
1985
|
});
|
|
1920
1986
|
}
|
|
1921
1987
|
|