@mdream/action 1.2.2 → 1.4.0

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.
@@ -529,23 +529,33 @@ function requireNative() {
529
529
 
530
530
  nativeBinding = requireNative()
531
531
 
532
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
532
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
533
+ // unset / any other value → native binding preferred, WASI is only a fallback
534
+ // 'true' → force WASI fallback even if native loaded
535
+ // 'error' → force WASI and throw if no WASI binding is found
536
+ // Treating any non-empty string as truthy (the historical behavior) meant
537
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
538
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
539
+ const forceWasi =
540
+ process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'
541
+
542
+ if (!nativeBinding || forceWasi) {
533
543
  let wasiBinding = null
534
544
  let wasiBindingError = null
535
545
  try {
536
546
  wasiBinding = require('./rust.wasi.cjs')
537
547
  nativeBinding = wasiBinding
538
548
  } catch (err) {
539
- if (process.env.NAPI_RS_FORCE_WASI) {
549
+ if (forceWasi) {
540
550
  wasiBindingError = err
541
551
  }
542
552
  }
543
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
553
+ if (!nativeBinding || forceWasi) {
544
554
  try {
545
555
  wasiBinding = require('@mdream/rust-wasm32-wasi')
546
556
  nativeBinding = wasiBinding
547
557
  } catch (err) {
548
- if (process.env.NAPI_RS_FORCE_WASI) {
558
+ if (forceWasi) {
549
559
  if (!wasiBindingError) {
550
560
  wasiBindingError = err
551
561
  } else {