rolldown 0.15.0-snapshot-5e456b6-20241203003703 → 0.15.0-snapshot-993c4a1-20241205003858

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 CHANGED
@@ -1,143 +1,16 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-BK2Ye-xa.cjs');
3
- const require_src = require('../shared/src-COU7qQBJ.cjs');
3
+ const require_src = require('../shared/src-BIbmsUlX.cjs');
4
4
  const require_consola_36c0034f = require('../shared/consola_36c0034f-_8_dG1Nr.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,133 @@ 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 = {
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 : Object.keys(colors).reduce((colors$1, key) => ({
243
+ ...colors$1,
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
+ var colors_exports = {};
251
+ __export(colors_exports, {
252
+ bold: () => bold,
253
+ cyan: () => cyan,
254
+ dim: () => dim,
255
+ gray: () => gray,
256
+ green: () => green,
257
+ red: () => red,
258
+ underline: () => underline,
259
+ yellow: () => yellow
260
+ });
261
+ const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: node_process.env.FORCE_COLOR !== "0" && !node_process.env.NO_COLOR });
262
+
263
+ //#endregion
264
+ //#region src/cli/utils.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
+ async function ensureConfig(configPath) {
288
+ const fileUrl = (0, node_url.pathToFileURL)(configPath).toString();
289
+ let configExports;
290
+ try {
291
+ configExports = await import(fileUrl);
292
+ } catch (err) {
293
+ let errorMessage = "Error happened while loading config.";
294
+ if (!isSupportedFormat(configPath)) errorMessage += ` Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${node_path.default.extname(configPath)}\``;
295
+ throw new Error(errorMessage, { cause: err });
296
+ }
297
+ return configExports.default;
298
+ }
299
+ const SUPPORTED_CONFIG_FORMATS = [
300
+ ".js",
301
+ ".mjs",
302
+ ".cjs"
303
+ ];
304
+ /**
305
+ * Check whether the configuration file is supported
306
+ */
307
+ function isSupportedFormat(configPath) {
308
+ const ext = node_path.default.extname(configPath);
309
+ return SUPPORTED_CONFIG_FORMATS.includes(ext);
310
+ }
311
+
312
312
  //#endregion
313
313
  //#region src/cli/commands/bundle.ts
314
314
  async function bundleWithConfig(configPath, cliOptions) {
@@ -318,24 +318,33 @@ async function bundleWithConfig(configPath, cliOptions) {
318
318
  process.exit(1);
319
319
  }
320
320
  const configList = require_src.arraify(config);
321
- for (const config$1 of configList) cliOptions.watch ? await watchInner(config$1, cliOptions) : bundleInner(config$1, cliOptions);
321
+ const operation = cliOptions.watch ? watchInner : bundleInner;
322
+ for (const config$1 of configList) await operation(config$1, cliOptions);
322
323
  }
323
324
  async function bundleWithCliOptions(cliOptions) {
324
- if (cliOptions.output.dir) cliOptions.watch ? await watchInner({}, cliOptions) : await bundleInner({}, cliOptions);
325
- else if (!cliOptions.watch) {
326
- const build = await require_src.rolldown(cliOptions.input);
327
- const { output } = await build.generate(cliOptions.output);
328
- if (output.length > 1) {
329
- logger.error("Multiple chunks are not supported to display in stdout");
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 {
325
+ if (cliOptions.output.dir) {
326
+ const operation = cliOptions.watch ? watchInner : bundleInner;
327
+ await operation({}, cliOptions);
328
+ return;
329
+ }
330
+ if (cliOptions.watch) {
336
331
  logger.error("You must specify `output.dir` to use watch mode");
337
332
  process.exit(1);
338
333
  }
334
+ const build = await require_src.rolldown(cliOptions.input);
335
+ try {
336
+ const { output: outputs } = await build.generate(cliOptions.output);
337
+ if (outputs.length === 0) {
338
+ logger.error("No output generated");
339
+ process.exit(1);
340
+ }
341
+ for (const file of outputs) {
342
+ if (outputs.length > 1) logger.log(`\n${cyan(bold(`|→ ${file.fileName}:`))}\n`);
343
+ logger.log(file.type === "asset" ? file.source : file.code);
344
+ }
345
+ } finally {
346
+ await build.close();
347
+ }
339
348
  }
340
349
  async function watchInner(options$1, cliOptions) {
341
350
  const watcher = await require_src.watch({
@@ -375,15 +384,19 @@ async function bundleInner(options$1, cliOptions) {
375
384
  ...options$1,
376
385
  ...cliOptions.input
377
386
  });
378
- const bundleOutput = await build.write({
379
- ...options$1?.output,
380
- ...cliOptions.output
381
- });
382
- const endTime = node_perf_hooks.performance.now();
383
- printBundleOutputPretty(bundleOutput);
384
- logger.log(``);
385
- const duration = endTime - startTime;
386
- logger.success(`Finished in ${bold(ms(duration))}`);
387
+ try {
388
+ const bundleOutput = await build.write({
389
+ ...options$1?.output,
390
+ ...cliOptions.output
391
+ });
392
+ const endTime = node_perf_hooks.performance.now();
393
+ printBundleOutputPretty(bundleOutput);
394
+ logger.log(``);
395
+ const duration = endTime - startTime;
396
+ logger.success(`Finished in ${bold(ms(duration))}`);
397
+ } finally {
398
+ await build.close();
399
+ }
387
400
  }
388
401
  function printBundleOutputPretty(output) {
389
402
  const outputEntries = collectOutputEntries(output.output);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-BK2Ye-xa.cjs');
3
- const require_src = require('../shared/src-COU7qQBJ.cjs');
3
+ const require_src = require('../shared/src-BIbmsUlX.cjs');
4
4
  const node_url = require_chunk.__toESM(require("node:url"));
5
5
 
6
6
  //#region src/plugin/parallel-plugin.ts
@@ -1,4 +1,4 @@
1
- const require_src = require('../shared/src-COU7qQBJ.cjs');
1
+ const require_src = require('../shared/src-BIbmsUlX.cjs');
2
2
 
3
3
  exports.VERSION = require_src.VERSION
4
4
  exports.build = require_src.build
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-BK2Ye-xa.cjs');
3
- const require_src = require('../shared/src-COU7qQBJ.cjs');
3
+ const require_src = require('../shared/src-BIbmsUlX.cjs');
4
4
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
5
5
 
6
6
  //#region src/parallel-plugin-worker.ts