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/cjs/cli.cjs
CHANGED
|
@@ -1,143 +1,17 @@
|
|
|
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-BKghi7SX.cjs');
|
|
4
|
+
const require_consola_36c0034f = require('../shared/consola_36c0034f-B7L-radJ.cjs');
|
|
5
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
5
6
|
const zod = require_chunk.__toESM(require("zod"));
|
|
6
7
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
7
8
|
const node_process = require_chunk.__toESM(require("node:process"));
|
|
8
9
|
const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
|
|
9
|
-
const
|
|
10
|
+
const tty = require_chunk.__toESM(require("tty"));
|
|
10
11
|
const node_util = require_chunk.__toESM(require("node:util"));
|
|
11
12
|
const node_tty = require_chunk.__toESM(require("node:tty"));
|
|
12
|
-
const
|
|
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 });
|
|
13
|
+
const node_url = require_chunk.__toESM(require("node:url"));
|
|
139
14
|
|
|
140
|
-
//#endregion
|
|
141
15
|
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
142
16
|
const signals = [];
|
|
143
17
|
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
@@ -309,38 +183,224 @@ var SignalExit = class extends SignalExitBase {
|
|
|
309
183
|
const process$2 = globalThis.process;
|
|
310
184
|
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
311
185
|
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
188
|
+
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
189
|
+
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
190
|
+
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
191
|
+
const isWindows = platform === "win32";
|
|
192
|
+
const isDumbTerminal = env$1.TERM === "dumb";
|
|
193
|
+
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
194
|
+
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
195
|
+
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
196
|
+
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));
|
|
197
|
+
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
198
|
+
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
199
|
+
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
200
|
+
const colors$1 = {
|
|
201
|
+
reset: init(0, 0),
|
|
202
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
203
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
204
|
+
italic: init(3, 23),
|
|
205
|
+
underline: init(4, 24),
|
|
206
|
+
inverse: init(7, 27),
|
|
207
|
+
hidden: init(8, 28),
|
|
208
|
+
strikethrough: init(9, 29),
|
|
209
|
+
black: init(30, 39),
|
|
210
|
+
red: init(31, 39),
|
|
211
|
+
green: init(32, 39),
|
|
212
|
+
yellow: init(33, 39),
|
|
213
|
+
blue: init(34, 39),
|
|
214
|
+
magenta: init(35, 39),
|
|
215
|
+
cyan: init(36, 39),
|
|
216
|
+
white: init(37, 39),
|
|
217
|
+
gray: init(90, 39),
|
|
218
|
+
bgBlack: init(40, 49),
|
|
219
|
+
bgRed: init(41, 49),
|
|
220
|
+
bgGreen: init(42, 49),
|
|
221
|
+
bgYellow: init(43, 49),
|
|
222
|
+
bgBlue: init(44, 49),
|
|
223
|
+
bgMagenta: init(45, 49),
|
|
224
|
+
bgCyan: init(46, 49),
|
|
225
|
+
bgWhite: init(47, 49),
|
|
226
|
+
blackBright: init(90, 39),
|
|
227
|
+
redBright: init(91, 39),
|
|
228
|
+
greenBright: init(92, 39),
|
|
229
|
+
yellowBright: init(93, 39),
|
|
230
|
+
blueBright: init(94, 39),
|
|
231
|
+
magentaBright: init(95, 39),
|
|
232
|
+
cyanBright: init(96, 39),
|
|
233
|
+
whiteBright: init(97, 39),
|
|
234
|
+
bgBlackBright: init(100, 49),
|
|
235
|
+
bgRedBright: init(101, 49),
|
|
236
|
+
bgGreenBright: init(102, 49),
|
|
237
|
+
bgYellowBright: init(103, 49),
|
|
238
|
+
bgBlueBright: init(104, 49),
|
|
239
|
+
bgMagentaBright: init(105, 49),
|
|
240
|
+
bgCyanBright: init(106, 49),
|
|
241
|
+
bgWhiteBright: init(107, 49)
|
|
242
|
+
};
|
|
243
|
+
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
|
|
244
|
+
...colors$2,
|
|
245
|
+
[key]: String
|
|
246
|
+
}), {});
|
|
247
|
+
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();
|
|
248
|
+
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/cli/colors.ts
|
|
251
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: node_process.env.FORCE_COLOR !== "0" && !node_process.env.NO_COLOR });
|
|
252
|
+
const colors = {
|
|
253
|
+
bold,
|
|
254
|
+
cyan,
|
|
255
|
+
dim,
|
|
256
|
+
gray,
|
|
257
|
+
green,
|
|
258
|
+
red,
|
|
259
|
+
underline,
|
|
260
|
+
yellow
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/cli/logger.ts
|
|
265
|
+
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : require_consola_36c0034f.createConsola({ formatOptions: { date: false } });
|
|
266
|
+
function createTestingLogger() {
|
|
267
|
+
const types = [
|
|
268
|
+
"silent",
|
|
269
|
+
"fatal",
|
|
270
|
+
"error",
|
|
271
|
+
"warn",
|
|
272
|
+
"log",
|
|
273
|
+
"info",
|
|
274
|
+
"success",
|
|
275
|
+
"fail",
|
|
276
|
+
"ready",
|
|
277
|
+
"start",
|
|
278
|
+
"box",
|
|
279
|
+
"debug",
|
|
280
|
+
"trace",
|
|
281
|
+
"verbose"
|
|
282
|
+
];
|
|
283
|
+
const ret = Object.create(null);
|
|
284
|
+
for (const type of types) ret[type] = console.log;
|
|
285
|
+
return ret;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/cli/load-config.ts
|
|
290
|
+
async function loadTsConfig(configFile) {
|
|
291
|
+
const file = await bundleTsConfig(configFile);
|
|
292
|
+
try {
|
|
293
|
+
return (await import((0, node_url.pathToFileURL)(file).href)).default;
|
|
294
|
+
} finally {
|
|
295
|
+
node_fs.default.unlink(file, () => {});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async function bundleTsConfig(configFile) {
|
|
299
|
+
const dirnameVarName = "injected_original_dirname";
|
|
300
|
+
const filenameVarName = "injected_original_filename";
|
|
301
|
+
const importMetaUrlVarName = "injected_original_import_meta_url";
|
|
302
|
+
const bundle = await require_src.rolldown({
|
|
303
|
+
input: configFile,
|
|
304
|
+
platform: "node",
|
|
305
|
+
resolve: { mainFields: ["main"] },
|
|
306
|
+
define: {
|
|
307
|
+
__dirname: dirnameVarName,
|
|
308
|
+
__filename: filenameVarName,
|
|
309
|
+
"import.meta.url": importMetaUrlVarName,
|
|
310
|
+
"import.meta.dirname": dirnameVarName,
|
|
311
|
+
"import.meta.filename": filenameVarName
|
|
312
|
+
},
|
|
313
|
+
treeshake: false,
|
|
314
|
+
external: [/^[\w@][^:]/],
|
|
315
|
+
plugins: [{
|
|
316
|
+
name: "inject-file-scope-variables",
|
|
317
|
+
transform: {
|
|
318
|
+
filter: { id: /\.[cm]?[jt]s$/ },
|
|
319
|
+
async handler(code, id) {
|
|
320
|
+
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(node_path.default.dirname(id))};` + `const ${filenameVarName} = ${JSON.stringify(id)};` + `const ${importMetaUrlVarName} = ${JSON.stringify((0, node_url.pathToFileURL)(id).href)};`;
|
|
321
|
+
return {
|
|
322
|
+
code: injectValues + code,
|
|
323
|
+
map: null
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}]
|
|
328
|
+
});
|
|
329
|
+
const result = await bundle.write({
|
|
330
|
+
dir: node_path.default.dirname(configFile),
|
|
331
|
+
format: "esm",
|
|
332
|
+
sourcemap: "inline",
|
|
333
|
+
entryFileNames: "rolldown.config.[hash].js"
|
|
334
|
+
});
|
|
335
|
+
return result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
|
|
336
|
+
}
|
|
337
|
+
const SUPPORTED_JS_CONFIG_FORMATS = [
|
|
338
|
+
".js",
|
|
339
|
+
".mjs",
|
|
340
|
+
".cjs"
|
|
341
|
+
];
|
|
342
|
+
const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
343
|
+
".ts",
|
|
344
|
+
".mts",
|
|
345
|
+
".cts"
|
|
346
|
+
];
|
|
347
|
+
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
348
|
+
async function loadConfig(configPath) {
|
|
349
|
+
const ext = node_path.default.extname(configPath);
|
|
350
|
+
try {
|
|
351
|
+
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import((0, node_url.pathToFileURL)(configPath).href)).default;
|
|
352
|
+
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(configPath);
|
|
353
|
+
else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
|
|
354
|
+
} catch (err) {
|
|
355
|
+
throw new Error("Error happened while loading config.", { cause: err });
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
312
359
|
//#endregion
|
|
313
360
|
//#region src/cli/commands/bundle.ts
|
|
314
361
|
async function bundleWithConfig(configPath, cliOptions) {
|
|
315
|
-
const config = await
|
|
362
|
+
const config = await loadConfig(configPath);
|
|
316
363
|
if (!config) {
|
|
317
364
|
logger.error(`No configuration found at ${config}`);
|
|
318
365
|
process.exit(1);
|
|
319
366
|
}
|
|
320
367
|
const configList = require_src.arraify(config);
|
|
321
|
-
|
|
368
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
369
|
+
for (const config$1 of configList) await operation(config$1, cliOptions);
|
|
322
370
|
}
|
|
323
371
|
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 {
|
|
372
|
+
if (cliOptions.output.dir) {
|
|
373
|
+
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
374
|
+
await operation({}, cliOptions);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (cliOptions.watch) {
|
|
336
378
|
logger.error("You must specify `output.dir` to use watch mode");
|
|
337
379
|
process.exit(1);
|
|
338
380
|
}
|
|
381
|
+
const build = await require_src.rolldown(cliOptions.input);
|
|
382
|
+
try {
|
|
383
|
+
const { output: outputs } = await build.generate(cliOptions.output);
|
|
384
|
+
if (outputs.length === 0) {
|
|
385
|
+
logger.error("No output generated");
|
|
386
|
+
process.exit(1);
|
|
387
|
+
}
|
|
388
|
+
for (const file of outputs) {
|
|
389
|
+
if (outputs.length > 1) logger.log(`\n${colors.cyan(colors.bold(`|→ ${file.fileName}:`))}\n`);
|
|
390
|
+
console.log(file.type === "asset" ? file.source : file.code);
|
|
391
|
+
}
|
|
392
|
+
} finally {
|
|
393
|
+
await build.close();
|
|
394
|
+
}
|
|
339
395
|
}
|
|
340
396
|
async function watchInner(options$1, cliOptions) {
|
|
341
397
|
const watcher = await require_src.watch({
|
|
342
398
|
...options$1,
|
|
343
|
-
...cliOptions.input
|
|
399
|
+
...cliOptions.input,
|
|
400
|
+
output: {
|
|
401
|
+
...options$1?.output,
|
|
402
|
+
...cliOptions.output
|
|
403
|
+
}
|
|
344
404
|
});
|
|
345
405
|
onExit((code) => {
|
|
346
406
|
Promise.resolve(watcher.close()).finally(() => {
|
|
@@ -355,11 +415,11 @@ async function watchInner(options$1, cliOptions) {
|
|
|
355
415
|
watcher.on("event", (event) => {
|
|
356
416
|
switch (event.code) {
|
|
357
417
|
case "BUNDLE_START":
|
|
358
|
-
if (changedFile.length > 0) logger.log(`Found ${bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
418
|
+
if (changedFile.length > 0) logger.log(`Found ${colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
359
419
|
changedFile.length = 0;
|
|
360
420
|
break;
|
|
361
421
|
case "BUNDLE_END":
|
|
362
|
-
logger.success(`Rebuilt ${bold(relativeId(event.output[0]))} in ${bold(ms(event.duration))}.`);
|
|
422
|
+
logger.success(`Rebuilt ${colors.bold(relativeId(event.output[0]))} in ${colors.bold(ms(event.duration))}.`);
|
|
363
423
|
break;
|
|
364
424
|
case "ERROR":
|
|
365
425
|
logger.error(event.error);
|
|
@@ -375,15 +435,19 @@ async function bundleInner(options$1, cliOptions) {
|
|
|
375
435
|
...options$1,
|
|
376
436
|
...cliOptions.input
|
|
377
437
|
});
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
438
|
+
try {
|
|
439
|
+
const bundleOutput = await build.write({
|
|
440
|
+
...options$1?.output,
|
|
441
|
+
...cliOptions.output
|
|
442
|
+
});
|
|
443
|
+
const endTime = node_perf_hooks.performance.now();
|
|
444
|
+
printBundleOutputPretty(bundleOutput);
|
|
445
|
+
logger.log(``);
|
|
446
|
+
const duration = endTime - startTime;
|
|
447
|
+
logger.success(`Finished in ${colors.bold(ms(duration))}`);
|
|
448
|
+
} finally {
|
|
449
|
+
await build.close();
|
|
450
|
+
}
|
|
387
451
|
}
|
|
388
452
|
function printBundleOutputPretty(output) {
|
|
389
453
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -430,17 +494,17 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
430
494
|
const filtered = entries.filter((e) => e.type === group.type);
|
|
431
495
|
if (!filtered.length) continue;
|
|
432
496
|
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)}`);
|
|
497
|
+
let log = colors.dim(withTrailingSlash(distPath));
|
|
498
|
+
log += colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
499
|
+
log += colors.dim(entry.type);
|
|
500
|
+
log += colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
437
501
|
logger.log(log);
|
|
438
502
|
}
|
|
439
503
|
}
|
|
440
504
|
}
|
|
441
|
-
function withTrailingSlash(path$
|
|
442
|
-
if (path$
|
|
443
|
-
return path$
|
|
505
|
+
function withTrailingSlash(path$2) {
|
|
506
|
+
if (path$2[path$2.length - 1] !== "/") return `${path$2}/`;
|
|
507
|
+
return path$2;
|
|
444
508
|
}
|
|
445
509
|
function ms(duration) {
|
|
446
510
|
return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
|
|
@@ -1518,12 +1582,13 @@ const watchOptionsSchema = zod.z.strictObject({
|
|
|
1518
1582
|
exclude: stringOrRegExpSchema.optional(),
|
|
1519
1583
|
chokidar: zod.z.any().optional()
|
|
1520
1584
|
});
|
|
1585
|
+
const checksOptionsSchema = zod.z.strictObject({ circularDependency: zod.z.boolean().describe("Wether to emit warnings when detecting circular dependencies").optional() });
|
|
1521
1586
|
const inputOptionsSchema = zod.z.strictObject({
|
|
1522
1587
|
input: inputOptionSchema.optional(),
|
|
1523
1588
|
plugins: phantom().optional(),
|
|
1524
1589
|
external: externalSchema.optional(),
|
|
1525
1590
|
resolve: zod.z.strictObject({
|
|
1526
|
-
alias: zod.z.record(zod.z.string()).optional(),
|
|
1591
|
+
alias: zod.z.record(zod.z.array(zod.z.string()).or(zod.z.string())).optional(),
|
|
1527
1592
|
aliasFields: zod.z.array(zod.z.array(zod.z.string())).optional(),
|
|
1528
1593
|
conditionNames: optionalStringArray(),
|
|
1529
1594
|
extensionAlias: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())).optional(),
|
|
@@ -1536,10 +1601,10 @@ const inputOptionsSchema = zod.z.strictObject({
|
|
|
1536
1601
|
tsconfigFilename: zod.z.string().optional()
|
|
1537
1602
|
}).optional(),
|
|
1538
1603
|
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(),
|
|
1604
|
+
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
1605
|
shimMissingExports: zod.z.boolean().describe(`Create shim variables for missing exports`).optional(),
|
|
1541
1606
|
treeshake: require_src.TreeshakingOptionsSchema.optional(),
|
|
1542
|
-
logLevel: require_src.LogLevelOptionSchema.describe(`Log level (${dim("silent")}, ${underline(gray("info"))}, debug, ${yellow("warn")})`).optional(),
|
|
1607
|
+
logLevel: require_src.LogLevelOptionSchema.describe(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`).optional(),
|
|
1543
1608
|
onLog: zod.z.function().args(require_src.LogLevelSchema, require_src.RollupLogSchema, zod.z.function().args(require_src.LogLevelWithErrorSchema, require_src.RollupLogWithStringSchema)).optional(),
|
|
1544
1609
|
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
1610
|
moduleTypes: moduleTypesSchema.describe("Module types for customized extensions").optional(),
|
|
@@ -1554,7 +1619,8 @@ const inputOptionsSchema = zod.z.strictObject({
|
|
|
1554
1619
|
profilerNames: zod.z.boolean().optional(),
|
|
1555
1620
|
jsx: jsxOptionsSchema.optional(),
|
|
1556
1621
|
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()
|
|
1622
|
+
dropLabels: zod.z.array(zod.z.string()).describe("Remove labeled statements with these label names").optional(),
|
|
1623
|
+
checks: checksOptionsSchema.optional()
|
|
1558
1624
|
});
|
|
1559
1625
|
const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
1560
1626
|
external: zod.z.array(zod.z.string()).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`").optional(),
|
|
@@ -1573,17 +1639,17 @@ const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
|
1573
1639
|
|
|
1574
1640
|
//#endregion
|
|
1575
1641
|
//#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)`);
|
|
1642
|
+
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
1643
|
const addonFunctionSchema = zod.z.function().args(phantom()).returns(zod.z.string().or(zod.z.promise(zod.z.string())));
|
|
1578
1644
|
const chunkFileNamesFunctionSchema = zod.z.function().args(phantom()).returns(zod.z.string());
|
|
1579
1645
|
const GlobalsFunctionSchema = zod.z.function().args(zod.z.string()).returns(zod.z.string());
|
|
1580
1646
|
const outputOptionsSchema = zod.z.strictObject({
|
|
1581
1647
|
dir: zod.z.string().describe("Output directory, defaults to `dist` if `file` is not set").optional(),
|
|
1582
1648
|
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(),
|
|
1649
|
+
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
1650
|
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
1651
|
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(),
|
|
1652
|
+
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
1653
|
sourcemapIgnoreList: zod.z.boolean().or(phantom()).optional(),
|
|
1588
1654
|
sourcemapPathTransform: phantom().optional(),
|
|
1589
1655
|
banner: zod.z.string().or(addonFunctionSchema).optional(),
|
|
@@ -1616,7 +1682,7 @@ const outputOptionsSchema = zod.z.strictObject({
|
|
|
1616
1682
|
comments: zod.z.enum(["none", "preserve-legal"]).describe("Control comments in the output").optional()
|
|
1617
1683
|
});
|
|
1618
1684
|
const getAddonDescription = (placement, wrapper) => {
|
|
1619
|
-
return `Code to insert the ${bold(placement)} of the bundled file (${bold(wrapper)} the wrapper function)`;
|
|
1685
|
+
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
1620
1686
|
};
|
|
1621
1687
|
const outputCliOptionsSchema = outputOptionsSchema.extend({
|
|
1622
1688
|
banner: zod.z.string().describe(getAddonDescription("top", "outside")).optional(),
|
|
@@ -1704,8 +1770,8 @@ else base[key] = value;
|
|
|
1704
1770
|
}
|
|
1705
1771
|
return base;
|
|
1706
1772
|
}
|
|
1707
|
-
function setNestedProperty(obj, path$
|
|
1708
|
-
const keys = path$
|
|
1773
|
+
function setNestedProperty(obj, path$2, value) {
|
|
1774
|
+
const keys = path$2.split(".");
|
|
1709
1775
|
let current = obj;
|
|
1710
1776
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
1711
1777
|
if (!current[keys[i]]) current[keys[i]] = {};
|
|
@@ -1858,9 +1924,9 @@ else Object.defineProperty(values, option.name, {
|
|
|
1858
1924
|
|
|
1859
1925
|
//#endregion
|
|
1860
1926
|
//#region src/cli/commands/help.ts
|
|
1861
|
-
const introduction = `${gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
1927
|
+
const introduction = `${colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
1862
1928
|
|
|
1863
|
-
${bold(underline("USAGE"))} ${cyan("rolldown -c <config>")} or ${cyan("rolldown <input> <options>")}`;
|
|
1929
|
+
${colors.bold(colors.underline("USAGE"))} ${colors.cyan("rolldown -c <config>")} or ${colors.cyan("rolldown <input> <options>")}`;
|
|
1864
1930
|
const examples = [
|
|
1865
1931
|
{
|
|
1866
1932
|
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
@@ -1892,7 +1958,7 @@ const notes = [
|
|
|
1892
1958
|
function showHelp() {
|
|
1893
1959
|
logger.log(introduction);
|
|
1894
1960
|
logger.log("");
|
|
1895
|
-
logger.log(`${bold(underline("OPTIONS"))}`);
|
|
1961
|
+
logger.log(`${colors.bold(colors.underline("OPTIONS"))}`);
|
|
1896
1962
|
logger.log("");
|
|
1897
1963
|
logger.log(Object.entries(options).sort(([a], [b]) => {
|
|
1898
1964
|
if (options[a].short && !options[b].short) return -1;
|
|
@@ -1905,20 +1971,20 @@ function showHelp() {
|
|
|
1905
1971
|
if (short) optionStr += `-${short}, `;
|
|
1906
1972
|
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
1907
1973
|
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(".") ? "" : ".");
|
|
1974
|
+
return colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
1909
1975
|
}).join("\n"));
|
|
1910
1976
|
logger.log("");
|
|
1911
|
-
logger.log(`${bold(underline("EXAMPLES"))}`);
|
|
1977
|
+
logger.log(`${colors.bold(colors.underline("EXAMPLES"))}`);
|
|
1912
1978
|
logger.log("");
|
|
1913
1979
|
examples.forEach(({ title, command }, ord) => {
|
|
1914
1980
|
logger.log(` ${ord + 1}. ${title}:`);
|
|
1915
|
-
logger.log(` ${cyan(command)}`);
|
|
1981
|
+
logger.log(` ${colors.cyan(command)}`);
|
|
1916
1982
|
logger.log("");
|
|
1917
1983
|
});
|
|
1918
|
-
logger.log(`${bold(underline("NOTES"))}`);
|
|
1984
|
+
logger.log(`${colors.bold(colors.underline("NOTES"))}`);
|
|
1919
1985
|
logger.log("");
|
|
1920
1986
|
notes.forEach((note) => {
|
|
1921
|
-
logger.log(` * ${gray(note)}`);
|
|
1987
|
+
logger.log(` * ${colors.gray(note)}`);
|
|
1922
1988
|
});
|
|
1923
1989
|
}
|
|
1924
1990
|
|
|
@@ -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-BKghi7SX.cjs');
|
|
4
4
|
const node_url = require_chunk.__toESM(require("node:url"));
|
|
5
5
|
|
|
6
6
|
//#region src/plugin/parallel-plugin.ts
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -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-BKghi7SX.cjs');
|
|
4
4
|
const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
|
|
5
5
|
|
|
6
6
|
//#region src/parallel-plugin-worker.ts
|