binding-s-V_wTpj.mjs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. import { createRequire } from "node:module";
  2. //#region \0rolldown/runtime.js
  3. var __create = Object.create;
  4. var __defProp = Object.defineProperty;
  5. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  6. var __getOwnPropNames = Object.getOwnPropertyNames;
  7. var __getProtoOf = Object.getPrototypeOf;
  8. var __hasOwnProp = Object.prototype.hasOwnProperty;
  9. var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
  12. key = keys[i];
  13. if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
  14. get: ((k) => from[k]).bind(null, key),
  15. enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
  16. });
  17. }
  18. return to;
  19. };
  20. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
  21. value: mod,
  22. enumerable: true
  23. }) : target, mod));
  24. var __require = /* @__PURE__ */ createRequire(import.meta.url);
  25. //#endregion
  26. //#region src/webcontainer-fallback.cjs
  27. var require_webcontainer_fallback = /* @__PURE__ */ __commonJSMin(((exports, module) => {
  28. const fs = __require("node:fs");
  29. const childProcess = __require("node:child_process");
  30. const version = JSON.parse(fs.readFileSync(__require.resolve("rolldown/package.json"), "utf-8")).version;
  31. const baseDir = `/tmp/rolldown-${version}`;
  32. const bindingEntry = `${baseDir}/node_modules/@rolldown/binding-wasm32-wasi/rolldown-binding.wasi.cjs`;
  33. if (!fs.existsSync(bindingEntry)) {
  34. const bindingPkg = `@rolldown/binding-wasm32-wasi@${version}`;
  35. fs.rmSync(baseDir, {
  36. recursive: true,
  37. force: true
  38. });
  39. fs.mkdirSync(baseDir, { recursive: true });
  40. console.log(`[rolldown] Downloading ${bindingPkg} on WebContainer...`);
  41. childProcess.execFileSync("pnpm", ["i", bindingPkg], {
  42. cwd: baseDir,
  43. stdio: "inherit"
  44. });
  45. }
  46. module.exports = __require(bindingEntry);
  47. }));
  48. //#endregion
  49. //#region src/binding.cjs
  50. var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
  51. const { readFileSync } = __require("node:fs");
  52. let nativeBinding = null;
  53. const loadErrors = [];
  54. const isMusl = () => {
  55. let musl = false;
  56. if (process.platform === "linux") {
  57. musl = isMuslFromFilesystem();
  58. if (musl === null) musl = isMuslFromReport();
  59. if (musl === null) musl = isMuslFromChildProcess();
  60. }
  61. return musl;
  62. };
  63. const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
  64. const isMuslFromFilesystem = () => {
  65. try {
  66. return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
  67. } catch {
  68. return null;
  69. }
  70. };
  71. const isMuslFromReport = () => {
  72. let report = null;
  73. if (typeof process.report?.getReport === "function") {
  74. process.report.excludeNetwork = true;
  75. report = process.report.getReport();
  76. }
  77. if (!report) return null;
  78. if (report.header && report.header.glibcVersionRuntime) return false;
  79. if (Array.isArray(report.sharedObjects)) {
  80. if (report.sharedObjects.some(isFileMusl)) return true;
  81. }
  82. return false;
  83. };
  84. const isMuslFromChildProcess = () => {
  85. try {
  86. return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
  87. } catch (e) {
  88. return false;
  89. }
  90. };
  91. function requireNative() {
  92. if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
  93. return __require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
  94. } catch (err) {
  95. loadErrors.push(err);
  96. }
  97. else if (process.platform === "android") if (process.arch === "arm64") {
  98. try {
  99. return __require("./rolldown-binding.android-arm64.node");
  100. } catch (e) {
  101. loadErrors.push(e);
  102. }
  103. try {
  104. const binding = __require("@rolldown/binding-android-arm64");
  105. const bindingPackageVersion = __require("@rolldown/binding-android-arm64/package.json").version;
  106. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  107. return binding;
  108. } catch (e) {
  109. loadErrors.push(e);
  110. }
  111. } else if (process.arch === "arm") {
  112. try {
  113. return __require("./rolldown-binding.android-arm-eabi.node");
  114. } catch (e) {
  115. loadErrors.push(e);
  116. }
  117. try {
  118. const binding = __require("@rolldown/binding-android-arm-eabi");
  119. const bindingPackageVersion = __require("@rolldown/binding-android-arm-eabi/package.json").version;
  120. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  121. return binding;
  122. } catch (e) {
  123. loadErrors.push(e);
  124. }
  125. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
  126. else if (process.platform === "win32") if (process.arch === "x64") if (process.config?.variables?.shlib_suffix === "dll.a" || process.config?.variables?.node_target_type === "shared_library") {
  127. try {
  128. return __require("./rolldown-binding.win32-x64-gnu.node");
  129. } catch (e) {
  130. loadErrors.push(e);
  131. }
  132. try {
  133. const binding = __require("@rolldown/binding-win32-x64-gnu");
  134. const bindingPackageVersion = __require("@rolldown/binding-win32-x64-gnu/package.json").version;
  135. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  136. return binding;
  137. } catch (e) {
  138. loadErrors.push(e);
  139. }
  140. } else {
  141. try {
  142. return __require("./rolldown-binding.win32-x64-msvc.node");
  143. } catch (e) {
  144. loadErrors.push(e);
  145. }
  146. try {
  147. const binding = __require("@rolldown/binding-win32-x64-msvc");
  148. const bindingPackageVersion = __require("@rolldown/binding-win32-x64-msvc/package.json").version;
  149. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  150. return binding;
  151. } catch (e) {
  152. loadErrors.push(e);
  153. }
  154. }
  155. else if (process.arch === "ia32") {
  156. try {
  157. return __require("./rolldown-binding.win32-ia32-msvc.node");
  158. } catch (e) {
  159. loadErrors.push(e);
  160. }
  161. try {
  162. const binding = __require("@rolldown/binding-win32-ia32-msvc");
  163. const bindingPackageVersion = __require("@rolldown/binding-win32-ia32-msvc/package.json").version;
  164. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  165. return binding;
  166. } catch (e) {
  167. loadErrors.push(e);
  168. }
  169. } else if (process.arch === "arm64") {
  170. try {
  171. return __require("./rolldown-binding.win32-arm64-msvc.node");
  172. } catch (e) {
  173. loadErrors.push(e);
  174. }
  175. try {
  176. const binding = __require("@rolldown/binding-win32-arm64-msvc");
  177. const bindingPackageVersion = __require("@rolldown/binding-win32-arm64-msvc/package.json").version;
  178. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  179. return binding;
  180. } catch (e) {
  181. loadErrors.push(e);
  182. }
  183. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
  184. else if (process.platform === "darwin") {
  185. try {
  186. return __require("./rolldown-binding.darwin-universal.node");
  187. } catch (e) {
  188. loadErrors.push(e);
  189. }
  190. try {
  191. const binding = __require("@rolldown/binding-darwin-universal");
  192. const bindingPackageVersion = __require("@rolldown/binding-darwin-universal/package.json").version;
  193. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  194. return binding;
  195. } catch (e) {
  196. loadErrors.push(e);
  197. }
  198. if (process.arch === "x64") {
  199. try {
  200. return __require("./rolldown-binding.darwin-x64.node");
  201. } catch (e) {
  202. loadErrors.push(e);
  203. }
  204. try {
  205. const binding = __require("@rolldown/binding-darwin-x64");
  206. const bindingPackageVersion = __require("@rolldown/binding-darwin-x64/package.json").version;
  207. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  208. return binding;
  209. } catch (e) {
  210. loadErrors.push(e);
  211. }
  212. } else if (process.arch === "arm64") {
  213. try {
  214. return __require("./rolldown-binding.darwin-arm64.node");
  215. } catch (e) {
  216. loadErrors.push(e);
  217. }
  218. try {
  219. const binding = __require("@rolldown/binding-darwin-arm64");
  220. const bindingPackageVersion = __require("@rolldown/binding-darwin-arm64/package.json").version;
  221. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  222. return binding;
  223. } catch (e) {
  224. loadErrors.push(e);
  225. }
  226. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
  227. } else if (process.platform === "freebsd") if (process.arch === "x64") {
  228. try {
  229. return __require("./rolldown-binding.freebsd-x64.node");
  230. } catch (e) {
  231. loadErrors.push(e);
  232. }
  233. try {
  234. const binding = __require("@rolldown/binding-freebsd-x64");
  235. const bindingPackageVersion = __require("@rolldown/binding-freebsd-x64/package.json").version;
  236. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  237. return binding;
  238. } catch (e) {
  239. loadErrors.push(e);
  240. }
  241. } else if (process.arch === "arm64") {
  242. try {
  243. return __require("./rolldown-binding.freebsd-arm64.node");
  244. } catch (e) {
  245. loadErrors.push(e);
  246. }
  247. try {
  248. const binding = __require("@rolldown/binding-freebsd-arm64");
  249. const bindingPackageVersion = __require("@rolldown/binding-freebsd-arm64/package.json").version;
  250. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  251. return binding;
  252. } catch (e) {
  253. loadErrors.push(e);
  254. }
  255. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
  256. else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
  257. try {
  258. return __require("./rolldown-binding.linux-x64-musl.node");
  259. } catch (e) {
  260. loadErrors.push(e);
  261. }
  262. try {
  263. const binding = __require("@rolldown/binding-linux-x64-musl");
  264. const bindingPackageVersion = __require("@rolldown/binding-linux-x64-musl/package.json").version;
  265. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  266. return binding;
  267. } catch (e) {
  268. loadErrors.push(e);
  269. }
  270. } else {
  271. try {
  272. return __require("../rolldown-binding.linux-x64-gnu.node");
  273. } catch (e) {
  274. loadErrors.push(e);
  275. }
  276. try {
  277. const binding = __require("@rolldown/binding-linux-x64-gnu");
  278. const bindingPackageVersion = __require("@rolldown/binding-linux-x64-gnu/package.json").version;
  279. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  280. return binding;
  281. } catch (e) {
  282. loadErrors.push(e);
  283. }
  284. }
  285. else if (process.arch === "arm64") if (isMusl()) {
  286. try {
  287. return __require("./rolldown-binding.linux-arm64-musl.node");
  288. } catch (e) {
  289. loadErrors.push(e);
  290. }
  291. try {
  292. const binding = __require("@rolldown/binding-linux-arm64-musl");
  293. const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-musl/package.json").version;
  294. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  295. return binding;
  296. } catch (e) {
  297. loadErrors.push(e);
  298. }
  299. } else {
  300. try {
  301. return __require("./rolldown-binding.linux-arm64-gnu.node");
  302. } catch (e) {
  303. loadErrors.push(e);
  304. }
  305. try {
  306. const binding = __require("@rolldown/binding-linux-arm64-gnu");
  307. const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-gnu/package.json").version;
  308. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  309. return binding;
  310. } catch (e) {
  311. loadErrors.push(e);
  312. }
  313. }
  314. else if (process.arch === "arm") if (isMusl()) {
  315. try {
  316. return __require("./rolldown-binding.linux-arm-musleabihf.node");
  317. } catch (e) {
  318. loadErrors.push(e);
  319. }
  320. try {
  321. const binding = __require("@rolldown/binding-linux-arm-musleabihf");
  322. const bindingPackageVersion = __require("@rolldown/binding-linux-arm-musleabihf/package.json").version;
  323. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  324. return binding;
  325. } catch (e) {
  326. loadErrors.push(e);
  327. }
  328. } else {
  329. try {
  330. return __require("./rolldown-binding.linux-arm-gnueabihf.node");
  331. } catch (e) {
  332. loadErrors.push(e);
  333. }
  334. try {
  335. const binding = __require("@rolldown/binding-linux-arm-gnueabihf");
  336. const bindingPackageVersion = __require("@rolldown/binding-linux-arm-gnueabihf/package.json").version;
  337. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  338. return binding;
  339. } catch (e) {
  340. loadErrors.push(e);
  341. }
  342. }
  343. else if (process.arch === "loong64") if (isMusl()) {
  344. try {
  345. return __require("./rolldown-binding.linux-loong64-musl.node");
  346. } catch (e) {
  347. loadErrors.push(e);
  348. }
  349. try {
  350. const binding = __require("@rolldown/binding-linux-loong64-musl");
  351. const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-musl/package.json").version;
  352. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  353. return binding;
  354. } catch (e) {
  355. loadErrors.push(e);
  356. }
  357. } else {
  358. try {
  359. return __require("./rolldown-binding.linux-loong64-gnu.node");
  360. } catch (e) {
  361. loadErrors.push(e);
  362. }
  363. try {
  364. const binding = __require("@rolldown/binding-linux-loong64-gnu");
  365. const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-gnu/package.json").version;
  366. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  367. return binding;
  368. } catch (e) {
  369. loadErrors.push(e);
  370. }
  371. }
  372. else if (process.arch === "riscv64") if (isMusl()) {
  373. try {
  374. return __require("./rolldown-binding.linux-riscv64-musl.node");
  375. } catch (e) {
  376. loadErrors.push(e);
  377. }
  378. try {
  379. const binding = __require("@rolldown/binding-linux-riscv64-musl");
  380. const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-musl/package.json").version;
  381. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  382. return binding;
  383. } catch (e) {
  384. loadErrors.push(e);
  385. }
  386. } else {
  387. try {
  388. return __require("./rolldown-binding.linux-riscv64-gnu.node");
  389. } catch (e) {
  390. loadErrors.push(e);
  391. }
  392. try {
  393. const binding = __require("@rolldown/binding-linux-riscv64-gnu");
  394. const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-gnu/package.json").version;
  395. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  396. return binding;
  397. } catch (e) {
  398. loadErrors.push(e);
  399. }
  400. }
  401. else if (process.arch === "ppc64") {
  402. try {
  403. return __require("./rolldown-binding.linux-ppc64-gnu.node");
  404. } catch (e) {
  405. loadErrors.push(e);
  406. }
  407. try {
  408. const binding = __require("@rolldown/binding-linux-ppc64-gnu");
  409. const bindingPackageVersion = __require("@rolldown/binding-linux-ppc64-gnu/package.json").version;
  410. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  411. return binding;
  412. } catch (e) {
  413. loadErrors.push(e);
  414. }
  415. } else if (process.arch === "s390x") {
  416. try {
  417. return __require("./rolldown-binding.linux-s390x-gnu.node");
  418. } catch (e) {
  419. loadErrors.push(e);
  420. }
  421. try {
  422. const binding = __require("@rolldown/binding-linux-s390x-gnu");
  423. const bindingPackageVersion = __require("@rolldown/binding-linux-s390x-gnu/package.json").version;
  424. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  425. return binding;
  426. } catch (e) {
  427. loadErrors.push(e);
  428. }
  429. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
  430. else if (process.platform === "openharmony") if (process.arch === "arm64") {
  431. try {
  432. return __require("./rolldown-binding.openharmony-arm64.node");
  433. } catch (e) {
  434. loadErrors.push(e);
  435. }
  436. try {
  437. const binding = __require("@rolldown/binding-openharmony-arm64");
  438. const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm64/package.json").version;
  439. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  440. return binding;
  441. } catch (e) {
  442. loadErrors.push(e);
  443. }
  444. } else if (process.arch === "x64") {
  445. try {
  446. return __require("./rolldown-binding.openharmony-x64.node");
  447. } catch (e) {
  448. loadErrors.push(e);
  449. }
  450. try {
  451. const binding = __require("@rolldown/binding-openharmony-x64");
  452. const bindingPackageVersion = __require("@rolldown/binding-openharmony-x64/package.json").version;
  453. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  454. return binding;
  455. } catch (e) {
  456. loadErrors.push(e);
  457. }
  458. } else if (process.arch === "arm") {
  459. try {
  460. return __require("./rolldown-binding.openharmony-arm.node");
  461. } catch (e) {
  462. loadErrors.push(e);
  463. }
  464. try {
  465. const binding = __require("@rolldown/binding-openharmony-arm");
  466. const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm/package.json").version;
  467. if (bindingPackageVersion !== "1.0.0-rc.15" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.0.0-rc.15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  468. return binding;
  469. } catch (e) {
  470. loadErrors.push(e);
  471. }
  472. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
  473. else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
  474. }
  475. nativeBinding = requireNative();
  476. if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
  477. let wasiBinding = null;
  478. let wasiBindingError = null;
  479. try {
  480. wasiBinding = __require("../rolldown-binding.wasi.cjs");
  481. nativeBinding = wasiBinding;
  482. } catch (err) {
  483. if (process.env.NAPI_RS_FORCE_WASI) wasiBindingError = err;
  484. }
  485. if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) try {
  486. wasiBinding = __require("@rolldown/binding-wasm32-wasi");
  487. nativeBinding = wasiBinding;
  488. } catch (err) {
  489. if (process.env.NAPI_RS_FORCE_WASI) {
  490. if (!wasiBindingError) wasiBindingError = err;
  491. else wasiBindingError.cause = err;
  492. loadErrors.push(err);
  493. }
  494. }
  495. if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
  496. const error = /* @__PURE__ */ new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
  497. error.cause = wasiBindingError;
  498. throw error;
  499. }
  500. }
  501. if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) try {
  502. nativeBinding = require_webcontainer_fallback();
  503. } catch (err) {
  504. loadErrors.push(err);
  505. }
  506. if (!nativeBinding) {
  507. if (loadErrors.length > 0) throw new Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.", { cause: loadErrors.reduce((err, cur) => {
  508. cur.cause = err;
  509. return cur;
  510. }) });
  511. throw new Error(`Failed to load native binding`);
  512. }
  513. module.exports = nativeBinding;
  514. module.exports.minify = nativeBinding.minify;
  515. module.exports.minifySync = nativeBinding.minifySync;
  516. module.exports.Severity = nativeBinding.Severity;
  517. module.exports.ParseResult = nativeBinding.ParseResult;
  518. module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
  519. module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
  520. module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
  521. module.exports.ImportNameKind = nativeBinding.ImportNameKind;
  522. module.exports.parse = nativeBinding.parse;
  523. module.exports.parseSync = nativeBinding.parseSync;
  524. module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
  525. module.exports.ResolverFactory = nativeBinding.ResolverFactory;
  526. module.exports.EnforceExtension = nativeBinding.EnforceExtension;
  527. module.exports.ModuleType = nativeBinding.ModuleType;
  528. module.exports.sync = nativeBinding.sync;
  529. module.exports.HelperMode = nativeBinding.HelperMode;
  530. module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
  531. module.exports.isolatedDeclarationSync = nativeBinding.isolatedDeclarationSync;
  532. module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
  533. module.exports.moduleRunnerTransformSync = nativeBinding.moduleRunnerTransformSync;
  534. module.exports.transform = nativeBinding.transform;
  535. module.exports.transformSync = nativeBinding.transformSync;
  536. module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
  537. module.exports.BindingBundleErrorEventData = nativeBinding.BindingBundleErrorEventData;
  538. module.exports.BindingBundler = nativeBinding.BindingBundler;
  539. module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
  540. module.exports.BindingChunkingContext = nativeBinding.BindingChunkingContext;
  541. module.exports.BindingDecodedMap = nativeBinding.BindingDecodedMap;
  542. module.exports.BindingDevEngine = nativeBinding.BindingDevEngine;
  543. module.exports.BindingLoadPluginContext = nativeBinding.BindingLoadPluginContext;
  544. module.exports.BindingMagicString = nativeBinding.BindingMagicString;
  545. module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
  546. module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
  547. module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
  548. module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
  549. module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
  550. module.exports.BindingRenderedChunk = nativeBinding.BindingRenderedChunk;
  551. module.exports.BindingRenderedChunkMeta = nativeBinding.BindingRenderedChunkMeta;
  552. module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
  553. module.exports.BindingSourceMap = nativeBinding.BindingSourceMap;
  554. module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
  555. module.exports.BindingWatcher = nativeBinding.BindingWatcher;
  556. module.exports.BindingWatcherBundler = nativeBinding.BindingWatcherBundler;
  557. module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
  558. module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
  559. module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
  560. module.exports.ScheduledBuild = nativeBinding.ScheduledBuild;
  561. module.exports.TraceSubscriberGuard = nativeBinding.TraceSubscriberGuard;
  562. module.exports.TsconfigCache = nativeBinding.TsconfigCache;
  563. module.exports.BindingAttachDebugInfo = nativeBinding.BindingAttachDebugInfo;
  564. module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
  565. module.exports.BindingChunkModuleOrderBy = nativeBinding.BindingChunkModuleOrderBy;
  566. module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
  567. module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
  568. module.exports.BindingPropertyReadSideEffects = nativeBinding.BindingPropertyReadSideEffects;
  569. module.exports.BindingPropertyWriteSideEffects = nativeBinding.BindingPropertyWriteSideEffects;
  570. module.exports.BindingRebuildStrategy = nativeBinding.BindingRebuildStrategy;
  571. module.exports.collapseSourcemaps = nativeBinding.collapseSourcemaps;
  572. module.exports.enhancedTransform = nativeBinding.enhancedTransform;
  573. module.exports.enhancedTransformSync = nativeBinding.enhancedTransformSync;
  574. module.exports.FilterTokenKind = nativeBinding.FilterTokenKind;
  575. module.exports.initTraceSubscriber = nativeBinding.initTraceSubscriber;
  576. module.exports.registerPlugins = nativeBinding.registerPlugins;
  577. module.exports.resolveTsconfig = nativeBinding.resolveTsconfig;
  578. module.exports.shutdownAsyncRuntime = nativeBinding.shutdownAsyncRuntime;
  579. module.exports.startAsyncRuntime = nativeBinding.startAsyncRuntime;
  580. }));
  581. //#endregion
  582. export { __toESM as n, require_binding as t };