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/cjs/cli.cjs
CHANGED
|
@@ -1,143 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('../shared/chunk-
|
|
3
|
-
const require_src = require('../shared/src-
|
|
4
|
-
const require_consola_36c0034f = require('../shared/consola_36c0034f-
|
|
2
|
+
const require_chunk = require('../shared/chunk-BFvIen8E.cjs');
|
|
3
|
+
const require_src = require('../shared/src-Bs7g4_us.cjs');
|
|
4
|
+
const require_consola_36c0034f = require('../shared/consola_36c0034f-B7L-radJ.cjs');
|
|
5
5
|
const zod = require_chunk.__toESM(require("zod"));
|
|
6
6
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
7
7
|
const node_process = require_chunk.__toESM(require("node:process"));
|
|
8
8
|
const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
|
|
9
|
+
const tty = require_chunk.__toESM(require("tty"));
|
|
9
10
|
const node_url = require_chunk.__toESM(require("node:url"));
|
|
10
11
|
const node_util = require_chunk.__toESM(require("node:util"));
|
|
11
12
|
const node_tty = require_chunk.__toESM(require("node:tty"));
|
|
12
|
-
const tty = require_chunk.__toESM(require("tty"));
|
|
13
|
-
|
|
14
|
-
//#region src/cli/utils.ts
|
|
15
|
-
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : require_consola_36c0034f.createConsola({ formatOptions: { date: false } });
|
|
16
|
-
function createTestingLogger() {
|
|
17
|
-
const types = [
|
|
18
|
-
"silent",
|
|
19
|
-
"fatal",
|
|
20
|
-
"error",
|
|
21
|
-
"warn",
|
|
22
|
-
"log",
|
|
23
|
-
"info",
|
|
24
|
-
"success",
|
|
25
|
-
"fail",
|
|
26
|
-
"ready",
|
|
27
|
-
"start",
|
|
28
|
-
"box",
|
|
29
|
-
"debug",
|
|
30
|
-
"trace",
|
|
31
|
-
"verbose"
|
|
32
|
-
];
|
|
33
|
-
const ret = Object.create(null);
|
|
34
|
-
for (const type of types) ret[type] = console.log;
|
|
35
|
-
return ret;
|
|
36
|
-
}
|
|
37
|
-
async function ensureConfig(configPath) {
|
|
38
|
-
const fileUrl = (0, node_url.pathToFileURL)(configPath).toString();
|
|
39
|
-
let configExports;
|
|
40
|
-
try {
|
|
41
|
-
configExports = await import(fileUrl);
|
|
42
|
-
} catch (err) {
|
|
43
|
-
let errorMessage = "Error happened while loading config.";
|
|
44
|
-
if (!isSupportedFormat(configPath)) errorMessage += ` Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${node_path.default.extname(configPath)}\``;
|
|
45
|
-
throw new Error(errorMessage, { cause: err });
|
|
46
|
-
}
|
|
47
|
-
return configExports.default;
|
|
48
|
-
}
|
|
49
|
-
const SUPPORTED_CONFIG_FORMATS = [
|
|
50
|
-
".js",
|
|
51
|
-
".mjs",
|
|
52
|
-
".cjs"
|
|
53
|
-
];
|
|
54
|
-
/**
|
|
55
|
-
* Check whether the configuration file is supported
|
|
56
|
-
*/
|
|
57
|
-
function isSupportedFormat(configPath) {
|
|
58
|
-
const ext = node_path.default.extname(configPath);
|
|
59
|
-
return SUPPORTED_CONFIG_FORMATS.includes(ext);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
64
|
-
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
65
|
-
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
66
|
-
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
67
|
-
const isWindows = platform === "win32";
|
|
68
|
-
const isDumbTerminal = env$1.TERM === "dumb";
|
|
69
|
-
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
70
|
-
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
71
|
-
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
72
|
-
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));
|
|
73
|
-
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
74
|
-
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
75
|
-
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
76
|
-
const colors = {
|
|
77
|
-
reset: init(0, 0),
|
|
78
|
-
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
79
|
-
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
80
|
-
italic: init(3, 23),
|
|
81
|
-
underline: init(4, 24),
|
|
82
|
-
inverse: init(7, 27),
|
|
83
|
-
hidden: init(8, 28),
|
|
84
|
-
strikethrough: init(9, 29),
|
|
85
|
-
black: init(30, 39),
|
|
86
|
-
red: init(31, 39),
|
|
87
|
-
green: init(32, 39),
|
|
88
|
-
yellow: init(33, 39),
|
|
89
|
-
blue: init(34, 39),
|
|
90
|
-
magenta: init(35, 39),
|
|
91
|
-
cyan: init(36, 39),
|
|
92
|
-
white: init(37, 39),
|
|
93
|
-
gray: init(90, 39),
|
|
94
|
-
bgBlack: init(40, 49),
|
|
95
|
-
bgRed: init(41, 49),
|
|
96
|
-
bgGreen: init(42, 49),
|
|
97
|
-
bgYellow: init(43, 49),
|
|
98
|
-
bgBlue: init(44, 49),
|
|
99
|
-
bgMagenta: init(45, 49),
|
|
100
|
-
bgCyan: init(46, 49),
|
|
101
|
-
bgWhite: init(47, 49),
|
|
102
|
-
blackBright: init(90, 39),
|
|
103
|
-
redBright: init(91, 39),
|
|
104
|
-
greenBright: init(92, 39),
|
|
105
|
-
yellowBright: init(93, 39),
|
|
106
|
-
blueBright: init(94, 39),
|
|
107
|
-
magentaBright: init(95, 39),
|
|
108
|
-
cyanBright: init(96, 39),
|
|
109
|
-
whiteBright: init(97, 39),
|
|
110
|
-
bgBlackBright: init(100, 49),
|
|
111
|
-
bgRedBright: init(101, 49),
|
|
112
|
-
bgGreenBright: init(102, 49),
|
|
113
|
-
bgYellowBright: init(103, 49),
|
|
114
|
-
bgBlueBright: init(104, 49),
|
|
115
|
-
bgMagentaBright: init(105, 49),
|
|
116
|
-
bgCyanBright: init(106, 49),
|
|
117
|
-
bgWhiteBright: init(107, 49)
|
|
118
|
-
};
|
|
119
|
-
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors : Object.keys(colors).reduce((colors$1, key) => ({
|
|
120
|
-
...colors$1,
|
|
121
|
-
[key]: String
|
|
122
|
-
}), {});
|
|
123
|
-
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();
|
|
124
|
-
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/cli/colors.ts
|
|
127
|
-
var colors_exports = {};
|
|
128
|
-
__export(colors_exports, {
|
|
129
|
-
bold: () => bold,
|
|
130
|
-
cyan: () => cyan,
|
|
131
|
-
dim: () => dim,
|
|
132
|
-
gray: () => gray,
|
|
133
|
-
green: () => green,
|
|
134
|
-
red: () => red,
|
|
135
|
-
underline: () => underline,
|
|
136
|
-
yellow: () => yellow
|
|
137
|
-
});
|
|
138
|
-
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: node_process.env.FORCE_COLOR !== "0" && !node_process.env.NO_COLOR });
|
|
139
13
|
|
|
140
|
-
//#endregion
|
|
141
14
|
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
142
15
|
const signals = [];
|
|
143
16
|
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
@@ -309,6 +182,132 @@ var SignalExit = class extends SignalExitBase {
|
|
|
309
182
|
const process$2 = globalThis.process;
|
|
310
183
|
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
311
184
|
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
187
|
+
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
188
|
+
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
189
|
+
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
190
|
+
const isWindows = platform === "win32";
|
|
191
|
+
const isDumbTerminal = env$1.TERM === "dumb";
|
|
192
|
+
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
193
|
+
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
194
|
+
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
195
|
+
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));
|
|
196
|
+
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
197
|
+
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
198
|
+
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
199
|
+
const colors$1 = {
|
|
200
|
+
reset: init(0, 0),
|
|
201
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
202
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
203
|
+
italic: init(3, 23),
|
|
204
|
+
underline: init(4, 24),
|
|
205
|
+
inverse: init(7, 27),
|
|
206
|
+
hidden: init(8, 28),
|
|
207
|
+
strikethrough: init(9, 29),
|
|
208
|
+
black: init(30, 39),
|
|
209
|
+
red: init(31, 39),
|
|
210
|
+
green: init(32, 39),
|
|
211
|
+
yellow: init(33, 39),
|
|
212
|
+
blue: init(34, 39),
|
|
213
|
+
magenta: init(35, 39),
|
|
214
|
+
cyan: init(36, 39),
|
|
215
|
+
white: init(37, 39),
|
|
216
|
+
gray: init(90, 39),
|
|
217
|
+
bgBlack: init(40, 49),
|
|
218
|
+
bgRed: init(41, 49),
|
|
219
|
+
bgGreen: init(42, 49),
|
|
220
|
+
bgYellow: init(43, 49),
|
|
221
|
+
bgBlue: init(44, 49),
|
|
222
|
+
bgMagenta: init(45, 49),
|
|
223
|
+
bgCyan: init(46, 49),
|
|
224
|
+
bgWhite: init(47, 49),
|
|
225
|
+
blackBright: init(90, 39),
|
|
226
|
+
redBright: init(91, 39),
|
|
227
|
+
greenBright: init(92, 39),
|
|
228
|
+
yellowBright: init(93, 39),
|
|
229
|
+
blueBright: init(94, 39),
|
|
230
|
+
magentaBright: init(95, 39),
|
|
231
|
+
cyanBright: init(96, 39),
|
|
232
|
+
whiteBright: init(97, 39),
|
|
233
|
+
bgBlackBright: init(100, 49),
|
|
234
|
+
bgRedBright: init(101, 49),
|
|
235
|
+
bgGreenBright: init(102, 49),
|
|
236
|
+
bgYellowBright: init(103, 49),
|
|
237
|
+
bgBlueBright: init(104, 49),
|
|
238
|
+
bgMagentaBright: init(105, 49),
|
|
239
|
+
bgCyanBright: init(106, 49),
|
|
240
|
+
bgWhiteBright: init(107, 49)
|
|
241
|
+
};
|
|
242
|
+
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
|
|
243
|
+
...colors$2,
|
|
244
|
+
[key]: String
|
|
245
|
+
}), {});
|
|
246
|
+
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();
|
|
247
|
+
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/cli/colors.ts
|
|
250
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: node_process.env.FORCE_COLOR !== "0" && !node_process.env.NO_COLOR });
|
|
251
|
+
const colors = {
|
|
252
|
+
bold,
|
|
253
|
+
cyan,
|
|
254
|
+
dim,
|
|
255
|
+
gray,
|
|
256
|
+
green,
|
|
257
|
+
red,
|
|
258
|
+
underline,
|
|
259
|
+
yellow
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/cli/utils.ts
|
|
264
|
+
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : require_consola_36c0034f.createConsola({ formatOptions: { date: false } });
|
|
265
|
+
function createTestingLogger() {
|
|
266
|
+
const types = [
|
|
267
|
+
"silent",
|
|
268
|
+
"fatal",
|
|
269
|
+
"error",
|
|
270
|
+
"warn",
|
|
271
|
+
"log",
|
|
272
|
+
"info",
|
|
273
|
+
"success",
|
|
274
|
+
"fail",
|
|
275
|
+
"ready",
|
|
276
|
+
"start",
|
|
277
|
+
"box",
|
|
278
|
+
"debug",
|
|
279
|
+
"trace",
|
|
280
|
+
"verbose"
|
|
281
|
+
];
|
|
282
|
+
const ret = Object.create(null);
|
|
283
|
+
for (const type of types) ret[type] = console.log;
|
|
284
|
+
return ret;
|
|
285
|
+
}
|
|
286
|
+
async function ensureConfig(configPath) {
|
|
287
|
+
const fileUrl = (0, node_url.pathToFileURL)(configPath).toString();
|
|
288
|
+
let configExports;
|
|
289
|
+
try {
|
|
290
|
+
configExports = await import(fileUrl);
|
|
291
|
+
} catch (err) {
|
|
292
|
+
let errorMessage = "Error happened while loading config.";
|
|
293
|
+
if (!isSupportedFormat(configPath)) errorMessage += ` Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${node_path.default.extname(configPath)}\``;
|
|
294
|
+
throw new Error(errorMessage, { cause: err });
|
|
295
|
+
}
|
|
296
|
+
return configExports.default;
|
|
297
|
+
}
|
|
298
|
+
const SUPPORTED_CONFIG_FORMATS = [
|
|
299
|
+
".js",
|
|
300
|
+
".mjs",
|
|
301
|
+
".cjs"
|
|
302
|
+
];
|
|
303
|
+
/**
|
|
304
|
+
* Check whether the configuration file is supported
|
|
305
|
+
*/
|
|
306
|
+
function isSupportedFormat(configPath) {
|
|
307
|
+
const ext = node_path.default.extname(configPath);
|
|
308
|
+
return SUPPORTED_CONFIG_FORMATS.includes(ext);
|
|
309
|
+
}
|
|
310
|
+
|
|
312
311
|
//#endregion
|
|
313
312
|
//#region src/cli/commands/bundle.ts
|
|
314
313
|
async function bundleWithConfig(configPath, cliOptions) {
|
|
@@ -318,24 +317,33 @@ async function bundleWithConfig(configPath, cliOptions) {
|
|
|
318
317
|
process.exit(1);
|
|
319
318
|
}
|
|
320
319
|
const configList = require_src.arraify(config);
|
|
321
|
-
|
|
320
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
321
|
+
for (const config$1 of configList) await operation(config$1, cliOptions);
|
|
322
322
|
}
|
|
323
323
|
async function bundleWithCliOptions(cliOptions) {
|
|
324
|
-
if (cliOptions.output.dir)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
process.exit(1);
|
|
331
|
-
} else if (output.length === 0) {
|
|
332
|
-
logger.error("No output generated");
|
|
333
|
-
process.exit(1);
|
|
334
|
-
} else logger.log(output[0].code);
|
|
335
|
-
} else {
|
|
324
|
+
if (cliOptions.output.dir) {
|
|
325
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
326
|
+
await operation({}, cliOptions);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (cliOptions.watch) {
|
|
336
330
|
logger.error("You must specify `output.dir` to use watch mode");
|
|
337
331
|
process.exit(1);
|
|
338
332
|
}
|
|
333
|
+
const build = await require_src.rolldown(cliOptions.input);
|
|
334
|
+
try {
|
|
335
|
+
const { output: outputs } = await build.generate(cliOptions.output);
|
|
336
|
+
if (outputs.length === 0) {
|
|
337
|
+
logger.error("No output generated");
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
for (const file of outputs) {
|
|
341
|
+
if (outputs.length > 1) logger.log(`\n${colors.cyan(colors.bold(`|→ ${file.fileName}:`))}\n`);
|
|
342
|
+
logger.log(file.type === "asset" ? file.source : file.code);
|
|
343
|
+
}
|
|
344
|
+
} finally {
|
|
345
|
+
await build.close();
|
|
346
|
+
}
|
|
339
347
|
}
|
|
340
348
|
async function watchInner(options$1, cliOptions) {
|
|
341
349
|
const watcher = await require_src.watch({
|
|
@@ -355,11 +363,11 @@ async function watchInner(options$1, cliOptions) {
|
|
|
355
363
|
watcher.on("event", (event) => {
|
|
356
364
|
switch (event.code) {
|
|
357
365
|
case "BUNDLE_START":
|
|
358
|
-
if (changedFile.length > 0) logger.log(`Found ${bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
366
|
+
if (changedFile.length > 0) logger.log(`Found ${colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
359
367
|
changedFile.length = 0;
|
|
360
368
|
break;
|
|
361
369
|
case "BUNDLE_END":
|
|
362
|
-
logger.success(`Rebuilt ${bold(relativeId(event.output[0]))} in ${bold(ms(event.duration))}.`);
|
|
370
|
+
logger.success(`Rebuilt ${colors.bold(relativeId(event.output[0]))} in ${colors.bold(ms(event.duration))}.`);
|
|
363
371
|
break;
|
|
364
372
|
case "ERROR":
|
|
365
373
|
logger.error(event.error);
|
|
@@ -375,15 +383,19 @@ async function bundleInner(options$1, cliOptions) {
|
|
|
375
383
|
...options$1,
|
|
376
384
|
...cliOptions.input
|
|
377
385
|
});
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
386
|
+
try {
|
|
387
|
+
const bundleOutput = await build.write({
|
|
388
|
+
...options$1?.output,
|
|
389
|
+
...cliOptions.output
|
|
390
|
+
});
|
|
391
|
+
const endTime = node_perf_hooks.performance.now();
|
|
392
|
+
printBundleOutputPretty(bundleOutput);
|
|
393
|
+
logger.log(``);
|
|
394
|
+
const duration = endTime - startTime;
|
|
395
|
+
logger.success(`Finished in ${colors.bold(ms(duration))}`);
|
|
396
|
+
} finally {
|
|
397
|
+
await build.close();
|
|
398
|
+
}
|
|
387
399
|
}
|
|
388
400
|
function printBundleOutputPretty(output) {
|
|
389
401
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -430,10 +442,10 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
430
442
|
const filtered = entries.filter((e) => e.type === group.type);
|
|
431
443
|
if (!filtered.length) continue;
|
|
432
444
|
for (const entry of filtered.sort((a, z$4) => a.size - z$4.size)) {
|
|
433
|
-
let log = dim(withTrailingSlash(distPath));
|
|
434
|
-
log +=
|
|
435
|
-
log += dim(entry.type);
|
|
436
|
-
log += dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
445
|
+
let log = colors.dim(withTrailingSlash(distPath));
|
|
446
|
+
log += colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
447
|
+
log += colors.dim(entry.type);
|
|
448
|
+
log += colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
437
449
|
logger.log(log);
|
|
438
450
|
}
|
|
439
451
|
}
|
|
@@ -1518,12 +1530,13 @@ const watchOptionsSchema = zod.z.strictObject({
|
|
|
1518
1530
|
exclude: stringOrRegExpSchema.optional(),
|
|
1519
1531
|
chokidar: zod.z.any().optional()
|
|
1520
1532
|
});
|
|
1533
|
+
const checksOptionsSchema = zod.z.strictObject({ circularDependency: zod.z.boolean().describe("Wether to emit warnings when detecting circular dependencies").optional() });
|
|
1521
1534
|
const inputOptionsSchema = zod.z.strictObject({
|
|
1522
1535
|
input: inputOptionSchema.optional(),
|
|
1523
1536
|
plugins: phantom().optional(),
|
|
1524
1537
|
external: externalSchema.optional(),
|
|
1525
1538
|
resolve: zod.z.strictObject({
|
|
1526
|
-
alias: zod.z.record(zod.z.string()).optional(),
|
|
1539
|
+
alias: zod.z.record(zod.z.array(zod.z.string()).or(zod.z.string())).optional(),
|
|
1527
1540
|
aliasFields: zod.z.array(zod.z.array(zod.z.string())).optional(),
|
|
1528
1541
|
conditionNames: optionalStringArray(),
|
|
1529
1542
|
extensionAlias: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())).optional(),
|
|
@@ -1536,10 +1549,10 @@ const inputOptionsSchema = zod.z.strictObject({
|
|
|
1536
1549
|
tsconfigFilename: zod.z.string().optional()
|
|
1537
1550
|
}).optional(),
|
|
1538
1551
|
cwd: zod.z.string().describe("Current working directory").optional(),
|
|
1539
|
-
platform: zod.z.literal("node").or(zod.z.literal("browser")).or(zod.z.literal("neutral")).describe(`Platform for which the code should be generated (node, ${underline("browser")}, neutral)`).optional(),
|
|
1552
|
+
platform: zod.z.literal("node").or(zod.z.literal("browser")).or(zod.z.literal("neutral")).describe(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`).optional(),
|
|
1540
1553
|
shimMissingExports: zod.z.boolean().describe(`Create shim variables for missing exports`).optional(),
|
|
1541
1554
|
treeshake: require_src.TreeshakingOptionsSchema.optional(),
|
|
1542
|
-
logLevel: require_src.LogLevelOptionSchema.describe(`Log level (${dim("silent")}, ${underline(gray("info"))}, debug, ${yellow("warn")})`).optional(),
|
|
1555
|
+
logLevel: require_src.LogLevelOptionSchema.describe(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`).optional(),
|
|
1543
1556
|
onLog: zod.z.function().args(require_src.LogLevelSchema, require_src.RollupLogSchema, zod.z.function().args(require_src.LogLevelWithErrorSchema, require_src.RollupLogWithStringSchema)).optional(),
|
|
1544
1557
|
onwarn: zod.z.function().args(require_src.RollupLogSchema, zod.z.function().args(require_src.RollupLogWithStringSchema.or(zod.z.function().returns(require_src.RollupLogWithStringSchema)))).optional(),
|
|
1545
1558
|
moduleTypes: moduleTypesSchema.describe("Module types for customized extensions").optional(),
|
|
@@ -1554,7 +1567,8 @@ const inputOptionsSchema = zod.z.strictObject({
|
|
|
1554
1567
|
profilerNames: zod.z.boolean().optional(),
|
|
1555
1568
|
jsx: jsxOptionsSchema.optional(),
|
|
1556
1569
|
watch: watchOptionsSchema.or(zod.z.literal(false)).optional(),
|
|
1557
|
-
dropLabels: zod.z.array(zod.z.string()).describe("Remove labeled statements with these label names").optional()
|
|
1570
|
+
dropLabels: zod.z.array(zod.z.string()).describe("Remove labeled statements with these label names").optional(),
|
|
1571
|
+
checks: checksOptionsSchema.optional()
|
|
1558
1572
|
});
|
|
1559
1573
|
const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
1560
1574
|
external: zod.z.array(zod.z.string()).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`").optional(),
|
|
@@ -1573,17 +1587,17 @@ const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
|
1573
1587
|
|
|
1574
1588
|
//#endregion
|
|
1575
1589
|
//#region src/options/output-options-schema.ts
|
|
1576
|
-
const ModuleFormatSchema = zod.z.literal("es").or(zod.z.literal("cjs")).or(zod.z.literal("esm")).or(zod.z.literal("module")).or(zod.z.literal("commonjs")).or(zod.z.literal("iife")).or(zod.z.literal("umd")).describe(`Output format of the generated bundle (supports ${underline("esm")}, cjs, and iife)`);
|
|
1590
|
+
const ModuleFormatSchema = zod.z.literal("es").or(zod.z.literal("cjs")).or(zod.z.literal("esm")).or(zod.z.literal("module")).or(zod.z.literal("commonjs")).or(zod.z.literal("iife")).or(zod.z.literal("umd")).describe(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`);
|
|
1577
1591
|
const addonFunctionSchema = zod.z.function().args(phantom()).returns(zod.z.string().or(zod.z.promise(zod.z.string())));
|
|
1578
1592
|
const chunkFileNamesFunctionSchema = zod.z.function().args(phantom()).returns(zod.z.string());
|
|
1579
1593
|
const GlobalsFunctionSchema = zod.z.function().args(zod.z.string()).returns(zod.z.string());
|
|
1580
1594
|
const outputOptionsSchema = zod.z.strictObject({
|
|
1581
1595
|
dir: zod.z.string().describe("Output directory, defaults to `dist` if `file` is not set").optional(),
|
|
1582
1596
|
file: zod.z.string().describe("Single output file").optional(),
|
|
1583
|
-
exports: zod.z.literal("auto").or(zod.z.literal("named")).or(zod.z.literal("default")).or(zod.z.literal("none")).describe(`Specify a export mode (${underline("auto")}, named, default, none)`).optional(),
|
|
1597
|
+
exports: zod.z.literal("auto").or(zod.z.literal("named")).or(zod.z.literal("default")).or(zod.z.literal("none")).describe(`Specify a export mode (${colors.underline("auto")}, named, default, none)`).optional(),
|
|
1584
1598
|
hashCharacters: zod.z.literal("base64").or(zod.z.literal("base36")).or(zod.z.literal("hex")).describe("Use the specified character set for file hashes").optional(),
|
|
1585
1599
|
format: ModuleFormatSchema.optional(),
|
|
1586
|
-
sourcemap: zod.z.boolean().or(zod.z.literal("inline")).or(zod.z.literal("hidden")).describe(`Generate sourcemap (\`-s inline\` for inline, or ${bold("pass the `-s` on the last argument if you want to generate `.map` file")})`).optional(),
|
|
1600
|
+
sourcemap: zod.z.boolean().or(zod.z.literal("inline")).or(zod.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(),
|
|
1587
1601
|
sourcemapIgnoreList: zod.z.boolean().or(phantom()).optional(),
|
|
1588
1602
|
sourcemapPathTransform: phantom().optional(),
|
|
1589
1603
|
banner: zod.z.string().or(addonFunctionSchema).optional(),
|
|
@@ -1616,7 +1630,7 @@ const outputOptionsSchema = zod.z.strictObject({
|
|
|
1616
1630
|
comments: zod.z.enum(["none", "preserve-legal"]).describe("Control comments in the output").optional()
|
|
1617
1631
|
});
|
|
1618
1632
|
const getAddonDescription = (placement, wrapper) => {
|
|
1619
|
-
return `Code to insert the ${bold(placement)} of the bundled file (${bold(wrapper)} the wrapper function)`;
|
|
1633
|
+
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
1620
1634
|
};
|
|
1621
1635
|
const outputCliOptionsSchema = outputOptionsSchema.extend({
|
|
1622
1636
|
banner: zod.z.string().describe(getAddonDescription("top", "outside")).optional(),
|
|
@@ -1858,9 +1872,9 @@ else Object.defineProperty(values, option.name, {
|
|
|
1858
1872
|
|
|
1859
1873
|
//#endregion
|
|
1860
1874
|
//#region src/cli/commands/help.ts
|
|
1861
|
-
const introduction = `${gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
1875
|
+
const introduction = `${colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
1862
1876
|
|
|
1863
|
-
${bold(underline("USAGE"))} ${cyan("rolldown -c <config>")} or ${cyan("rolldown <input> <options>")}`;
|
|
1877
|
+
${colors.bold(colors.underline("USAGE"))} ${colors.cyan("rolldown -c <config>")} or ${colors.cyan("rolldown <input> <options>")}`;
|
|
1864
1878
|
const examples = [
|
|
1865
1879
|
{
|
|
1866
1880
|
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
@@ -1892,7 +1906,7 @@ const notes = [
|
|
|
1892
1906
|
function showHelp() {
|
|
1893
1907
|
logger.log(introduction);
|
|
1894
1908
|
logger.log("");
|
|
1895
|
-
logger.log(`${bold(underline("OPTIONS"))}`);
|
|
1909
|
+
logger.log(`${colors.bold(colors.underline("OPTIONS"))}`);
|
|
1896
1910
|
logger.log("");
|
|
1897
1911
|
logger.log(Object.entries(options).sort(([a], [b]) => {
|
|
1898
1912
|
if (options[a].short && !options[b].short) return -1;
|
|
@@ -1905,20 +1919,20 @@ function showHelp() {
|
|
|
1905
1919
|
if (short) optionStr += `-${short}, `;
|
|
1906
1920
|
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
1907
1921
|
if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
|
|
1908
|
-
return cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1922
|
+
return colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1909
1923
|
}).join("\n"));
|
|
1910
1924
|
logger.log("");
|
|
1911
|
-
logger.log(`${bold(underline("EXAMPLES"))}`);
|
|
1925
|
+
logger.log(`${colors.bold(colors.underline("EXAMPLES"))}`);
|
|
1912
1926
|
logger.log("");
|
|
1913
1927
|
examples.forEach(({ title, command }, ord) => {
|
|
1914
1928
|
logger.log(` ${ord + 1}. ${title}:`);
|
|
1915
|
-
logger.log(` ${cyan(command)}`);
|
|
1929
|
+
logger.log(` ${colors.cyan(command)}`);
|
|
1916
1930
|
logger.log("");
|
|
1917
1931
|
});
|
|
1918
|
-
logger.log(`${bold(underline("NOTES"))}`);
|
|
1932
|
+
logger.log(`${colors.bold(colors.underline("NOTES"))}`);
|
|
1919
1933
|
logger.log("");
|
|
1920
1934
|
notes.forEach((note) => {
|
|
1921
|
-
logger.log(` * ${gray(note)}`);
|
|
1935
|
+
logger.log(` * ${colors.gray(note)}`);
|
|
1922
1936
|
});
|
|
1923
1937
|
}
|
|
1924
1938
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('../shared/chunk-
|
|
3
|
-
const require_src = require('../shared/src-
|
|
2
|
+
const require_chunk = require('../shared/chunk-BFvIen8E.cjs');
|
|
3
|
+
const require_src = require('../shared/src-Bs7g4_us.cjs');
|
|
4
4
|
const node_url = require_chunk.__toESM(require("node:url"));
|
|
5
5
|
|
|
6
6
|
//#region src/plugin/parallel-plugin.ts
|
|
@@ -13,6 +13,15 @@ function defineParallelPlugin(pluginPath) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/api/experimental.ts
|
|
18
|
+
const experimental_scan = async (input) => {
|
|
19
|
+
const { bundler, stopWorkers } = await require_src.createBundler(input, {});
|
|
20
|
+
const output = await bundler.scan();
|
|
21
|
+
require_src.handleOutputErrors(output);
|
|
22
|
+
await stopWorkers?.();
|
|
23
|
+
};
|
|
24
|
+
|
|
16
25
|
//#endregion
|
|
17
26
|
//#region src/builtin-plugin/transform-plugin.ts
|
|
18
27
|
function normalizeEcmaTransformPluginConfig(config) {
|
|
@@ -59,7 +68,7 @@ exports.loadFallbackPlugin = require_src.loadFallbackPlugin
|
|
|
59
68
|
exports.manifestPlugin = require_src.manifestPlugin
|
|
60
69
|
exports.modulePreloadPolyfillPlugin = require_src.modulePreloadPolyfillPlugin
|
|
61
70
|
exports.replacePlugin = replacePlugin
|
|
62
|
-
exports.scan =
|
|
71
|
+
exports.scan = experimental_scan
|
|
63
72
|
Object.defineProperty(exports, 'transform', {
|
|
64
73
|
enumerable: true,
|
|
65
74
|
get: function () {
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const require_src = require('../shared/src-
|
|
1
|
+
const require_src = require('../shared/src-Bs7g4_us.cjs');
|
|
2
2
|
|
|
3
3
|
exports.VERSION = require_src.VERSION
|
|
4
|
+
exports.build = require_src.build
|
|
4
5
|
exports.defineConfig = require_src.defineConfig
|
|
5
6
|
exports.rolldown = require_src.rolldown
|
|
6
7
|
exports.watch = require_src.watch
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('../shared/chunk-
|
|
3
|
-
const require_src = require('../shared/src-
|
|
2
|
+
const require_chunk = require('../shared/chunk-BFvIen8E.cjs');
|
|
3
|
+
const require_src = require('../shared/src-Bs7g4_us.cjs');
|
|
4
4
|
const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
|
|
5
5
|
|
|
6
6
|
//#region src/parallel-plugin-worker.ts
|