rolldown 1.0.0-beta.4-commit.d3748b6 → 1.0.0-beta.40

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.
Files changed (133) hide show
  1. package/bin/cli.mjs +2 -0
  2. package/dist/cli.d.mts +1 -0
  3. package/dist/cli.mjs +579 -0
  4. package/dist/config.d.mts +10 -0
  5. package/dist/config.mjs +10 -0
  6. package/dist/experimental-index.d.mts +147 -0
  7. package/dist/experimental-index.mjs +216 -0
  8. package/dist/experimental-runtime-types.d.ts +71 -0
  9. package/dist/filter-index.d.mts +4 -0
  10. package/dist/filter-index.mjs +44 -0
  11. package/dist/index.d.mts +3 -0
  12. package/dist/index.mjs +5 -0
  13. package/dist/parallel-plugin-worker.d.mts +1 -0
  14. package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +8 -16
  15. package/dist/parallel-plugin.d.mts +14 -0
  16. package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
  17. package/dist/parse-ast-index.d.mts +8 -0
  18. package/dist/parse-ast-index.mjs +3 -0
  19. package/dist/shared/binding-BVXbXhPv.d.mts +1413 -0
  20. package/dist/shared/define-config-0kfJrpvQ.d.mts +1454 -0
  21. package/dist/shared/load-config-BJ274Wsp.mjs +117 -0
  22. package/dist/{esm/cli.mjs → shared/logger-CiCY7ucm.mjs} +107 -868
  23. package/dist/shared/misc-CQeo-AFx.mjs +22 -0
  24. package/dist/shared/parse-ast-index-C7EYXjEA.mjs +10974 -0
  25. package/dist/shared/{prompt-CxK9euq3.mjs → prompt-D2FxOcB5.mjs} +243 -245
  26. package/dist/shared/src-BH2eQDD9.mjs +4282 -0
  27. package/package.json +62 -76
  28. package/bin/cli.js +0 -2
  29. package/dist/cjs/cli.cjs +0 -1753
  30. package/dist/cjs/experimental-index.cjs +0 -85
  31. package/dist/cjs/index.cjs +0 -8
  32. package/dist/cjs/parallel-plugin-worker.cjs +0 -41
  33. package/dist/cjs/parallel-plugin.cjs +0 -9
  34. package/dist/cjs/parse-ast-index.cjs +0 -4
  35. package/dist/esm/experimental-index.mjs +0 -57
  36. package/dist/esm/index.mjs +0 -4
  37. package/dist/esm/parse-ast-index.mjs +0 -3
  38. package/dist/shared/chunk-qZFfknuJ.cjs +0 -40
  39. package/dist/shared/parse-ast-index-CyX8MVZE.mjs +0 -674
  40. package/dist/shared/parse-ast-index-D7XtMFo4.cjs +0 -719
  41. package/dist/shared/prompt-ZZScCEWI.cjs +0 -854
  42. package/dist/shared/src-CH716UxL.cjs +0 -3056
  43. package/dist/shared/src-CzSgWS0h.mjs +0 -2875
  44. package/dist/types/api/build.d.ts +0 -18
  45. package/dist/types/api/experimental.d.ts +0 -7
  46. package/dist/types/api/rolldown/index.d.ts +0 -3
  47. package/dist/types/api/rolldown/rolldown-build.d.ts +0 -13
  48. package/dist/types/api/watch/index.d.ts +0 -3
  49. package/dist/types/api/watch/watch-emitter.d.ts +0 -31
  50. package/dist/types/api/watch/watcher.d.ts +0 -13
  51. package/dist/types/binding.d.ts +0 -1456
  52. package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
  53. package/dist/types/builtin-plugin/constructors.d.ts +0 -21
  54. package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
  55. package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
  56. package/dist/types/builtin-plugin/utils.d.ts +0 -8
  57. package/dist/types/cli/arguments/alias.d.ts +0 -16
  58. package/dist/types/cli/arguments/index.d.ts +0 -15
  59. package/dist/types/cli/arguments/normalize.d.ts +0 -12
  60. package/dist/types/cli/arguments/utils.d.ts +0 -8
  61. package/dist/types/cli/colors.d.ts +0 -11
  62. package/dist/types/cli/commands/bundle.d.ts +0 -3
  63. package/dist/types/cli/commands/help.d.ts +0 -1
  64. package/dist/types/cli/index.d.ts +0 -1
  65. package/dist/types/cli/load-config.d.ts +0 -5
  66. package/dist/types/cli/logger.d.ts +0 -5
  67. package/dist/types/constants/plugin-context.d.ts +0 -7
  68. package/dist/types/constants/plugin.d.ts +0 -45
  69. package/dist/types/experimental-index.d.ts +0 -9
  70. package/dist/types/index.d.ts +0 -30
  71. package/dist/types/log/log-handler.d.ts +0 -4
  72. package/dist/types/log/logger.d.ts +0 -6
  73. package/dist/types/log/logging.d.ts +0 -12
  74. package/dist/types/log/logs.d.ts +0 -18
  75. package/dist/types/options/generated/checks-options.d.ts +0 -57
  76. package/dist/types/options/input-options.d.ts +0 -177
  77. package/dist/types/options/normalized-input-options.d.ts +0 -18
  78. package/dist/types/options/normalized-output-options.d.ts +0 -70
  79. package/dist/types/options/output-options.d.ts +0 -182
  80. package/dist/types/options/watch-options.d.ts +0 -5
  81. package/dist/types/parallel-plugin-worker.d.ts +0 -1
  82. package/dist/types/parallel-plugin.d.ts +0 -1
  83. package/dist/types/parse-ast-index.d.ts +0 -5
  84. package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
  85. package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
  86. package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
  87. package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
  88. package/dist/types/plugin/bindingify-plugin.d.ts +0 -16
  89. package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
  90. package/dist/types/plugin/hook-filter.d.ts +0 -48
  91. package/dist/types/plugin/index.d.ts +0 -134
  92. package/dist/types/plugin/minimal-plugin-context.d.ts +0 -23
  93. package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
  94. package/dist/types/plugin/parallel-plugin.d.ts +0 -9
  95. package/dist/types/plugin/plugin-context-data.d.ts +0 -17
  96. package/dist/types/plugin/plugin-context.d.ts +0 -67
  97. package/dist/types/plugin/plugin-driver.d.ts +0 -8
  98. package/dist/types/plugin/transform-plugin-context.d.ts +0 -28
  99. package/dist/types/types/assert.d.ts +0 -14
  100. package/dist/types/types/config-export.d.ts +0 -5
  101. package/dist/types/types/misc.d.ts +0 -40
  102. package/dist/types/types/module-info.d.ts +0 -15
  103. package/dist/types/types/module-side-effects.d.ts +0 -12
  104. package/dist/types/types/output-bundle.d.ts +0 -4
  105. package/dist/types/types/rolldown-options.d.ts +0 -5
  106. package/dist/types/types/rolldown-output.d.ts +0 -66
  107. package/dist/types/types/schema.d.ts +0 -33
  108. package/dist/types/types/sourcemap.d.ts +0 -14
  109. package/dist/types/types/utils.d.ts +0 -13
  110. package/dist/types/utils/asset-source.d.ts +0 -4
  111. package/dist/types/utils/async-flatten.d.ts +0 -1
  112. package/dist/types/utils/bindingify-input-options.d.ts +0 -7
  113. package/dist/types/utils/bindingify-output-options.d.ts +0 -5
  114. package/dist/types/utils/code-frame.d.ts +0 -1
  115. package/dist/types/utils/compose-js-plugins.d.ts +0 -2
  116. package/dist/types/utils/create-bundler-option.d.ts +0 -11
  117. package/dist/types/utils/create-bundler.d.ts +0 -8
  118. package/dist/types/utils/define-config.d.ts +0 -5
  119. package/dist/types/utils/error.d.ts +0 -2
  120. package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
  121. package/dist/types/utils/misc.d.ts +0 -6
  122. package/dist/types/utils/normalize-hook.d.ts +0 -7
  123. package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
  124. package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
  125. package/dist/types/utils/plugin/index.d.ts +0 -2
  126. package/dist/types/utils/resolved-external.d.ts +0 -4
  127. package/dist/types/utils/transform-module-info.d.ts +0 -4
  128. package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
  129. package/dist/types/utils/transform-rendered-module.d.ts +0 -3
  130. package/dist/types/utils/transform-side-effects.d.ts +0 -3
  131. package/dist/types/utils/transform-sourcemap.d.ts +0 -3
  132. package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
  133. package/dist/types/utils/validator.d.ts +0 -6
@@ -1,674 +0,0 @@
1
- import { createRequire } from "module";
2
- import { env } from "node:process";
3
- import * as tty from "tty";
4
-
5
- //#region rolldown:runtime
6
- var __create = Object.create;
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __commonJS = (cb, mod) => function() {
13
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
17
- key = keys[i];
18
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
- get: ((k) => from[k]).bind(null, key),
20
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
- });
22
- }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: true
28
- }) : target, mod));
29
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
-
31
- //#endregion
32
- //#region src/utils/code-frame.ts
33
- function spaces(index) {
34
- let result = "";
35
- while (index--) result += " ";
36
- return result;
37
- }
38
- function tabsToSpaces(value) {
39
- return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
40
- }
41
- const LINE_TRUNCATE_LENGTH = 120;
42
- const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
43
- const ELLIPSIS = "...";
44
- function getCodeFrame(source, line, column) {
45
- let lines = source.split("\n");
46
- if (line > lines.length) return "";
47
- const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
48
- const frameStart = Math.max(0, line - 3);
49
- let frameEnd = Math.min(line + 2, lines.length);
50
- lines = lines.slice(frameStart, frameEnd);
51
- while (!/\S/.test(lines[lines.length - 1])) {
52
- lines.pop();
53
- frameEnd -= 1;
54
- }
55
- const digits = String(frameEnd).length;
56
- return lines.map((sourceLine, index) => {
57
- const isErrorLine = frameStart + index + 1 === line;
58
- let lineNumber = String(index + frameStart + 1);
59
- while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
60
- let displayedLine = tabsToSpaces(sourceLine);
61
- if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
62
- if (isErrorLine) {
63
- const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
64
- return `${lineNumber}: ${displayedLine}\n${indicator}`;
65
- }
66
- return `${lineNumber}: ${displayedLine}`;
67
- }).join("\n");
68
- }
69
-
70
- //#endregion
71
- //#region src/log/locate-character/index.js
72
- /** @typedef {import('./types').Location} Location */
73
- /**
74
- * @param {import('./types').Range} range
75
- * @param {number} index
76
- */
77
- function rangeContains(range, index) {
78
- return range.start <= index && index < range.end;
79
- }
80
- function getLocator(source, options = {}) {
81
- const { offsetLine = 0, offsetColumn = 0 } = options;
82
- let start = 0;
83
- const ranges = source.split("\n").map((line, i$1) => {
84
- const end = start + line.length + 1;
85
- /** @type {import('./types').Range} */
86
- const range = {
87
- start,
88
- end,
89
- line: i$1
90
- };
91
- start = end;
92
- return range;
93
- });
94
- let i = 0;
95
- /**
96
- * @param {string | number} search
97
- * @param {number} [index]
98
- * @returns {Location | undefined}
99
- */
100
- function locator(search, index) {
101
- if (typeof search === "string") search = source.indexOf(search, index ?? 0);
102
- if (search === -1) return void 0;
103
- let range = ranges[i];
104
- const d = search >= range.end ? 1 : -1;
105
- while (range) {
106
- if (rangeContains(range, search)) return {
107
- line: offsetLine + range.line,
108
- column: offsetColumn + search - range.start,
109
- character: search
110
- };
111
- i += d;
112
- range = ranges[i];
113
- }
114
- }
115
- return locator;
116
- }
117
- function locate(source, search, options) {
118
- return getLocator(source, options)(search, options && options.startIndex);
119
- }
120
-
121
- //#endregion
122
- //#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
123
- const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
124
- const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
125
- const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
126
- const isWindows = platform === "win32";
127
- const isDumbTerminal = env$1.TERM === "dumb";
128
- const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
129
- const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
130
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
131
- 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));
132
- const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
133
- const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
134
- const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
135
- const colors$1 = {
136
- reset: init(0, 0),
137
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
138
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
139
- italic: init(3, 23),
140
- underline: init(4, 24),
141
- inverse: init(7, 27),
142
- hidden: init(8, 28),
143
- strikethrough: init(9, 29),
144
- black: init(30, 39),
145
- red: init(31, 39),
146
- green: init(32, 39),
147
- yellow: init(33, 39),
148
- blue: init(34, 39),
149
- magenta: init(35, 39),
150
- cyan: init(36, 39),
151
- white: init(37, 39),
152
- gray: init(90, 39),
153
- bgBlack: init(40, 49),
154
- bgRed: init(41, 49),
155
- bgGreen: init(42, 49),
156
- bgYellow: init(43, 49),
157
- bgBlue: init(44, 49),
158
- bgMagenta: init(45, 49),
159
- bgCyan: init(46, 49),
160
- bgWhite: init(47, 49),
161
- blackBright: init(90, 39),
162
- redBright: init(91, 39),
163
- greenBright: init(92, 39),
164
- yellowBright: init(93, 39),
165
- blueBright: init(94, 39),
166
- magentaBright: init(95, 39),
167
- cyanBright: init(96, 39),
168
- whiteBright: init(97, 39),
169
- bgBlackBright: init(100, 49),
170
- bgRedBright: init(101, 49),
171
- bgGreenBright: init(102, 49),
172
- bgYellowBright: init(103, 49),
173
- bgBlueBright: init(104, 49),
174
- bgMagentaBright: init(105, 49),
175
- bgCyanBright: init(106, 49),
176
- bgWhiteBright: init(107, 49)
177
- };
178
- const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
179
- ...colors$2,
180
- [key]: String
181
- }), {});
182
- 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();
183
-
184
- //#endregion
185
- //#region src/cli/colors.ts
186
- const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR });
187
- const colors = {
188
- bold,
189
- cyan,
190
- dim,
191
- gray,
192
- green,
193
- red,
194
- underline,
195
- yellow
196
- };
197
-
198
- //#endregion
199
- //#region src/log/logs.ts
200
- const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", MINIFY_WARNING = "MINIFY_WARNING", PARSE_ERROR = "PARSE_ERROR";
201
- function logParseError(message) {
202
- return {
203
- code: PARSE_ERROR,
204
- message
205
- };
206
- }
207
- function logMinifyWarning() {
208
- return {
209
- code: MINIFY_WARNING,
210
- message: colors.yellow("The built-in minifier is still under development. Setting \"minify: true\" is not recommended for production use.")
211
- };
212
- }
213
- function logInvalidLogPosition(pluginName) {
214
- return {
215
- code: INVALID_LOG_POSITION,
216
- message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
217
- };
218
- }
219
- function logInputHookInOutputPlugin(pluginName, hookName) {
220
- return {
221
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
222
- message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
223
- };
224
- }
225
- function logCycleLoading(pluginName, moduleId) {
226
- return {
227
- code: CYCLE_LOADING,
228
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
229
- };
230
- }
231
- function logMultiplyNotifyOption() {
232
- return {
233
- code: MULTIPLY_NOTIFY_OPTION,
234
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`
235
- };
236
- }
237
- function logPluginError(error$1, plugin, { hook, id } = {}) {
238
- const code = error$1.code;
239
- if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
240
- error$1.code = PLUGIN_ERROR;
241
- error$1.plugin = plugin;
242
- if (hook) error$1.hook = hook;
243
- if (id) error$1.id = id;
244
- return error$1;
245
- }
246
- function error(base) {
247
- if (!(base instanceof Error)) {
248
- base = Object.assign(new Error(base.message), base);
249
- Object.defineProperty(base, "name", {
250
- value: "RollupError",
251
- writable: true
252
- });
253
- }
254
- throw base;
255
- }
256
- function augmentCodeLocation(properties, pos, source, id) {
257
- if (typeof pos === "object") {
258
- const { line, column } = pos;
259
- properties.loc = {
260
- column,
261
- file: id,
262
- line
263
- };
264
- } else {
265
- properties.pos = pos;
266
- const location = locate(source, pos, { offsetLine: 1 });
267
- if (!location) return;
268
- const { line, column } = location;
269
- properties.loc = {
270
- column,
271
- file: id,
272
- line
273
- };
274
- }
275
- if (properties.frame === void 0) {
276
- const { line, column } = properties.loc;
277
- properties.frame = getCodeFrame(source, line, column);
278
- }
279
- }
280
-
281
- //#endregion
282
- //#region src/binding.js
283
- var require_binding = __commonJS({ "src/binding.js"(exports, module) {
284
- const { createRequire: createRequire$1 } = __require("node:module");
285
- const { readFileSync } = __require("node:fs");
286
- let nativeBinding = null;
287
- const loadErrors = [];
288
- const isMusl = () => {
289
- let musl = false;
290
- if (process.platform === "linux") {
291
- musl = isMuslFromFilesystem();
292
- if (musl === null) musl = isMuslFromReport();
293
- if (musl === null) musl = isMuslFromChildProcess();
294
- }
295
- return musl;
296
- };
297
- const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
298
- const isMuslFromFilesystem = () => {
299
- try {
300
- return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
301
- } catch {
302
- return null;
303
- }
304
- };
305
- const isMuslFromReport = () => {
306
- const report = typeof process.report.getReport === "function" ? process.report.getReport() : null;
307
- if (!report) return null;
308
- if (report.header && report.header.glibcVersionRuntime) return false;
309
- if (Array.isArray(report.sharedObjects)) {
310
- if (report.sharedObjects.some(isFileMusl)) return true;
311
- }
312
- return false;
313
- };
314
- const isMuslFromChildProcess = () => {
315
- try {
316
- return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
317
- } catch (e) {
318
- return false;
319
- }
320
- };
321
- function requireNative() {
322
- if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
323
- nativeBinding = __require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
324
- } catch (err) {
325
- loadErrors.push(err);
326
- }
327
- else if (process.platform === "android") if (process.arch === "arm64") {
328
- try {
329
- return __require("../rolldown-binding.android-arm64.node");
330
- } catch (e) {
331
- loadErrors.push(e);
332
- }
333
- try {
334
- return __require("@rolldown/binding-android-arm64");
335
- } catch (e) {
336
- loadErrors.push(e);
337
- }
338
- } else if (process.arch === "arm") {
339
- try {
340
- return __require("../rolldown-binding.android-arm-eabi.node");
341
- } catch (e) {
342
- loadErrors.push(e);
343
- }
344
- try {
345
- return __require("@rolldown/binding-android-arm-eabi");
346
- } catch (e) {
347
- loadErrors.push(e);
348
- }
349
- } else loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
350
- else if (process.platform === "win32") if (process.arch === "x64") {
351
- try {
352
- return __require("../rolldown-binding.win32-x64-msvc.node");
353
- } catch (e) {
354
- loadErrors.push(e);
355
- }
356
- try {
357
- return __require("@rolldown/binding-win32-x64-msvc");
358
- } catch (e) {
359
- loadErrors.push(e);
360
- }
361
- } else if (process.arch === "ia32") {
362
- try {
363
- return __require("../rolldown-binding.win32-ia32-msvc.node");
364
- } catch (e) {
365
- loadErrors.push(e);
366
- }
367
- try {
368
- return __require("@rolldown/binding-win32-ia32-msvc");
369
- } catch (e) {
370
- loadErrors.push(e);
371
- }
372
- } else if (process.arch === "arm64") {
373
- try {
374
- return __require("../rolldown-binding.win32-arm64-msvc.node");
375
- } catch (e) {
376
- loadErrors.push(e);
377
- }
378
- try {
379
- return __require("@rolldown/binding-win32-arm64-msvc");
380
- } catch (e) {
381
- loadErrors.push(e);
382
- }
383
- } else loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
384
- else if (process.platform === "darwin") {
385
- try {
386
- return __require("../rolldown-binding.darwin-universal.node");
387
- } catch (e) {
388
- loadErrors.push(e);
389
- }
390
- try {
391
- return __require("@rolldown/binding-darwin-universal");
392
- } catch (e) {
393
- loadErrors.push(e);
394
- }
395
- if (process.arch === "x64") {
396
- try {
397
- return __require("../rolldown-binding.darwin-x64.node");
398
- } catch (e) {
399
- loadErrors.push(e);
400
- }
401
- try {
402
- return __require("@rolldown/binding-darwin-x64");
403
- } catch (e) {
404
- loadErrors.push(e);
405
- }
406
- } else if (process.arch === "arm64") {
407
- try {
408
- return __require("../rolldown-binding.darwin-arm64.node");
409
- } catch (e) {
410
- loadErrors.push(e);
411
- }
412
- try {
413
- return __require("@rolldown/binding-darwin-arm64");
414
- } catch (e) {
415
- loadErrors.push(e);
416
- }
417
- } else loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
418
- } else if (process.platform === "freebsd") if (process.arch === "x64") {
419
- try {
420
- return __require("../rolldown-binding.freebsd-x64.node");
421
- } catch (e) {
422
- loadErrors.push(e);
423
- }
424
- try {
425
- return __require("@rolldown/binding-freebsd-x64");
426
- } catch (e) {
427
- loadErrors.push(e);
428
- }
429
- } else if (process.arch === "arm64") {
430
- try {
431
- return __require("../rolldown-binding.freebsd-arm64.node");
432
- } catch (e) {
433
- loadErrors.push(e);
434
- }
435
- try {
436
- return __require("@rolldown/binding-freebsd-arm64");
437
- } catch (e) {
438
- loadErrors.push(e);
439
- }
440
- } else loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
441
- else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
442
- try {
443
- return __require("../rolldown-binding.linux-x64-musl.node");
444
- } catch (e) {
445
- loadErrors.push(e);
446
- }
447
- try {
448
- return __require("@rolldown/binding-linux-x64-musl");
449
- } catch (e) {
450
- loadErrors.push(e);
451
- }
452
- } else {
453
- try {
454
- return __require("../rolldown-binding.linux-x64-gnu.node");
455
- } catch (e) {
456
- loadErrors.push(e);
457
- }
458
- try {
459
- return __require("@rolldown/binding-linux-x64-gnu");
460
- } catch (e) {
461
- loadErrors.push(e);
462
- }
463
- }
464
- else if (process.arch === "arm64") if (isMusl()) {
465
- try {
466
- return __require("../rolldown-binding.linux-arm64-musl.node");
467
- } catch (e) {
468
- loadErrors.push(e);
469
- }
470
- try {
471
- return __require("@rolldown/binding-linux-arm64-musl");
472
- } catch (e) {
473
- loadErrors.push(e);
474
- }
475
- } else {
476
- try {
477
- return __require("../rolldown-binding.linux-arm64-gnu.node");
478
- } catch (e) {
479
- loadErrors.push(e);
480
- }
481
- try {
482
- return __require("@rolldown/binding-linux-arm64-gnu");
483
- } catch (e) {
484
- loadErrors.push(e);
485
- }
486
- }
487
- else if (process.arch === "arm") if (isMusl()) {
488
- try {
489
- return __require("../rolldown-binding.linux-arm-musleabihf.node");
490
- } catch (e) {
491
- loadErrors.push(e);
492
- }
493
- try {
494
- return __require("@rolldown/binding-linux-arm-musleabihf");
495
- } catch (e) {
496
- loadErrors.push(e);
497
- }
498
- } else {
499
- try {
500
- return __require("../rolldown-binding.linux-arm-gnueabihf.node");
501
- } catch (e) {
502
- loadErrors.push(e);
503
- }
504
- try {
505
- return __require("@rolldown/binding-linux-arm-gnueabihf");
506
- } catch (e) {
507
- loadErrors.push(e);
508
- }
509
- }
510
- else if (process.arch === "riscv64") if (isMusl()) {
511
- try {
512
- return __require("../rolldown-binding.linux-riscv64-musl.node");
513
- } catch (e) {
514
- loadErrors.push(e);
515
- }
516
- try {
517
- return __require("@rolldown/binding-linux-riscv64-musl");
518
- } catch (e) {
519
- loadErrors.push(e);
520
- }
521
- } else {
522
- try {
523
- return __require("../rolldown-binding.linux-riscv64-gnu.node");
524
- } catch (e) {
525
- loadErrors.push(e);
526
- }
527
- try {
528
- return __require("@rolldown/binding-linux-riscv64-gnu");
529
- } catch (e) {
530
- loadErrors.push(e);
531
- }
532
- }
533
- else if (process.arch === "ppc64") {
534
- try {
535
- return __require("../rolldown-binding.linux-ppc64-gnu.node");
536
- } catch (e) {
537
- loadErrors.push(e);
538
- }
539
- try {
540
- return __require("@rolldown/binding-linux-ppc64-gnu");
541
- } catch (e) {
542
- loadErrors.push(e);
543
- }
544
- } else if (process.arch === "s390x") {
545
- try {
546
- return __require("../rolldown-binding.linux-s390x-gnu.node");
547
- } catch (e) {
548
- loadErrors.push(e);
549
- }
550
- try {
551
- return __require("@rolldown/binding-linux-s390x-gnu");
552
- } catch (e) {
553
- loadErrors.push(e);
554
- }
555
- } else loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
556
- else loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
557
- }
558
- nativeBinding = requireNative();
559
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
560
- try {
561
- nativeBinding = __require("../rolldown-binding.wasi.cjs");
562
- } catch (err) {
563
- if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
564
- }
565
- if (!nativeBinding) try {
566
- nativeBinding = __require("@rolldown/binding-wasm32-wasi");
567
- } catch (err) {
568
- if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
569
- }
570
- }
571
- if (!nativeBinding) {
572
- if (loadErrors.length > 0) throw new Error("Failed to load native binding", { cause: loadErrors });
573
- throw new Error(`Failed to load native binding`);
574
- }
575
- module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
576
- module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
577
- module.exports.BindingError = nativeBinding.BindingError;
578
- module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
579
- module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
580
- module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
581
- module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
582
- module.exports.BindingOutputs = nativeBinding.BindingOutputs;
583
- module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
584
- module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
585
- module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
586
- module.exports.BindingWatcher = nativeBinding.BindingWatcher;
587
- module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
588
- module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
589
- module.exports.Bundler = nativeBinding.Bundler;
590
- module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
591
- module.exports.ParseResult = nativeBinding.ParseResult;
592
- module.exports.RenderedChunk = nativeBinding.RenderedChunk;
593
- module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
594
- module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
595
- module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
596
- module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
597
- module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
598
- module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
599
- module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
600
- module.exports.getBufferOffset = nativeBinding.getBufferOffset;
601
- module.exports.HelperMode = nativeBinding.HelperMode;
602
- module.exports.ImportNameKind = nativeBinding.ImportNameKind;
603
- module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
604
- module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
605
- module.exports.parseAsync = nativeBinding.parseAsync;
606
- module.exports.parseSync = nativeBinding.parseSync;
607
- module.exports.parseSyncRaw = nativeBinding.parseSyncRaw;
608
- module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
609
- module.exports.registerPlugins = nativeBinding.registerPlugins;
610
- module.exports.Severity = nativeBinding.Severity;
611
- module.exports.transform = nativeBinding.transform;
612
- } });
613
- var import_binding = __toESM(require_binding());
614
-
615
- //#endregion
616
- //#region src/parse-ast-index.ts
617
- function wrap(result, sourceText) {
618
- let program, module$1, comments, errors;
619
- return {
620
- get program() {
621
- if (!errors) errors = result.errors;
622
- if (errors.length > 0) return normalizeParseError(sourceText, errors);
623
- if (!program) program = JSON.parse(result.program);
624
- return program;
625
- },
626
- get module() {
627
- if (!module$1) module$1 = result.module;
628
- return module$1;
629
- },
630
- get comments() {
631
- if (!comments) comments = result.comments;
632
- return comments;
633
- },
634
- get errors() {
635
- if (!errors) errors = result.errors;
636
- return errors;
637
- }
638
- };
639
- }
640
- function normalizeParseError(sourceText, errors) {
641
- let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
642
- for (let i = 0; i < errors.length; i++) {
643
- if (i >= 5) {
644
- message += "\n...";
645
- break;
646
- }
647
- const e = errors[i];
648
- message += e.message + "\n" + e.labels.map((label) => {
649
- const location = locate(sourceText, label.start, { offsetLine: 1 });
650
- if (!location) return;
651
- return getCodeFrame(sourceText, location.line, location.column);
652
- }).filter(Boolean).join("\n");
653
- }
654
- return error(logParseError(message));
655
- }
656
- const defaultParserOptions = {
657
- lang: "js",
658
- preserveParens: false
659
- };
660
- function parseAst(sourceText, options, filename) {
661
- return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
662
- ...defaultParserOptions,
663
- ...options
664
- }), sourceText).program;
665
- }
666
- async function parseAstAsync(sourceText, options, filename) {
667
- return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
668
- ...defaultParserOptions,
669
- ...options
670
- }), sourceText).program;
671
- }
672
-
673
- //#endregion
674
- export { augmentCodeLocation, colors, error, import_binding, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, parseAst, parseAstAsync };