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