rolldown 1.1.5 → 1.2.1

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 (49) hide show
  1. package/THIRD-PARTY-LICENSE +33 -0
  2. package/dist/cli.mjs +9 -10
  3. package/dist/config.d.mts +16 -17
  4. package/dist/config.mjs +2 -2
  5. package/dist/experimental-default-runtime.mjs +116 -0
  6. package/dist/experimental-index.d.mts +170 -155
  7. package/dist/experimental-index.mjs +47 -22
  8. package/dist/experimental-runtime-base.mjs +95 -0
  9. package/dist/experimental-runtime-types.d.ts +111 -41
  10. package/dist/experimental-runtime.d.ts +177 -0
  11. package/dist/experimental-runtime.mjs +257 -0
  12. package/dist/filter-index.d.mts +6 -5
  13. package/dist/filter-index.mjs +1 -3
  14. package/dist/get-log-filter.d.mts +2 -2
  15. package/dist/index.d.mts +4 -4
  16. package/dist/index.mjs +4 -4
  17. package/dist/parallel-plugin-worker.mjs +2 -2
  18. package/dist/parallel-plugin.d.mts +3 -4
  19. package/dist/parse-ast-index.d.mts +19 -20
  20. package/dist/parse-ast-index.mjs +2 -2
  21. package/dist/plugins-index.d.mts +27 -28
  22. package/dist/plugins-index.mjs +2 -2
  23. package/dist/shared/{binding-D26QphWG.d.mts → binding-CVtkJvyl.d.mts} +48 -25
  24. package/dist/shared/{binding-TuFFIE_J.mjs → binding-Cv62mM1i.mjs} +124 -50
  25. package/dist/shared/{bindingify-input-options-XPJLJOD0.mjs → bindingify-input-options-EnUlEF0T.mjs} +209 -252
  26. package/dist/shared/{constructors-BbWPse2X.d.mts → constructors-ALilxAii.d.mts} +9 -10
  27. package/dist/shared/{constructors-D_3i7dpX.mjs → constructors-CuqzPFxJ.mjs} +10 -6
  28. package/dist/shared/{rolldown-build-CtPvmZgJ.mjs → create-bundler-option-4QtiLLuz.mjs} +39 -156
  29. package/dist/shared/define-config-DSMNXceb.d.mts +4066 -0
  30. package/dist/shared/{error-BHRSI0R7.mjs → error-BgfXq0Tb.mjs} +1 -1
  31. package/dist/shared/get-log-filter-AjBknEEO.d.mts +34 -0
  32. package/dist/shared/{load-config-BL_FI6dc.mjs → load-config-DsMzOVzu.mjs} +2 -2
  33. package/dist/shared/{logging-BSNejiLS.d.mts → logging-xuHO4mAy.d.mts} +6 -6
  34. package/dist/shared/{logs-ZGEh6uhb.mjs → logs-DmYCAKcW.mjs} +8 -1
  35. package/dist/shared/{misc-CoQm4NHO.mjs → misc-DOSKtd97.mjs} +9 -1
  36. package/dist/shared/{normalize-string-or-regex-dnh67V_w.mjs → normalize-string-or-regex-BVNGzRe4.mjs} +2 -2
  37. package/dist/shared/{parse-D4dtlfWy.mjs → parse-DQIYJwT4.mjs} +2 -2
  38. package/dist/shared/{prompt--dNycKSZ.mjs → prompt-CH6TK0bC.mjs} +2 -6
  39. package/dist/shared/{resolve-tsconfig-DxqIJB3x.mjs → resolve-tsconfig-CQndqeLj.mjs} +2 -2
  40. package/dist/shared/rolldown-DP_p9pd3.mjs +178 -0
  41. package/dist/shared/transform-WmU_cI8e.d.mts +148 -0
  42. package/dist/shared/{watch-B1b0gmVh.mjs → watch-Cwq-cFUy.mjs} +16 -13
  43. package/dist/utils-index.d.mts +29 -30
  44. package/dist/utils-index.mjs +6 -8
  45. package/package.json +32 -25
  46. package/dist/shared/define-config-BhJ90aEv.d.mts +0 -3978
  47. package/dist/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  48. package/dist/shared/rolldown-ChpIlMRm.mjs +0 -40
  49. package/dist/shared/transform-BPrUvqEZ.d.mts +0 -149
@@ -270,21 +270,33 @@ interface ExportExportName {
270
270
  start: number | null;
271
271
  end: number | null;
272
272
  }
273
- type ExportExportNameKind = /** `export { name } */'Name' | /** `export default expression` */'Default' | /** `export * from "mod" */'None';
273
+ type ExportExportNameKind = 'Name' |
274
+ /** `export default expression` */
275
+ 'Default' |
276
+ /** `export * from "mod" */
277
+ 'None';
274
278
  interface ExportImportName {
275
279
  kind: ExportImportNameKind;
276
280
  name: string | null;
277
281
  start: number | null;
278
282
  end: number | null;
279
283
  }
280
- type ExportImportNameKind = /** `export { name } */'Name' | /** `export * as ns from "mod"` */'All' | /** `export * from "mod"` */'AllButDefault' | /** Does not have a specifier. */'None';
284
+ type ExportImportNameKind = 'Name' |
285
+ /** `export * as ns from "mod"` */
286
+ 'All' |
287
+ /** `export * from "mod"` */
288
+ 'AllButDefault' |
289
+ /** Does not have a specifier. */
290
+ 'None';
281
291
  interface ExportLocalName {
282
292
  kind: ExportLocalNameKind;
283
293
  name: string | null;
284
294
  start: number | null;
285
295
  end: number | null;
286
296
  }
287
- type ExportLocalNameKind = /** `export { name } */'Name' | /** `export default expression` */'Default' |
297
+ type ExportLocalNameKind = 'Name' |
298
+ /** `export default expression` */
299
+ 'Default' |
288
300
  /**
289
301
  * If the exported value is not locally accessible from within the module.
290
302
  * `export default function () {}`
@@ -296,7 +308,11 @@ interface ImportName {
296
308
  start: number | null;
297
309
  end: number | null;
298
310
  }
299
- type ImportNameKind = /** `import { x } from "mod"` */'Name' | /** `import * as ns from "mod"` */'NamespaceObject' | /** `import defaultExport from "mod"` */'Default';
311
+ type ImportNameKind = 'Name' |
312
+ /** `import * as ns from "mod"` */
313
+ 'NamespaceObject' |
314
+ /** `import defaultExport from "mod"` */
315
+ 'Default';
300
316
  interface ParserOptions {
301
317
  /** Treat the source text as `js`, `jsx`, `ts`, `tsx` or `dts`. */
302
318
  lang?: 'js' | 'jsx' | 'ts' | 'tsx' | 'dts';
@@ -816,18 +832,7 @@ interface DecoratorOptions {
816
832
  */
817
833
  strictNullChecks?: boolean;
818
834
  }
819
- type HelperMode =
820
- /**
821
- * Runtime mode (default): Helper functions are imported from a runtime package.
822
- *
823
- * Example:
824
- *
825
- * ```js
826
- * import helperName from "@oxc-project/runtime/helpers/helperName";
827
- * helperName(...arguments);
828
- * ```
829
- */
830
- 'Runtime' |
835
+ type HelperMode = 'Runtime' |
831
836
  /**
832
837
  * External mode: Helper functions are accessed from a global `babelHelpers` object.
833
838
  *
@@ -1663,17 +1668,17 @@ interface BindingEsmExternalRequirePluginConfig {
1663
1668
  external: Array<BindingStringOrRegex>;
1664
1669
  skipDuplicateCheck?: boolean;
1665
1670
  }
1666
- interface BindingHmrBoundaryOutput {
1667
- boundary: string;
1668
- acceptedVia: string;
1669
- }
1670
1671
  type BindingHmrUpdate = {
1671
1672
  type: 'Patch';
1672
1673
  code: string;
1673
1674
  filename: string;
1674
1675
  sourcemap?: string;
1675
- sourcemapFilename?: string;
1676
- hmrBoundaries: Array<BindingHmrBoundaryOutput>;
1676
+ sourcemapFilename?: string; /**
1677
+ * Stable ids of the changed modules — the `changedIds` of the push envelope.
1678
+ * The client walks from these on its own graph.
1679
+ */
1680
+ changedIds: Array<string>; /** Per-client envelope sequence number. */
1681
+ seq: number;
1677
1682
  } | {
1678
1683
  type: 'FullReload';
1679
1684
  reason?: string;
@@ -1700,6 +1705,21 @@ interface BindingIndentOptions {
1700
1705
  interface BindingIsolatedDeclarationPluginConfig {
1701
1706
  stripInternal?: boolean;
1702
1707
  }
1708
+ /**
1709
+ * The client-facing slice of a lazy-compile result. The carried modules and
1710
+ * stamps stay server-side as the engine's pending-payload entry.
1711
+ */
1712
+ interface BindingLazyChunkOutput {
1713
+ code: string;
1714
+ filename: string;
1715
+ /**
1716
+ * The chunk's sourcemap, when `sourcemap` is `File` or `Hidden`. Serve it
1717
+ * under `sourcemapFilename`, which is what the chunk's `sourceMappingURL`
1718
+ * refers to.
1719
+ */
1720
+ sourcemap?: string;
1721
+ sourcemapFilename?: string;
1722
+ }
1703
1723
  interface BindingLogLocation {
1704
1724
  /** 1-based */
1705
1725
  line: number;
@@ -1719,6 +1739,8 @@ interface BindingModules {
1719
1739
  }
1720
1740
  interface BindingOverwriteOptions {
1721
1741
  contentOnly?: boolean;
1742
+ /** Stores the replaced content in the generated sourcemap's `names` field. */
1743
+ storeName?: boolean;
1722
1744
  }
1723
1745
  interface BindingPluginContextResolveOptions {
1724
1746
  /**
@@ -1738,8 +1760,7 @@ interface BindingPluginContextResolveOptions {
1738
1760
  }
1739
1761
  declare enum BindingRebuildStrategy {
1740
1762
  Always = 0,
1741
- Auto = 1,
1742
- Never = 2
1763
+ Never = 1
1743
1764
  }
1744
1765
  interface BindingReplacePluginConfig {
1745
1766
  values: Record<string, string>;
@@ -1822,6 +1843,8 @@ interface BindingTsconfigResult {
1822
1843
  }
1823
1844
  interface BindingUpdateOptions {
1824
1845
  overwrite?: boolean;
1846
+ /** Stores the replaced content in the generated sourcemap's `names` field. */
1847
+ storeName?: boolean;
1825
1848
  }
1826
1849
  interface BindingViteBuildImportAnalysisPluginConfig {
1827
1850
  preloadCode: string;
@@ -1956,4 +1979,4 @@ interface ViteImportGlobMeta {
1956
1979
  isSubImportsPattern?: boolean;
1957
1980
  }
1958
1981
  //#endregion
1959
- export { ExternalMemoryStatus as A, ResolveResult as B, BindingViteManifestPluginConfig as C, BindingViteResolvePluginConfig as D, BindingViteReporterPluginConfig as E, MinifyResult as F, isolatedDeclaration as G, SourceMap as H, NapiResolveOptions as I, isolatedDeclarationSync as K, ParseResult as L, IsolatedDeclarationsResult as M, JsxOptions as N, BindingViteTransformPluginConfig as O, MinifyOptions as P, ParserOptions as R, BindingViteJsonPluginConfig as S, BindingViteReactRefreshWrapperPluginConfig as T, TransformOptions as U, ResolverFactory as V, TsconfigCache as W, BindingTsconfigRawOptions as _, BindingEnhancedTransformOptions as a, BindingViteDynamicImportVarsPluginConfig as b, BindingHookResolveIdExtraArgs as c, BindingPluginContextResolveOptions as d, BindingRebuildStrategy as f, BindingTsconfigCompilerOptions as g, BindingTransformHookExtraArgs as h, BindingClientHmrUpdate as i, IsolatedDeclarationsOptions as j, BindingWatcherBundler as k, BindingIsolatedDeclarationPluginConfig as l, BindingReplacePluginConfig as m, BindingBundleAnalyzerPluginConfig as n, BindingEnhancedTransformResult as o, BindingRenderedChunk as p, moduleRunnerTransform as q, BindingBundleState as r, BindingEsmExternalRequirePluginConfig as s, BindingBuiltinPluginName as t, BindingMagicString as u, BindingTsconfigResult as v, BindingViteModulePreloadPolyfillPluginConfig as w, BindingViteImportGlobPluginConfig as x, BindingViteBuildImportAnalysisPluginConfig as y, PreRenderedChunk as z };
1982
+ export { BindingWatcherBundler as A, PreRenderedChunk as B, BindingViteJsonPluginConfig as C, BindingViteReporterPluginConfig as D, BindingViteReactRefreshWrapperPluginConfig as E, MinifyOptions as F, TsconfigCache as G, ResolverFactory as H, MinifyResult as I, moduleRunnerTransform as J, isolatedDeclaration as K, NapiResolveOptions as L, IsolatedDeclarationsOptions as M, IsolatedDeclarationsResult as N, BindingViteResolvePluginConfig as O, JsxOptions as P, ParseResult as R, BindingViteImportGlobPluginConfig as S, BindingViteModulePreloadPolyfillPluginConfig as T, SourceMap as U, ResolveResult as V, TransformOptions as W, BindingTsconfigCompilerOptions as _, BindingEnhancedTransformOptions as a, BindingViteBuildImportAnalysisPluginConfig as b, BindingHookResolveIdExtraArgs as c, BindingMagicString as d, BindingPluginContextResolveOptions as f, BindingTransformHookExtraArgs as g, BindingReplacePluginConfig as h, BindingClientHmrUpdate as i, ExternalMemoryStatus as j, BindingViteTransformPluginConfig as k, BindingIsolatedDeclarationPluginConfig as l, BindingRenderedChunk as m, BindingBundleAnalyzerPluginConfig as n, BindingEnhancedTransformResult as o, BindingRebuildStrategy as p, isolatedDeclarationSync as q, BindingBundleState as r, BindingEsmExternalRequirePluginConfig as s, BindingBuiltinPluginName as t, BindingLazyChunkOutput as u, BindingTsconfigRawOptions as v, BindingViteManifestPluginConfig as w, BindingViteDynamicImportVarsPluginConfig as x, BindingTsconfigResult as y, ParserOptions as z };
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
21
21
  value: mod,
22
22
  enumerable: true
23
23
  }) : target, mod));
@@ -103,7 +103,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
103
103
  try {
104
104
  const binding = __require("@rolldown/binding-android-arm64");
105
105
  const bindingPackageVersion = __require("@rolldown/binding-android-arm64/package.json").version;
106
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
106
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
107
107
  return binding;
108
108
  } catch (e) {
109
109
  loadErrors.push(e);
@@ -117,7 +117,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
117
117
  try {
118
118
  const binding = __require("@rolldown/binding-android-arm-eabi");
119
119
  const bindingPackageVersion = __require("@rolldown/binding-android-arm-eabi/package.json").version;
120
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
120
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
121
121
  return binding;
122
122
  } catch (e) {
123
123
  loadErrors.push(e);
@@ -132,7 +132,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
132
132
  try {
133
133
  const binding = __require("@rolldown/binding-win32-x64-gnu");
134
134
  const bindingPackageVersion = __require("@rolldown/binding-win32-x64-gnu/package.json").version;
135
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
135
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
136
136
  return binding;
137
137
  } catch (e) {
138
138
  loadErrors.push(e);
@@ -146,7 +146,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
146
146
  try {
147
147
  const binding = __require("@rolldown/binding-win32-x64-msvc");
148
148
  const bindingPackageVersion = __require("@rolldown/binding-win32-x64-msvc/package.json").version;
149
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
149
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
150
150
  return binding;
151
151
  } catch (e) {
152
152
  loadErrors.push(e);
@@ -161,7 +161,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
161
161
  try {
162
162
  const binding = __require("@rolldown/binding-win32-ia32-msvc");
163
163
  const bindingPackageVersion = __require("@rolldown/binding-win32-ia32-msvc/package.json").version;
164
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
164
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
165
165
  return binding;
166
166
  } catch (e) {
167
167
  loadErrors.push(e);
@@ -175,7 +175,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
175
175
  try {
176
176
  const binding = __require("@rolldown/binding-win32-arm64-msvc");
177
177
  const bindingPackageVersion = __require("@rolldown/binding-win32-arm64-msvc/package.json").version;
178
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
178
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
179
179
  return binding;
180
180
  } catch (e) {
181
181
  loadErrors.push(e);
@@ -190,7 +190,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190
190
  try {
191
191
  const binding = __require("@rolldown/binding-darwin-universal");
192
192
  const bindingPackageVersion = __require("@rolldown/binding-darwin-universal/package.json").version;
193
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
193
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
194
194
  return binding;
195
195
  } catch (e) {
196
196
  loadErrors.push(e);
@@ -204,7 +204,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
204
204
  try {
205
205
  const binding = __require("@rolldown/binding-darwin-x64");
206
206
  const bindingPackageVersion = __require("@rolldown/binding-darwin-x64/package.json").version;
207
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
207
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
208
208
  return binding;
209
209
  } catch (e) {
210
210
  loadErrors.push(e);
@@ -218,7 +218,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
218
218
  try {
219
219
  const binding = __require("@rolldown/binding-darwin-arm64");
220
220
  const bindingPackageVersion = __require("@rolldown/binding-darwin-arm64/package.json").version;
221
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
221
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
222
222
  return binding;
223
223
  } catch (e) {
224
224
  loadErrors.push(e);
@@ -233,7 +233,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
233
233
  try {
234
234
  const binding = __require("@rolldown/binding-freebsd-x64");
235
235
  const bindingPackageVersion = __require("@rolldown/binding-freebsd-x64/package.json").version;
236
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
236
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
237
237
  return binding;
238
238
  } catch (e) {
239
239
  loadErrors.push(e);
@@ -247,7 +247,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
247
247
  try {
248
248
  const binding = __require("@rolldown/binding-freebsd-arm64");
249
249
  const bindingPackageVersion = __require("@rolldown/binding-freebsd-arm64/package.json").version;
250
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
250
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
251
251
  return binding;
252
252
  } catch (e) {
253
253
  loadErrors.push(e);
@@ -262,7 +262,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
262
262
  try {
263
263
  const binding = __require("@rolldown/binding-linux-x64-musl");
264
264
  const bindingPackageVersion = __require("@rolldown/binding-linux-x64-musl/package.json").version;
265
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
265
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
266
266
  return binding;
267
267
  } catch (e) {
268
268
  loadErrors.push(e);
@@ -276,7 +276,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
276
276
  try {
277
277
  const binding = __require("@rolldown/binding-linux-x64-gnu");
278
278
  const bindingPackageVersion = __require("@rolldown/binding-linux-x64-gnu/package.json").version;
279
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
279
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
280
280
  return binding;
281
281
  } catch (e) {
282
282
  loadErrors.push(e);
@@ -291,7 +291,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
291
291
  try {
292
292
  const binding = __require("@rolldown/binding-linux-arm64-musl");
293
293
  const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-musl/package.json").version;
294
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
294
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
295
295
  return binding;
296
296
  } catch (e) {
297
297
  loadErrors.push(e);
@@ -305,7 +305,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
305
305
  try {
306
306
  const binding = __require("@rolldown/binding-linux-arm64-gnu");
307
307
  const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-gnu/package.json").version;
308
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
308
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
309
309
  return binding;
310
310
  } catch (e) {
311
311
  loadErrors.push(e);
@@ -320,7 +320,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
320
320
  try {
321
321
  const binding = __require("@rolldown/binding-linux-arm-musleabihf");
322
322
  const bindingPackageVersion = __require("@rolldown/binding-linux-arm-musleabihf/package.json").version;
323
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
323
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
324
324
  return binding;
325
325
  } catch (e) {
326
326
  loadErrors.push(e);
@@ -334,7 +334,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
334
334
  try {
335
335
  const binding = __require("@rolldown/binding-linux-arm-gnueabihf");
336
336
  const bindingPackageVersion = __require("@rolldown/binding-linux-arm-gnueabihf/package.json").version;
337
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
337
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
338
338
  return binding;
339
339
  } catch (e) {
340
340
  loadErrors.push(e);
@@ -349,7 +349,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
349
349
  try {
350
350
  const binding = __require("@rolldown/binding-linux-loong64-musl");
351
351
  const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-musl/package.json").version;
352
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
352
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
353
353
  return binding;
354
354
  } catch (e) {
355
355
  loadErrors.push(e);
@@ -363,7 +363,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
363
363
  try {
364
364
  const binding = __require("@rolldown/binding-linux-loong64-gnu");
365
365
  const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-gnu/package.json").version;
366
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
366
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
367
367
  return binding;
368
368
  } catch (e) {
369
369
  loadErrors.push(e);
@@ -378,7 +378,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
378
378
  try {
379
379
  const binding = __require("@rolldown/binding-linux-riscv64-musl");
380
380
  const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-musl/package.json").version;
381
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
381
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
382
382
  return binding;
383
383
  } catch (e) {
384
384
  loadErrors.push(e);
@@ -392,7 +392,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
392
392
  try {
393
393
  const binding = __require("@rolldown/binding-linux-riscv64-gnu");
394
394
  const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-gnu/package.json").version;
395
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
395
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
396
396
  return binding;
397
397
  } catch (e) {
398
398
  loadErrors.push(e);
@@ -407,7 +407,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
407
407
  try {
408
408
  const binding = __require("@rolldown/binding-linux-ppc64-gnu");
409
409
  const bindingPackageVersion = __require("@rolldown/binding-linux-ppc64-gnu/package.json").version;
410
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
410
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
411
411
  return binding;
412
412
  } catch (e) {
413
413
  loadErrors.push(e);
@@ -421,7 +421,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
421
421
  try {
422
422
  const binding = __require("@rolldown/binding-linux-s390x-gnu");
423
423
  const bindingPackageVersion = __require("@rolldown/binding-linux-s390x-gnu/package.json").version;
424
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
424
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
425
425
  return binding;
426
426
  } catch (e) {
427
427
  loadErrors.push(e);
@@ -436,7 +436,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
436
436
  try {
437
437
  const binding = __require("@rolldown/binding-openharmony-arm64");
438
438
  const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm64/package.json").version;
439
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
439
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
440
440
  return binding;
441
441
  } catch (e) {
442
442
  loadErrors.push(e);
@@ -450,7 +450,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
450
450
  try {
451
451
  const binding = __require("@rolldown/binding-openharmony-x64");
452
452
  const bindingPackageVersion = __require("@rolldown/binding-openharmony-x64/package.json").version;
453
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
453
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
454
454
  return binding;
455
455
  } catch (e) {
456
456
  loadErrors.push(e);
@@ -464,7 +464,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
464
464
  try {
465
465
  const binding = __require("@rolldown/binding-openharmony-arm");
466
466
  const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm/package.json").version;
467
- if (bindingPackageVersion !== "1.1.5" && 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.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
467
+ if (bindingPackageVersion !== "1.2.1" && 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.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
468
468
  return binding;
469
469
  } catch (e) {
470
470
  loadErrors.push(e);
@@ -472,30 +472,107 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
472
472
  } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
473
473
  else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
474
474
  }
475
- nativeBinding = requireNative();
476
- const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || process.env.NAPI_RS_FORCE_WASI === "error";
475
+ function createLoadErrorChain(errors) {
476
+ return errors.reduce((previous, current) => {
477
+ let message;
478
+ try {
479
+ message = current && typeof current.message === "string" ? current.message : String(current);
480
+ } catch {
481
+ message = "Unknown error";
482
+ }
483
+ const error = new Error(message);
484
+ error.cause = previous;
485
+ return error;
486
+ }, null);
487
+ }
488
+ const __napiWasiFlavors = ["wasm32-wasi"];
489
+ const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR;
490
+ const __napiWasiFlavorRequested = typeof __napiWasiFlavor === "string" && __napiWasiFlavor.length > 0;
491
+ if (__napiWasiFlavorRequested && __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1) throw new Error("Unsupported WASI flavor \"" + __napiWasiFlavor + "\". Available flavors: " + __napiWasiFlavors.join(", "));
492
+ const forceWasiError = process.env.NAPI_RS_FORCE_WASI === "error";
493
+ const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || forceWasiError || __napiWasiFlavorRequested;
494
+ if (!forceWasi) nativeBinding = requireNative();
477
495
  if (!nativeBinding || forceWasi) {
478
496
  let wasiBinding = null;
479
- let wasiBindingError = null;
480
- try {
481
- wasiBinding = __require("../rolldown-binding.wasi.cjs");
482
- nativeBinding = wasiBinding;
483
- } catch (err) {
484
- if (forceWasi) wasiBindingError = err;
497
+ let wasiBindingLoaded = false;
498
+ const wasiBindingErrors = [];
499
+ const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
500
+ try {
501
+ __require.resolve(specifier);
502
+ } catch (resolveError) {
503
+ if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
504
+ if (isPackage) {
505
+ try {
506
+ __require.resolve(specifier + "/package.json");
507
+ } catch (packageError) {
508
+ if (packageError && packageError.code === "MODULE_NOT_FOUND") return resolveError;
509
+ throw resolveError;
510
+ }
511
+ throw resolveError;
512
+ }
513
+ return resolveError;
514
+ }
515
+ if (localArtifacts) {
516
+ let artifactError = null;
517
+ for (let i = 0; i < localArtifacts.length; i++) try {
518
+ __require.resolve(localArtifacts[i]);
519
+ return null;
520
+ } catch (resolveError) {
521
+ if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
522
+ artifactError = resolveError;
523
+ }
524
+ return artifactError;
525
+ }
526
+ return null;
527
+ };
528
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
529
+ let candidateError = null;
530
+ let candidateFailed = false;
531
+ try {
532
+ candidateError = __napiWasiResolveCandidate("./rolldown-binding.wasi.cjs", false, ["./rolldown-binding.wasm32-wasi.debug.wasm", "./rolldown-binding.wasm32-wasi.wasm"]);
533
+ candidateFailed = candidateError !== null;
534
+ if (!candidateFailed) {
535
+ wasiBinding = __require("../rolldown-binding.wasi.cjs");
536
+ nativeBinding = wasiBinding;
537
+ wasiBindingLoaded = true;
538
+ }
539
+ } catch (err) {
540
+ candidateError = err;
541
+ candidateFailed = true;
542
+ }
543
+ if (candidateFailed) {
544
+ wasiBindingErrors.push(candidateError);
545
+ loadErrors.push(candidateError);
546
+ }
485
547
  }
486
- if (!nativeBinding || forceWasi) try {
487
- wasiBinding = __require("@rolldown/binding-wasm32-wasi");
488
- nativeBinding = wasiBinding;
489
- } catch (err) {
490
- if (forceWasi) {
491
- if (!wasiBindingError) wasiBindingError = err;
492
- else wasiBindingError.cause = err;
493
- loadErrors.push(err);
548
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
549
+ let candidateError = null;
550
+ let candidateFailed = false;
551
+ try {
552
+ candidateError = __napiWasiResolveCandidate("@rolldown/binding-wasm32-wasi", true, void 0);
553
+ candidateFailed = candidateError !== null;
554
+ if (!candidateFailed) {
555
+ if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
556
+ const bindingPackageVersion = __require("@rolldown/binding-wasm32-wasi/package.json").version;
557
+ if (bindingPackageVersion !== "1.2.1") throw new Error(`WASI binding package version mismatch, expected 1.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
558
+ }
559
+ wasiBinding = __require("@rolldown/binding-wasm32-wasi");
560
+ nativeBinding = wasiBinding;
561
+ wasiBindingLoaded = true;
562
+ }
563
+ } catch (err) {
564
+ candidateError = err;
565
+ candidateFailed = true;
566
+ }
567
+ if (candidateFailed) {
568
+ wasiBindingErrors.push(candidateError);
569
+ loadErrors.push(candidateError);
494
570
  }
495
571
  }
496
- if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
497
- const error = /* @__PURE__ */ new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
498
- error.cause = wasiBindingError;
572
+ if (!wasiBindingLoaded && forceWasi && !forceWasiError && !__napiWasiFlavorRequested) nativeBinding = requireNative();
573
+ if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
574
+ const error = /* @__PURE__ */ new Error(__napiWasiFlavorRequested ? "WASI binding for flavor \"" + __napiWasiFlavor + "\" not found" : "WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
575
+ error.cause = createLoadErrorChain(wasiBindingErrors);
499
576
  throw error;
500
577
  }
501
578
  }
@@ -507,10 +584,7 @@ var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
507
584
  if (!nativeBinding) {
508
585
  if (loadErrors.length > 0) {
509
586
  const error = /* @__PURE__ */ 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.");
510
- error.cause = loadErrors.reduce((err, cur) => {
511
- cur.cause = err;
512
- return cur;
513
- });
587
+ error.cause = createLoadErrorChain(loadErrors);
514
588
  throw error;
515
589
  }
516
590
  throw new Error(`Failed to load native binding`);