swc-project/swc · error · anyhow::Error

Filesystem cache is not enabled, cannot read plugin from phs

Error message

Filesystem cache is not enabled, cannot read plugin from phsyical path

What it means

PluginModuleCacheInner::store_bytes_from_path can only read a plugin binary from a physical path when the host was compiled with the filesystem_cache code path (cfg(not(target_arch = "wasm32"), feature = "filesystem_cache")). When that cfg block is compiled out, execution falls straight through to this bail. It is a capability error: this build of the plugin runner cannot accept path-based plugin loading at all.

Source

Thrown at crates/swc_plugin_runner/src/cache.rs:144

                        fs_cache_store.store(rt, &module_bytes_hash, &cache)?;
                        cache
                    };

                // Store hash to load from fs_cache_store later.
                self.fs_cache_hash_store
                    .insert(key.to_string(), module_bytes_hash);

                // Also store in memory for the in-process cache.
                self.insert_compiled_module_bytes(key.to_string(), module);
            }

            // Store raw bytes into memory cache.
            self.insert_raw_bytes(key.to_string(), raw_module_bytes);

            return Ok(());
        }

        anyhow::bail!("Filesystem cache is not enabled, cannot read plugin from phsyical path");
    }

    /// Returns a PluingModuleBytes can be compiled into a wasmer::Module.
    /// Depends on the cache availability, it may return a raw bytes or a
    /// serialized bytes.
    pub fn get(&self, rt: &dyn runtime::Runtime, key: &str) -> Option<Box<dyn PluginModuleBytes>> {
        // Look for compiled module bytes first, it is the cheapest way to get compile
        // wasmer::Module.
        if let Some(compiled_module) = self.compiled_module_bytes.get(key) {
            let cache = rt.clone_cache(compiled_module)?;
            return Some(Box::new(CompiledPluginModuleBytes::new(
                key.to_string(),
                cache,
            )));
        }

        // Next, read serialzied bytes from filesystem cache.
        #[cfg(all(not(target_arch = "wasm32"), feature = "filesystem_cache"))]

View on GitHub (pinned to d7d7434666)

Solutions

  1. Remove/disable jsc.experimental.plugins for wasm32 or feature-less builds - plugins cannot load there
  2. Rebuild the host with the filesystem_cache feature enabled (non-wasm32 target)
  3. If you vendor swc_plugin_runner, ensure the feature propagates through your dependency tree (cargo tree -f '{p} {f}' -p swc_plugin_runner)

Example fix

# Cargo.toml before
swc_plugin_runner = "0."

# Cargo.toml after
swc_plugin_runner = { version = "0.", features = ["filesystem_cache"] }
Defensive patterns

Strategy: validation

Validate before calling

// Rust: gate plugin config on build capability before transforming
fn plugins_supported() -> bool {
    #[cfg(all(not(target_arch = "wasm32"), feature = "filesystem_cache"))]
    { true }
    #[cfg(not(all(not(target_arch = "wasm32"), feature = "filesystem_cache")))]
    { false }
}

if !plugins.is_empty() && !plugins_supported() {
    anyhow::bail!("plugins requested but this build cannot load plugins from paths");
}

Try / catch

// Rust: catch at config load with an actionable message
if let Err(e) = swc::try_with_handler(...) { /* ... */ }
match err.downcast_ref::<anyhow::Error>() {
    Some(e) if e.to_string().contains("Filesystem cache is not enabled") => {
        return Err(anyhow!("disable jsc.experimental.plugins or rebuild with filesystem_cache"));
    }
    _ => return Err(err),
}

Prevention

When it happens

Trigger: Compiling wasm plugins into the cache on a host built for target_arch = "wasm32", or a swc_plugin_runner build without the filesystem_cache feature, and then configuring jsc.experimental.plugins (which always ends in store_bytes_from_path).

Common situations: Running swc in the browser via wasm bindings and leaving plugins in the config; downstream crates depending on swc_plugin_runner with default features off; embedding swc_core in a custom runtime that disables the cache feature.

Related errors


AI-assisted analysis of swc-project/swc@d7d7434666 (2026-08-16). Data as JSON: /api/errors/56d05b7a081c30e6. Report an issue: GitHub.