rolldown 1.0.0-beta.3-commit.fc7dd8c → 1.0.0-beta.3-commit.de6e9d2

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,7 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-C5fd4TKF.cjs');
4
- const require_binding = require('../shared/binding-DTKqYZn-.cjs');
3
+ const require_src = require('../shared/src-BHgxMyK2.cjs');
4
+ const require_parse_ast_index = require('../shared/parse-ast-index-p24sJjY3.cjs');
5
5
  const node_process = require_chunk.__toESM(require("node:process"));
6
6
  const node_path = require_chunk.__toESM(require("node:path"));
7
7
  const node_fs = require_chunk.__toESM(require("node:fs"));
@@ -952,11 +952,11 @@ function n(e) {
952
952
  return e ? e !== "false" : false;
953
953
  }
954
954
  const I = globalThis.process?.platform || "", T = n(s$1.CI) || l.ci !== false, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), U = n(s$1.DEBUG), A = t === "test" || n(s$1.TEST);
955
- n(s$1.MINIMAL) || T || A || !R;
955
+ n(s$1.MINIMAL);
956
956
  const _ = /^win/i.test(I);
957
- !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM !== "dumb" || T);
957
+ !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM !== "dumb");
958
958
  const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
959
- Number(C?.split(".")[0]) || null;
959
+ Number(C?.split(".")[0]);
960
960
  const y = globalThis.process || Object.create(null), c = { versions: {} };
961
961
  new Proxy(y, { get(e, o) {
962
962
  if (o === "env") return s$1;
@@ -977,7 +977,7 @@ function G() {
977
977
  if (e) return { name: e[1] };
978
978
  }
979
979
  const u = G();
980
- u?.name || "";
980
+ u?.name;
981
981
  function ansiRegex({ onlyFirst = false } = {}) {
982
982
  const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
983
983
  const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
@@ -1277,7 +1277,7 @@ async function bundleWithCliOptions(cliOptions) {
1277
1277
  process.exit(1);
1278
1278
  }
1279
1279
  for (const file of outputs) {
1280
- if (outputs.length > 1) logger.log(`\n${require_binding.colors.cyan(require_binding.colors.bold(`|→ ${file.fileName}:`))}\n`);
1280
+ if (outputs.length > 1) logger.log(`\n${require_parse_ast_index.colors.cyan(require_parse_ast_index.colors.bold(`|→ ${file.fileName}:`))}\n`);
1281
1281
  console.log(file.type === "asset" ? file.source : file.code);
1282
1282
  }
1283
1283
  } finally {
@@ -1311,11 +1311,11 @@ async function watchInner(config, cliOptions) {
1311
1311
  watcher.on("event", (event) => {
1312
1312
  switch (event.code) {
1313
1313
  case "BUNDLE_START":
1314
- if (changedFile.length > 0) logger.log(`Found ${require_binding.colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
1314
+ if (changedFile.length > 0) logger.log(`Found ${require_parse_ast_index.colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
1315
1315
  changedFile.length = 0;
1316
1316
  break;
1317
1317
  case "BUNDLE_END":
1318
- logger.success(`Rebuilt ${require_binding.colors.bold(relativeId(event.output[0]))} in ${require_binding.colors.bold(ms(event.duration))}.`);
1318
+ logger.success(`Rebuilt ${require_parse_ast_index.colors.bold(relativeId(event.output[0]))} in ${require_parse_ast_index.colors.bold(ms(event.duration))}.`);
1319
1319
  break;
1320
1320
  case "ERROR":
1321
1321
  logger.error(event.error);
@@ -1348,7 +1348,7 @@ async function bundleInner(config, cliOptions) {
1348
1348
  logger.log(``);
1349
1349
  const endTime = node_perf_hooks.performance.now();
1350
1350
  const duration = endTime - startTime;
1351
- logger.success(`Finished in ${require_binding.colors.bold(ms(duration))}`);
1351
+ logger.success(`Finished in ${require_parse_ast_index.colors.bold(ms(duration))}`);
1352
1352
  }
1353
1353
  function printBundleOutputPretty(output) {
1354
1354
  const outputEntries = collectOutputEntries(output.output);
@@ -1395,10 +1395,10 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
1395
1395
  const filtered = entries.filter((e) => e.type === group.type);
1396
1396
  if (!filtered.length) continue;
1397
1397
  for (const entry of filtered.sort((a$1, z) => a$1.size - z.size)) {
1398
- let log = require_binding.colors.dim(withTrailingSlash(distPath));
1399
- log += require_binding.colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
1400
- log += require_binding.colors.dim(entry.type);
1401
- log += require_binding.colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
1398
+ let log = require_parse_ast_index.colors.dim(withTrailingSlash(distPath));
1399
+ log += require_parse_ast_index.colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
1400
+ log += require_parse_ast_index.colors.dim(entry.type);
1401
+ log += require_parse_ast_index.colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
1402
1402
  logger.log(log);
1403
1403
  }
1404
1404
  }
@@ -1635,9 +1635,9 @@ function parseCliArguments() {
1635
1635
 
1636
1636
  //#endregion
1637
1637
  //#region src/cli/commands/help.ts
1638
- const introduction = `${require_binding.colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
1638
+ const introduction = `${require_parse_ast_index.colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
1639
1639
 
1640
- ${require_binding.colors.bold(require_binding.colors.underline("USAGE"))} ${require_binding.colors.cyan("rolldown -c <config>")} or ${require_binding.colors.cyan("rolldown <input> <options>")}`;
1640
+ ${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("USAGE"))} ${require_parse_ast_index.colors.cyan("rolldown -c <config>")} or ${require_parse_ast_index.colors.cyan("rolldown <input> <options>")}`;
1641
1641
  const examples = [
1642
1642
  {
1643
1643
  title: "Bundle with a config file `rolldown.config.mjs`",
@@ -1669,7 +1669,7 @@ const notes = [
1669
1669
  function showHelp() {
1670
1670
  logger.log(introduction);
1671
1671
  logger.log("");
1672
- logger.log(`${require_binding.colors.bold(require_binding.colors.underline("OPTIONS"))}`);
1672
+ logger.log(`${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("OPTIONS"))}`);
1673
1673
  logger.log("");
1674
1674
  logger.log(Object.entries(options).sort(([a$1], [b]) => {
1675
1675
  if (options[a$1].short && !options[b].short) return -1;
@@ -1682,20 +1682,20 @@ function showHelp() {
1682
1682
  if (short) optionStr += `-${short}, `;
1683
1683
  if (type === "string") optionStr += `<${hint ?? option}>`;
1684
1684
  if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
1685
- return require_binding.colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
1685
+ return require_parse_ast_index.colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
1686
1686
  }).join("\n"));
1687
1687
  logger.log("");
1688
- logger.log(`${require_binding.colors.bold(require_binding.colors.underline("EXAMPLES"))}`);
1688
+ logger.log(`${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("EXAMPLES"))}`);
1689
1689
  logger.log("");
1690
1690
  examples.forEach(({ title, command }, ord) => {
1691
1691
  logger.log(` ${ord + 1}. ${title}:`);
1692
- logger.log(` ${require_binding.colors.cyan(command)}`);
1692
+ logger.log(` ${require_parse_ast_index.colors.cyan(command)}`);
1693
1693
  logger.log("");
1694
1694
  });
1695
- logger.log(`${require_binding.colors.bold(require_binding.colors.underline("NOTES"))}`);
1695
+ logger.log(`${require_parse_ast_index.colors.bold(require_parse_ast_index.colors.underline("NOTES"))}`);
1696
1696
  logger.log("");
1697
1697
  notes.forEach((note) => {
1698
- logger.log(` * ${require_binding.colors.gray(note)}`);
1698
+ logger.log(` * ${require_parse_ast_index.colors.gray(note)}`);
1699
1699
  });
1700
1700
  }
1701
1701
 
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-C5fd4TKF.cjs');
4
- const require_binding = require('../shared/binding-DTKqYZn-.cjs');
3
+ const require_src = require('../shared/src-BHgxMyK2.cjs');
4
+ const require_parse_ast_index = require('../shared/parse-ast-index-p24sJjY3.cjs');
5
5
  const node_url = require_chunk.__toESM(require("node:url"));
6
6
 
7
7
  //#region src/plugin/parallel-plugin.ts
@@ -1,5 +1,5 @@
1
- const require_src = require('../shared/src-C5fd4TKF.cjs');
2
- require('../shared/binding-DTKqYZn-.cjs');
1
+ const require_src = require('../shared/src-BHgxMyK2.cjs');
2
+ require('../shared/parse-ast-index-p24sJjY3.cjs');
3
3
 
4
4
  exports.VERSION = require_src.VERSION
5
5
  exports.build = require_src.build
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-C5fd4TKF.cjs');
4
- const require_binding = require('../shared/binding-DTKqYZn-.cjs');
3
+ const require_src = require('../shared/src-BHgxMyK2.cjs');
4
+ const require_parse_ast_index = require('../shared/parse-ast-index-p24sJjY3.cjs');
5
5
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
6
6
 
7
7
  //#region src/parallel-plugin-worker.ts
@@ -20,12 +20,13 @@ const { registryId, pluginInfos, threadNumber } = node_worker_threads.workerData
20
20
  {},
21
21
  // TODO need to find a way to share pluginContextData
22
22
  new require_src.PluginContextData(),
23
+ [],
23
24
  () => {},
24
25
  "info"
25
26
  )
26
27
  };
27
28
  }));
28
- (0, require_binding.import_binding.registerPlugins)(registryId, plugins);
29
+ (0, require_parse_ast_index.import_binding.registerPlugins)(registryId, plugins);
29
30
  node_worker_threads.parentPort.postMessage({ type: "success" });
30
31
  } catch (error) {
31
32
  node_worker_threads.parentPort.postMessage({
@@ -1,57 +1,4 @@
1
- "use strict";
2
- const require_binding = require('../shared/binding-DTKqYZn-.cjs');
1
+ const require_parse_ast_index = require('../shared/parse-ast-index-p24sJjY3.cjs');
3
2
 
4
- //#region src/parse-ast-index.ts
5
- function wrap(result, sourceText) {
6
- let program, module$1, 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$1) module$1 = result.module;
16
- return module$1;
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 = require_binding.locate(sourceText, label.start, { offsetLine: 1 });
42
- if (!location) return;
43
- return require_binding.getCodeFrame(sourceText, location.line, location.column);
44
- }).filter(Boolean).join("\n");
45
- }
46
- return require_binding.error(require_binding.logParseError(message));
47
- }
48
- function parseAst(filename, sourceText, options) {
49
- return wrap((0, require_binding.import_binding.parseSync)(filename, sourceText, options), sourceText);
50
- }
51
- async function parseAstAsync(filename, sourceText, options) {
52
- return wrap(await (0, require_binding.import_binding.parseAsync)(filename, sourceText, options), sourceText);
53
- }
54
-
55
- //#endregion
56
- exports.parseAst = parseAst
57
- exports.parseAstAsync = parseAstAsync
3
+ exports.parseAst = require_parse_ast_index.parseAst
4
+ exports.parseAstAsync = require_parse_ast_index.parseAstAsync
package/dist/esm/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { colors } from "../shared/binding-CFTx0Fs7.mjs";
2
- import { arraify, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-DSWkOt7m.mjs";
1
+ import { colors } from "../shared/parse-ast-index-BDY-7XFT.mjs";
2
+ import { arraify, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-HKRB5bWZ.mjs";
3
3
  import process$1, { cwd } from "node:process";
4
4
  import path, { sep } from "node:path";
5
5
  import fs from "node:fs";
@@ -950,11 +950,11 @@ function n(e) {
950
950
  return e ? e !== "false" : false;
951
951
  }
952
952
  const I = globalThis.process?.platform || "", T = n(s$1.CI) || l.ci !== false, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), U = n(s$1.DEBUG), A = t === "test" || n(s$1.TEST);
953
- n(s$1.MINIMAL) || T || A || !R;
953
+ n(s$1.MINIMAL);
954
954
  const _ = /^win/i.test(I);
955
- !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM !== "dumb" || T);
955
+ !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM !== "dumb");
956
956
  const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
957
- Number(C?.split(".")[0]) || null;
957
+ Number(C?.split(".")[0]);
958
958
  const y = globalThis.process || Object.create(null), c = { versions: {} };
959
959
  new Proxy(y, { get(e, o) {
960
960
  if (o === "env") return s$1;
@@ -975,7 +975,7 @@ function G() {
975
975
  if (e) return { name: e[1] };
976
976
  }
977
977
  const u = G();
978
- u?.name || "";
978
+ u?.name;
979
979
  function ansiRegex({ onlyFirst = false } = {}) {
980
980
  const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
981
981
  const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
@@ -1,5 +1,5 @@
1
- import { import_binding } from "../shared/binding-CFTx0Fs7.mjs";
2
- import { BuiltinPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-DSWkOt7m.mjs";
1
+ import { import_binding } from "../shared/parse-ast-index-BDY-7XFT.mjs";
2
+ import { BuiltinPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-HKRB5bWZ.mjs";
3
3
  import { pathToFileURL } from "node:url";
4
4
 
5
5
  //#region src/plugin/parallel-plugin.ts
@@ -1,4 +1,4 @@
1
- import "../shared/binding-CFTx0Fs7.mjs";
2
- import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-DSWkOt7m.mjs";
1
+ import "../shared/parse-ast-index-BDY-7XFT.mjs";
2
+ import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-HKRB5bWZ.mjs";
3
3
 
4
4
  export { VERSION, build, defineConfig, rolldown, watch };
@@ -1,5 +1,5 @@
1
- import { import_binding } from "../shared/binding-CFTx0Fs7.mjs";
2
- import { PluginContextData, bindingifyPlugin } from "../shared/src-DSWkOt7m.mjs";
1
+ import { import_binding } from "../shared/parse-ast-index-BDY-7XFT.mjs";
2
+ import { PluginContextData, bindingifyPlugin } from "../shared/src-HKRB5bWZ.mjs";
3
3
  import { parentPort, workerData } from "node:worker_threads";
4
4
 
5
5
  //#region src/parallel-plugin-worker.ts
@@ -18,6 +18,7 @@ const { registryId, pluginInfos, threadNumber } = workerData;
18
18
  {},
19
19
  // TODO need to find a way to share pluginContextData
20
20
  new PluginContextData(),
21
+ [],
21
22
  () => {},
22
23
  "info"
23
24
  )
@@ -1,55 +1,3 @@
1
- import { error, getCodeFrame, import_binding, locate, logParseError } from "../shared/binding-CFTx0Fs7.mjs";
1
+ import { parseAst, parseAstAsync } from "../shared/parse-ast-index-BDY-7XFT.mjs";
2
2
 
3
- //#region src/parse-ast-index.ts
4
- function wrap(result, sourceText) {
5
- let program, module, comments, errors, magicString;
6
- return {
7
- get program() {
8
- if (!errors) errors = result.errors;
9
- if (errors.length > 0) return normalizeParseError(sourceText, errors);
10
- if (!program) program = JSON.parse(result.program);
11
- return program;
12
- },
13
- get module() {
14
- if (!module) module = result.module;
15
- return module;
16
- },
17
- get comments() {
18
- if (!comments) comments = result.comments;
19
- return comments;
20
- },
21
- get errors() {
22
- if (!errors) errors = result.errors;
23
- return errors;
24
- },
25
- get magicString() {
26
- if (!magicString) magicString = result.magicString;
27
- return magicString;
28
- }
29
- };
30
- }
31
- function normalizeParseError(sourceText, errors) {
32
- let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
33
- for (let i = 0; i < errors.length; i++) {
34
- if (i >= 5) {
35
- message += "\n...";
36
- break;
37
- }
38
- const e = errors[i];
39
- message += e.message + "\n" + e.labels.map((label) => {
40
- const location = locate(sourceText, label.start, { offsetLine: 1 });
41
- if (!location) return;
42
- return getCodeFrame(sourceText, location.line, location.column);
43
- }).filter(Boolean).join("\n");
44
- }
45
- return error(logParseError(message));
46
- }
47
- function parseAst(filename, sourceText, options) {
48
- return wrap((0, import_binding.parseSync)(filename, sourceText, options), sourceText);
49
- }
50
- async function parseAstAsync(filename, sourceText, options) {
51
- return wrap(await (0, import_binding.parseAsync)(filename, sourceText, options), sourceText);
52
- }
53
-
54
- //#endregion
55
3
  export { parseAst, parseAstAsync };
@@ -607,4 +607,56 @@ var require_binding = __commonJS({ "src/binding.js"(exports, module) {
607
607
  var import_binding = __toESM(require_binding());
608
608
 
609
609
  //#endregion
610
- export { augmentCodeLocation, colors, error, getCodeFrame, import_binding, locate, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logParseError, logPluginError };
610
+ //#region src/parse-ast-index.ts
611
+ function wrap(result, sourceText) {
612
+ let program, module$1, comments, errors, magicString;
613
+ return {
614
+ get program() {
615
+ if (!errors) errors = result.errors;
616
+ if (errors.length > 0) return normalizeParseError(sourceText, errors);
617
+ if (!program) program = JSON.parse(result.program);
618
+ return program;
619
+ },
620
+ get module() {
621
+ if (!module$1) module$1 = result.module;
622
+ return module$1;
623
+ },
624
+ get comments() {
625
+ if (!comments) comments = result.comments;
626
+ return comments;
627
+ },
628
+ get errors() {
629
+ if (!errors) errors = result.errors;
630
+ return errors;
631
+ },
632
+ get magicString() {
633
+ if (!magicString) magicString = result.magicString;
634
+ return magicString;
635
+ }
636
+ };
637
+ }
638
+ function normalizeParseError(sourceText, errors) {
639
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
640
+ for (let i = 0; i < errors.length; i++) {
641
+ if (i >= 5) {
642
+ message += "\n...";
643
+ break;
644
+ }
645
+ const e = errors[i];
646
+ message += e.message + "\n" + e.labels.map((label) => {
647
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
648
+ if (!location) return;
649
+ return getCodeFrame(sourceText, location.line, location.column);
650
+ }).filter(Boolean).join("\n");
651
+ }
652
+ return error(logParseError(message));
653
+ }
654
+ function parseAst(filename, sourceText, options) {
655
+ return wrap((0, import_binding.parseSync)(filename, sourceText, options), sourceText).program;
656
+ }
657
+ async function parseAstAsync(filename, sourceText, options) {
658
+ return wrap(await (0, import_binding.parseAsync)(filename, sourceText, options), sourceText).program;
659
+ }
660
+
661
+ //#endregion
662
+ export { augmentCodeLocation, colors, error, import_binding, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, parseAst, parseAstAsync };
@@ -580,6 +580,58 @@ var require_binding = require_chunk.__commonJS({ "src/binding.js"(exports, modul
580
580
  } });
581
581
  var import_binding = require_chunk.__toESM(require_binding());
582
582
 
583
+ //#endregion
584
+ //#region src/parse-ast-index.ts
585
+ function wrap(result, sourceText) {
586
+ let program, module$1, comments, errors, magicString;
587
+ return {
588
+ get program() {
589
+ if (!errors) errors = result.errors;
590
+ if (errors.length > 0) return normalizeParseError(sourceText, errors);
591
+ if (!program) program = JSON.parse(result.program);
592
+ return program;
593
+ },
594
+ get module() {
595
+ if (!module$1) module$1 = result.module;
596
+ return module$1;
597
+ },
598
+ get comments() {
599
+ if (!comments) comments = result.comments;
600
+ return comments;
601
+ },
602
+ get errors() {
603
+ if (!errors) errors = result.errors;
604
+ return errors;
605
+ },
606
+ get magicString() {
607
+ if (!magicString) magicString = result.magicString;
608
+ return magicString;
609
+ }
610
+ };
611
+ }
612
+ function normalizeParseError(sourceText, errors) {
613
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
614
+ for (let i = 0; i < errors.length; i++) {
615
+ if (i >= 5) {
616
+ message += "\n...";
617
+ break;
618
+ }
619
+ const e = errors[i];
620
+ message += e.message + "\n" + e.labels.map((label) => {
621
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
622
+ if (!location) return;
623
+ return getCodeFrame(sourceText, location.line, location.column);
624
+ }).filter(Boolean).join("\n");
625
+ }
626
+ return error(logParseError(message));
627
+ }
628
+ function parseAst(filename, sourceText, options) {
629
+ return wrap((0, import_binding.parseSync)(filename, sourceText, options), sourceText).program;
630
+ }
631
+ async function parseAstAsync(filename, sourceText, options) {
632
+ return wrap(await (0, import_binding.parseAsync)(filename, sourceText, options), sourceText).program;
633
+ }
634
+
583
635
  //#endregion
584
636
  Object.defineProperty(exports, 'augmentCodeLocation', {
585
637
  enumerable: true,
@@ -599,24 +651,12 @@ Object.defineProperty(exports, 'error', {
599
651
  return error;
600
652
  }
601
653
  });
602
- Object.defineProperty(exports, 'getCodeFrame', {
603
- enumerable: true,
604
- get: function () {
605
- return getCodeFrame;
606
- }
607
- });
608
654
  Object.defineProperty(exports, 'import_binding', {
609
655
  enumerable: true,
610
656
  get: function () {
611
657
  return import_binding;
612
658
  }
613
659
  });
614
- Object.defineProperty(exports, 'locate', {
615
- enumerable: true,
616
- get: function () {
617
- return locate;
618
- }
619
- });
620
660
  Object.defineProperty(exports, 'logCycleLoading', {
621
661
  enumerable: true,
622
662
  get: function () {
@@ -647,15 +687,21 @@ Object.defineProperty(exports, 'logMultiplyNotifyOption', {
647
687
  return logMultiplyNotifyOption;
648
688
  }
649
689
  });
650
- Object.defineProperty(exports, 'logParseError', {
690
+ Object.defineProperty(exports, 'logPluginError', {
651
691
  enumerable: true,
652
692
  get: function () {
653
- return logParseError;
693
+ return logPluginError;
654
694
  }
655
695
  });
656
- Object.defineProperty(exports, 'logPluginError', {
696
+ Object.defineProperty(exports, 'parseAst', {
657
697
  enumerable: true,
658
698
  get: function () {
659
- return logPluginError;
699
+ return parseAst;
700
+ }
701
+ });
702
+ Object.defineProperty(exports, 'parseAstAsync', {
703
+ enumerable: true,
704
+ get: function () {
705
+ return parseAstAsync;
660
706
  }
661
707
  });