rolldown 1.0.0-beta.1-commit.1d4a330 → 1.0.0-beta.1-commit.298dd8b

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,10 +1,11 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-B7GNdu2r.cjs');
4
- const require_consola_36c0034f = require('../shared/consola_36c0034f-CnRr1OYk.cjs');
5
- const node_fs = require_chunk.__toESM(require("node:fs"));
6
- const node_path = require_chunk.__toESM(require("node:path"));
3
+ const require_src = require('../shared/src-BYsFiN-a.cjs');
4
+ const require_binding = require('../shared/binding-D5MBYAdC.cjs');
5
+ const require_consola_36c0034f = require('../shared/consola_36c0034f-CynBWXXO.cjs');
7
6
  const node_process = require_chunk.__toESM(require("node:process"));
7
+ const node_path = require_chunk.__toESM(require("node:path"));
8
+ const node_fs = require_chunk.__toESM(require("node:fs"));
8
9
  const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
9
10
  const node_util = require_chunk.__toESM(require("node:util"));
10
11
  const node_tty = require_chunk.__toESM(require("node:tty"));
@@ -320,7 +321,7 @@ async function bundleWithCliOptions(cliOptions) {
320
321
  process.exit(1);
321
322
  }
322
323
  for (const file of outputs) {
323
- if (outputs.length > 1) logger.log(`\n${require_src.colors.cyan(require_src.colors.bold(`|→ ${file.fileName}:`))}\n`);
324
+ if (outputs.length > 1) logger.log(`\n${require_binding.colors.cyan(require_binding.colors.bold(`|→ ${file.fileName}:`))}\n`);
324
325
  console.log(file.type === "asset" ? file.source : file.code);
325
326
  }
326
327
  } finally {
@@ -354,11 +355,11 @@ async function watchInner(config, cliOptions) {
354
355
  watcher.on("event", (event) => {
355
356
  switch (event.code) {
356
357
  case "BUNDLE_START":
357
- if (changedFile.length > 0) logger.log(`Found ${require_src.colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
358
+ if (changedFile.length > 0) logger.log(`Found ${require_binding.colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
358
359
  changedFile.length = 0;
359
360
  break;
360
361
  case "BUNDLE_END":
361
- logger.success(`Rebuilt ${require_src.colors.bold(relativeId(event.output[0]))} in ${require_src.colors.bold(ms(event.duration))}.`);
362
+ logger.success(`Rebuilt ${require_binding.colors.bold(relativeId(event.output[0]))} in ${require_binding.colors.bold(ms(event.duration))}.`);
362
363
  break;
363
364
  case "ERROR":
364
365
  logger.error(event.error);
@@ -374,26 +375,24 @@ async function bundleInner(config, cliOptions) {
374
375
  const configList = require_src.arraify(config);
375
376
  for (const config$1 of configList) {
376
377
  const outputList = require_src.arraify(config$1.output || {});
377
- for (const output of outputList) {
378
- const build = await require_src.rolldown({
379
- ...config$1,
380
- ...cliOptions.input
381
- });
382
- try {
383
- result.push(await build.write({
384
- ...output,
385
- ...cliOptions.output
386
- }));
387
- } finally {
388
- await build.close();
389
- }
378
+ const build = await require_src.rolldown({
379
+ ...config$1,
380
+ ...cliOptions.input
381
+ });
382
+ for (const output of outputList) try {
383
+ result.push(await build.write({
384
+ ...output,
385
+ ...cliOptions.output
386
+ }));
387
+ } finally {
388
+ await build.close();
390
389
  }
391
390
  }
392
391
  result.forEach(printBundleOutputPretty);
393
392
  logger.log(``);
394
393
  const endTime = node_perf_hooks.performance.now();
395
394
  const duration = endTime - startTime;
396
- logger.success(`Finished in ${require_src.colors.bold(ms(duration))}`);
395
+ logger.success(`Finished in ${require_binding.colors.bold(ms(duration))}`);
397
396
  }
398
397
  function printBundleOutputPretty(output) {
399
398
  const outputEntries = collectOutputEntries(output.output);
@@ -440,10 +439,10 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
440
439
  const filtered = entries.filter((e) => e.type === group.type);
441
440
  if (!filtered.length) continue;
442
441
  for (const entry of filtered.sort((a, z) => a.size - z.size)) {
443
- let log = require_src.colors.dim(withTrailingSlash(distPath));
444
- log += require_src.colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
445
- log += require_src.colors.dim(entry.type);
446
- log += require_src.colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
442
+ let log = require_binding.colors.dim(withTrailingSlash(distPath));
443
+ log += require_binding.colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
444
+ log += require_binding.colors.dim(entry.type);
445
+ log += require_binding.colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
447
446
  logger.log(log);
448
447
  }
449
448
  }
@@ -680,9 +679,9 @@ function parseCliArguments() {
680
679
 
681
680
  //#endregion
682
681
  //#region src/cli/commands/help.ts
683
- const introduction = `${require_src.colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
682
+ const introduction = `${require_binding.colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
684
683
 
685
- ${require_src.colors.bold(require_src.colors.underline("USAGE"))} ${require_src.colors.cyan("rolldown -c <config>")} or ${require_src.colors.cyan("rolldown <input> <options>")}`;
684
+ ${require_binding.colors.bold(require_binding.colors.underline("USAGE"))} ${require_binding.colors.cyan("rolldown -c <config>")} or ${require_binding.colors.cyan("rolldown <input> <options>")}`;
686
685
  const examples = [
687
686
  {
688
687
  title: "Bundle with a config file `rolldown.config.mjs`",
@@ -714,7 +713,7 @@ const notes = [
714
713
  function showHelp() {
715
714
  logger.log(introduction);
716
715
  logger.log("");
717
- logger.log(`${require_src.colors.bold(require_src.colors.underline("OPTIONS"))}`);
716
+ logger.log(`${require_binding.colors.bold(require_binding.colors.underline("OPTIONS"))}`);
718
717
  logger.log("");
719
718
  logger.log(Object.entries(options).sort(([a], [b]) => {
720
719
  if (options[a].short && !options[b].short) return -1;
@@ -727,20 +726,20 @@ function showHelp() {
727
726
  if (short) optionStr += `-${short}, `;
728
727
  if (type === "string") optionStr += `<${hint ?? option}>`;
729
728
  if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
730
- return require_src.colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
729
+ return require_binding.colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
731
730
  }).join("\n"));
732
731
  logger.log("");
733
- logger.log(`${require_src.colors.bold(require_src.colors.underline("EXAMPLES"))}`);
732
+ logger.log(`${require_binding.colors.bold(require_binding.colors.underline("EXAMPLES"))}`);
734
733
  logger.log("");
735
734
  examples.forEach(({ title, command }, ord) => {
736
735
  logger.log(` ${ord + 1}. ${title}:`);
737
- logger.log(` ${require_src.colors.cyan(command)}`);
736
+ logger.log(` ${require_binding.colors.cyan(command)}`);
738
737
  logger.log("");
739
738
  });
740
- logger.log(`${require_src.colors.bold(require_src.colors.underline("NOTES"))}`);
739
+ logger.log(`${require_binding.colors.bold(require_binding.colors.underline("NOTES"))}`);
741
740
  logger.log("");
742
741
  notes.forEach((note) => {
743
- logger.log(` * ${require_src.colors.gray(note)}`);
742
+ logger.log(` * ${require_binding.colors.gray(note)}`);
744
743
  });
745
744
  }
746
745
 
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-B7GNdu2r.cjs');
3
+ const require_src = require('../shared/src-BYsFiN-a.cjs');
4
+ const require_binding$1 = require('../shared/binding-D5MBYAdC.cjs');
4
5
  const node_url = require_chunk.__toESM(require("node:url"));
5
6
 
6
7
  //#region src/plugin/parallel-plugin.ts
@@ -54,7 +55,7 @@ function aliasPlugin(config) {
54
55
 
55
56
  //#endregion
56
57
  //#region src/experimental-index.ts
57
- var import_binding = require_chunk.__toESM(require_src.require_binding());
58
+ var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
58
59
 
59
60
  //#endregion
60
61
  exports.aliasPlugin = aliasPlugin
@@ -66,6 +67,7 @@ exports.importGlobPlugin = require_src.importGlobPlugin
66
67
  exports.jsonPlugin = require_src.jsonPlugin
67
68
  exports.loadFallbackPlugin = require_src.loadFallbackPlugin
68
69
  exports.manifestPlugin = require_src.manifestPlugin
70
+ exports.moduleFederationPlugin = require_src.moduleFederationPlugin
69
71
  exports.modulePreloadPolyfillPlugin = require_src.modulePreloadPolyfillPlugin
70
72
  exports.replacePlugin = replacePlugin
71
73
  exports.scan = experimental_scan
@@ -1,4 +1,5 @@
1
- const require_src = require('../shared/src-B7GNdu2r.cjs');
1
+ const require_src = require('../shared/src-BYsFiN-a.cjs');
2
+ require('../shared/binding-D5MBYAdC.cjs');
2
3
 
3
4
  exports.VERSION = require_src.VERSION
4
5
  exports.build = require_src.build
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-B7GNdu2r.cjs');
3
+ const require_src = require('../shared/src-BYsFiN-a.cjs');
4
+ const require_binding$1 = require('../shared/binding-D5MBYAdC.cjs');
4
5
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
5
6
 
6
7
  //#region src/parallel-plugin-worker.ts
7
- var import_binding = require_chunk.__toESM(require_src.require_binding());
8
+ var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
8
9
  const { registryId, pluginInfos, threadNumber } = node_worker_threads.workerData;
9
10
  (async () => {
10
11
  try {
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
+ const require_binding$1 = require('../shared/binding-D5MBYAdC.cjs');
4
+
5
+ //#region src/parse-ast-index.ts
6
+ var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
7
+ function wrap(result, sourceText) {
8
+ let program, module$1, comments, errors, magicString;
9
+ return {
10
+ get program() {
11
+ if (!errors) errors = result.errors;
12
+ if (errors.length > 0) return normalizeParseError(sourceText, errors);
13
+ if (!program) program = JSON.parse(result.program);
14
+ return program;
15
+ },
16
+ get module() {
17
+ if (!module$1) module$1 = result.module;
18
+ return module$1;
19
+ },
20
+ get comments() {
21
+ if (!comments) comments = result.comments;
22
+ return comments;
23
+ },
24
+ get errors() {
25
+ if (!errors) errors = result.errors;
26
+ return errors;
27
+ },
28
+ get magicString() {
29
+ if (!magicString) magicString = result.magicString;
30
+ return magicString;
31
+ }
32
+ };
33
+ }
34
+ function normalizeParseError(sourceText, errors) {
35
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
36
+ for (let i = 0; i < errors.length; i++) {
37
+ if (i >= 5) {
38
+ message += "\n...";
39
+ break;
40
+ }
41
+ const e = errors[i];
42
+ message += e.message + "\n" + e.labels.map((label) => {
43
+ const location = require_binding$1.locate(sourceText, label.start, { offsetLine: 1 });
44
+ if (!location) return;
45
+ return require_binding$1.getCodeFrame(sourceText, location.line, location.column);
46
+ }).filter(Boolean).join("\n");
47
+ }
48
+ return require_binding$1.error(require_binding$1.logParseError(message));
49
+ }
50
+ function parseAst(filename, sourceText, options) {
51
+ return wrap((0, import_binding.parseSync)(filename, sourceText, options), sourceText);
52
+ }
53
+ async function parseAstAsync(filename, sourceText, options) {
54
+ return wrap(await (0, import_binding.parseAsync)(filename, sourceText, options), sourceText);
55
+ }
56
+
57
+ //#endregion
58
+ exports.parseAst = parseAst
59
+ exports.parseAstAsync = parseAstAsync
package/dist/esm/cli.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import { arraify, colors, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-BKtzXvhI.mjs";
2
- import { createConsola } from "../shared/consola_36c0034f-rAZL9aWp.mjs";
3
- import fs from "node:fs";
4
- import path from "node:path";
1
+ import { colors } from "../shared/binding-DLjQWzkm.mjs";
2
+ import { arraify, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-BiKHJ1rU.mjs";
3
+ import { createConsola } from "../shared/consola_36c0034f-Cx52UqEq.mjs";
5
4
  import process$1, { cwd } from "node:process";
5
+ import path from "node:path";
6
+ import fs from "node:fs";
6
7
  import { performance } from "node:perf_hooks";
7
8
  import { parseArgs } from "node:util";
8
9
  import { readdir } from "node:fs/promises";
@@ -371,19 +372,17 @@ async function bundleInner(config, cliOptions) {
371
372
  const configList = arraify(config);
372
373
  for (const config$1 of configList) {
373
374
  const outputList = arraify(config$1.output || {});
374
- for (const output of outputList) {
375
- const build = await rolldown({
376
- ...config$1,
377
- ...cliOptions.input
378
- });
379
- try {
380
- result.push(await build.write({
381
- ...output,
382
- ...cliOptions.output
383
- }));
384
- } finally {
385
- await build.close();
386
- }
375
+ const build = await rolldown({
376
+ ...config$1,
377
+ ...cliOptions.input
378
+ });
379
+ for (const output of outputList) try {
380
+ result.push(await build.write({
381
+ ...output,
382
+ ...cliOptions.output
383
+ }));
384
+ } finally {
385
+ await build.close();
387
386
  }
388
387
  }
389
388
  result.forEach(printBundleOutputPretty);
@@ -1,4 +1,5 @@
1
- import { BuiltinPlugin, __toESM, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-BKtzXvhI.mjs";
1
+ import { __toESM, require_binding } from "../shared/binding-DLjQWzkm.mjs";
2
+ import { BuiltinPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-BiKHJ1rU.mjs";
2
3
  import { pathToFileURL } from "node:url";
3
4
 
4
5
  //#region src/plugin/parallel-plugin.ts
@@ -56,4 +57,4 @@ var import_binding = __toESM(require_binding());
56
57
 
57
58
  //#endregion
58
59
  var transform = import_binding.transform;
59
- export { aliasPlugin, buildImportAnalysisPlugin, composeJsPlugins as composePlugins, defineParallelPlugin, dynamicImportVarsPlugin, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, replacePlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin };
60
+ export { aliasPlugin, buildImportAnalysisPlugin, composeJsPlugins as composePlugins, defineParallelPlugin, dynamicImportVarsPlugin, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, replacePlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin };
@@ -1,3 +1,4 @@
1
- import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-BKtzXvhI.mjs";
1
+ import "../shared/binding-DLjQWzkm.mjs";
2
+ import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-BiKHJ1rU.mjs";
2
3
 
3
4
  export { VERSION, build, defineConfig, rolldown, watch };
@@ -1,4 +1,5 @@
1
- import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src-BKtzXvhI.mjs";
1
+ import { __toESM, require_binding } from "../shared/binding-DLjQWzkm.mjs";
2
+ import { PluginContextData, bindingifyPlugin } from "../shared/src-BiKHJ1rU.mjs";
2
3
  import { parentPort, workerData } from "node:worker_threads";
3
4
 
4
5
  //#region src/parallel-plugin-worker.ts
@@ -0,0 +1,56 @@
1
+ import { __toESM, error, getCodeFrame, locate, logParseError, require_binding } from "../shared/binding-DLjQWzkm.mjs";
2
+
3
+ //#region src/parse-ast-index.ts
4
+ var import_binding = __toESM(require_binding());
5
+ function wrap(result, sourceText) {
6
+ let program, module, comments, errors, magicString;
7
+ return {
8
+ get program() {
9
+ if (!errors) errors = result.errors;
10
+ if (errors.length > 0) return normalizeParseError(sourceText, errors);
11
+ if (!program) program = JSON.parse(result.program);
12
+ return program;
13
+ },
14
+ get module() {
15
+ if (!module) module = result.module;
16
+ return module;
17
+ },
18
+ get comments() {
19
+ if (!comments) comments = result.comments;
20
+ return comments;
21
+ },
22
+ get errors() {
23
+ if (!errors) errors = result.errors;
24
+ return errors;
25
+ },
26
+ get magicString() {
27
+ if (!magicString) magicString = result.magicString;
28
+ return magicString;
29
+ }
30
+ };
31
+ }
32
+ function normalizeParseError(sourceText, errors) {
33
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
34
+ for (let i = 0; i < errors.length; i++) {
35
+ if (i >= 5) {
36
+ message += "\n...";
37
+ break;
38
+ }
39
+ const e = errors[i];
40
+ message += e.message + "\n" + e.labels.map((label) => {
41
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
42
+ if (!location) return;
43
+ return getCodeFrame(sourceText, location.line, location.column);
44
+ }).filter(Boolean).join("\n");
45
+ }
46
+ return error(logParseError(message));
47
+ }
48
+ function parseAst(filename, sourceText, options) {
49
+ return wrap((0, import_binding.parseSync)(filename, sourceText, options), sourceText);
50
+ }
51
+ async function parseAstAsync(filename, sourceText, options) {
52
+ return wrap(await (0, import_binding.parseAsync)(filename, sourceText, options), sourceText);
53
+ }
54
+
55
+ //#endregion
56
+ export { parseAst, parseAstAsync };