oxc-transform
Advanced tools
+192
-79
@@ -84,4 +84,4 @@ // prettier-ignore | ||
| const bindingPackageVersion = require('@oxc-transform/binding-android-arm64/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -101,4 +101,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-android-arm-eabi/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -123,4 +123,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-win32-x64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -140,4 +140,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-win32-x64-msvc/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -158,4 +158,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-win32-ia32-msvc/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -175,4 +175,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-win32-arm64-msvc/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -195,4 +195,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-darwin-universal/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -212,4 +212,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-darwin-x64/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -229,4 +229,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-darwin-arm64/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -250,4 +250,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-freebsd-x64/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -267,4 +267,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-freebsd-arm64/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -289,4 +289,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-x64-musl/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -306,4 +306,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-x64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -325,4 +325,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-arm64-musl/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -342,4 +342,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-arm64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -361,4 +361,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-arm-musleabihf/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -378,4 +378,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-arm-gnueabihf/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -397,4 +397,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-loong64-musl/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -414,4 +414,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-loong64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -433,4 +433,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-riscv64-musl/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -450,4 +450,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-riscv64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -468,4 +468,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-ppc64-gnu/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -485,4 +485,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-linux-s390x-gnu/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -506,4 +506,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-openharmony-arm64/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -523,4 +523,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-openharmony-x64/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -540,4 +540,4 @@ return binding | ||
| const bindingPackageVersion = require('@oxc-transform/binding-openharmony-arm/package.json').version | ||
| if (bindingPackageVersion !== '0.142.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.142.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| if (bindingPackageVersion !== '0.143.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| throw new Error(`Native binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
@@ -556,43 +556,159 @@ return binding | ||
| nativeBinding = requireNative() | ||
| function createLoadErrorChain(errors) { | ||
| return errors.reduce((previous, current) => { | ||
| let message | ||
| try { | ||
| message = | ||
| current && typeof current.message === 'string' | ||
| ? current.message | ||
| : String(current) | ||
| } catch { | ||
| message = 'Unknown error' | ||
| } | ||
| const error = new Error(message) | ||
| error.cause = previous | ||
| return error | ||
| }, null) | ||
| } | ||
| // NAPI_RS_FORCE_WASI is a tri-state flag: | ||
| // unset / any other value → native binding preferred, WASI is only a fallback | ||
| // 'true' → force WASI fallback even if native loaded | ||
| // 'error' → force WASI and throw if no WASI binding is found | ||
| // 'true' → prefer WASI, but retain native as a lazy fallback | ||
| // 'error' → require WASI without initializing a native fallback | ||
| // Treating any non-empty string as truthy (the historical behavior) meant | ||
| // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered | ||
| // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file. | ||
| // | ||
| // NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict | ||
| // WASI loading. It never crosses into another flavor or falls back to native. | ||
| const __napiWasiFlavors = ["wasm32-wasi"] | ||
| const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR | ||
| const __napiWasiFlavorRequested = | ||
| typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0 | ||
| if ( | ||
| __napiWasiFlavorRequested && | ||
| __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1 | ||
| ) { | ||
| throw new Error( | ||
| 'Unsupported WASI flavor "' + | ||
| __napiWasiFlavor + | ||
| '". Available flavors: ' + | ||
| __napiWasiFlavors.join(', '), | ||
| ) | ||
| } | ||
| const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error' | ||
| const forceWasi = | ||
| process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error' | ||
| process.env.NAPI_RS_FORCE_WASI === 'true' || | ||
| forceWasiError || | ||
| __napiWasiFlavorRequested | ||
| if (!forceWasi) { | ||
| nativeBinding = requireNative() | ||
| } | ||
| if (!nativeBinding || forceWasi) { | ||
| let wasiBinding = null | ||
| let wasiBindingError = null | ||
| try { | ||
| wasiBinding = require('./transform.wasi.cjs') | ||
| nativeBinding = wasiBinding | ||
| } catch (err) { | ||
| if (forceWasi) { | ||
| wasiBindingError = err | ||
| let wasiBindingLoaded = false | ||
| const wasiBindingErrors = [] | ||
| const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => { | ||
| try { | ||
| require.resolve(specifier) | ||
| } catch (resolveError) { | ||
| if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') { | ||
| throw resolveError | ||
| } | ||
| if (isPackage) { | ||
| try { | ||
| require.resolve(specifier + '/package.json') | ||
| } catch (packageError) { | ||
| if (packageError && packageError.code === 'MODULE_NOT_FOUND') { | ||
| return resolveError | ||
| } | ||
| // An exports restriction proves the package exists even when its | ||
| // package.json is not public. Preserve the root resolution failure. | ||
| throw resolveError | ||
| } | ||
| // The package exists but its main/export target is broken. | ||
| throw resolveError | ||
| } | ||
| return resolveError | ||
| } | ||
| if (localArtifacts) { | ||
| let artifactError = null | ||
| for (let i = 0; i < localArtifacts.length; i++) { | ||
| try { | ||
| require.resolve(localArtifacts[i]) | ||
| return null | ||
| } catch (resolveError) { | ||
| if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') { | ||
| throw resolveError | ||
| } | ||
| artifactError = resolveError | ||
| } | ||
| } | ||
| return artifactError | ||
| } | ||
| return null | ||
| } | ||
| if (!nativeBinding || forceWasi) { | ||
| if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) { | ||
| let candidateError = null | ||
| let candidateFailed = false | ||
| try { | ||
| wasiBinding = require('@oxc-transform/binding-wasm32-wasi') | ||
| nativeBinding = wasiBinding | ||
| candidateError = __napiWasiResolveCandidate('./transform.wasi.cjs', false, ["./transform.wasm32-wasi.debug.wasm","./transform.wasm32-wasi.wasm"]) | ||
| candidateFailed = candidateError !== null | ||
| if (!candidateFailed) { | ||
| wasiBinding = require('./transform.wasi.cjs') | ||
| nativeBinding = wasiBinding | ||
| wasiBindingLoaded = true | ||
| } | ||
| } catch (err) { | ||
| if (forceWasi) { | ||
| if (!wasiBindingError) { | ||
| wasiBindingError = err | ||
| } else { | ||
| wasiBindingError.cause = err | ||
| candidateError = err | ||
| candidateFailed = true | ||
| } | ||
| if (candidateFailed) { | ||
| wasiBindingErrors.push(candidateError) | ||
| loadErrors.push(candidateError) | ||
| } | ||
| } | ||
| if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) { | ||
| let candidateError = null | ||
| let candidateFailed = false | ||
| try { | ||
| candidateError = __napiWasiResolveCandidate('@oxc-transform/binding-wasm32-wasi', true, undefined) | ||
| candidateFailed = candidateError !== null | ||
| if (!candidateFailed) { | ||
| if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { | ||
| const bindingPackageVersion = require('@oxc-transform/binding-wasm32-wasi/package.json').version | ||
| if (bindingPackageVersion !== '0.143.0') { | ||
| throw new Error(`WASI binding package version mismatch, expected 0.143.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) | ||
| } | ||
| } | ||
| loadErrors.push(err) | ||
| wasiBinding = require('@oxc-transform/binding-wasm32-wasi') | ||
| nativeBinding = wasiBinding | ||
| wasiBindingLoaded = true | ||
| } | ||
| } catch (err) { | ||
| candidateError = err | ||
| candidateFailed = true | ||
| } | ||
| if (candidateFailed) { | ||
| wasiBindingErrors.push(candidateError) | ||
| loadErrors.push(candidateError) | ||
| } | ||
| } | ||
| if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { | ||
| const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') | ||
| error.cause = wasiBindingError | ||
| if ( | ||
| !wasiBindingLoaded && | ||
| forceWasi && | ||
| !forceWasiError && | ||
| !__napiWasiFlavorRequested | ||
| ) { | ||
| nativeBinding = requireNative() | ||
| } | ||
| if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) { | ||
| const error = new Error( | ||
| __napiWasiFlavorRequested | ||
| ? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found' | ||
| : 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error', | ||
| ) | ||
| error.cause = createLoadErrorChain(wasiBindingErrors) | ||
| throw error | ||
@@ -619,6 +735,3 @@ } | ||
| // which Node < 16.9 silently ignores | ||
| error.cause = loadErrors.reduce((err, cur) => { | ||
| cur.cause = err | ||
| return cur | ||
| }) | ||
| error.cause = createLoadErrorChain(loadErrors) | ||
| throw error | ||
@@ -625,0 +738,0 @@ } |
+24
-25
| { | ||
| "name": "oxc-transform", | ||
| "version": "0.142.0", | ||
| "version": "0.143.0", | ||
| "description": "Oxc Transformer Node API", | ||
@@ -41,5 +41,5 @@ "keywords": [ | ||
| "devDependencies": { | ||
| "@emnapi/core": "1.11.2", | ||
| "@emnapi/runtime": "1.11.2", | ||
| "@napi-rs/cli": "3.7.4", | ||
| "@emnapi/core": "2.0.0-alpha.3", | ||
| "@emnapi/runtime": "2.0.0-alpha.3", | ||
| "@napi-rs/cli": "3.8.2", | ||
| "@types/node": "24.1.0", | ||
@@ -84,22 +84,21 @@ "publint": "0.3.22", | ||
| "optionalDependencies": { | ||
| "@oxc-transform/binding-darwin-arm64": "0.142.0", | ||
| "@oxc-transform/binding-android-arm64": "0.142.0", | ||
| "@oxc-transform/binding-win32-arm64-msvc": "0.142.0", | ||
| "@oxc-transform/binding-linux-arm64-gnu": "0.142.0", | ||
| "@oxc-transform/binding-linux-arm64-musl": "0.142.0", | ||
| "@oxc-transform/binding-openharmony-arm64": "0.142.0", | ||
| "@oxc-transform/binding-android-arm-eabi": "0.142.0", | ||
| "@oxc-transform/binding-linux-arm-gnueabihf": "0.142.0", | ||
| "@oxc-transform/binding-linux-arm-musleabihf": "0.142.0", | ||
| "@oxc-transform/binding-win32-ia32-msvc": "0.142.0", | ||
| "@oxc-transform/binding-linux-ppc64-gnu": "0.142.0", | ||
| "@oxc-transform/binding-linux-riscv64-gnu": "0.142.0", | ||
| "@oxc-transform/binding-linux-riscv64-musl": "0.142.0", | ||
| "@oxc-transform/binding-linux-s390x-gnu": "0.142.0", | ||
| "@oxc-transform/binding-wasm32-wasi": "0.142.0", | ||
| "@oxc-transform/binding-darwin-x64": "0.142.0", | ||
| "@oxc-transform/binding-win32-x64-msvc": "0.142.0", | ||
| "@oxc-transform/binding-freebsd-x64": "0.142.0", | ||
| "@oxc-transform/binding-linux-x64-gnu": "0.142.0", | ||
| "@oxc-transform/binding-linux-x64-musl": "0.142.0" | ||
| "@oxc-transform/binding-darwin-arm64": "0.143.0", | ||
| "@oxc-transform/binding-android-arm64": "0.143.0", | ||
| "@oxc-transform/binding-win32-arm64-msvc": "0.143.0", | ||
| "@oxc-transform/binding-linux-arm64-gnu": "0.143.0", | ||
| "@oxc-transform/binding-linux-arm64-musl": "0.143.0", | ||
| "@oxc-transform/binding-openharmony-arm64": "0.143.0", | ||
| "@oxc-transform/binding-android-arm-eabi": "0.143.0", | ||
| "@oxc-transform/binding-linux-arm-gnueabihf": "0.143.0", | ||
| "@oxc-transform/binding-linux-arm-musleabihf": "0.143.0", | ||
| "@oxc-transform/binding-win32-ia32-msvc": "0.143.0", | ||
| "@oxc-transform/binding-linux-ppc64-gnu": "0.143.0", | ||
| "@oxc-transform/binding-linux-riscv64-gnu": "0.143.0", | ||
| "@oxc-transform/binding-linux-riscv64-musl": "0.143.0", | ||
| "@oxc-transform/binding-linux-s390x-gnu": "0.143.0", | ||
| "@oxc-transform/binding-darwin-x64": "0.143.0", | ||
| "@oxc-transform/binding-win32-x64-msvc": "0.143.0", | ||
| "@oxc-transform/binding-freebsd-x64": "0.143.0", | ||
| "@oxc-transform/binding-linux-x64-gnu": "0.143.0", | ||
| "@oxc-transform/binding-linux-x64-musl": "0.143.0" | ||
| }, | ||
@@ -113,5 +112,5 @@ "scripts": { | ||
| "build-wasm": "pnpm run build-wasm-dev --release", | ||
| "build-wasm-dev": "pnpm run build-dev --target wasm32-wasip1-threads", | ||
| "build-wasm-dev": "pnpm run build-dev --target wasm32-wasip1-threads --dts transform.wasi.d.cts", | ||
| "test": "vitest run --dir ./test" | ||
| } | ||
| } |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
58723
7.35%19
-5%1390
8.76%66
3.13%