swc-project/swc · error

Filesystem cache is not enabled, cannot read plugin from…

Error message

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

What it means

PluginCache::store_bytes_from_path in swc_plugin_runner reads a plugin (.wasm) binary from a physical path and populates its caches. The entire read/store block is compiled only under cfg(all(not(target_arch = "wasm32"), feature = "filesystem_cache")); when that configuration is false (the `filesystem_cache` cargo feature is off, or the host targets wasm32), execution falls straight to bail!('Filesystem cache is not enabled, cannot read plugin from phsyical path'). So the API was asked to load a plugin from disk in a build that cannot do filesystem caching.

Solutions

  1. Enable the `filesystem_cache` feature on swc_plugin_runner (or the swc_core feature that turns it on) in your Cargo.toml
  2. On wasm32 targets, load plugins from bytes (store_bytes / in-memory paths) instead of a physical path
  3. If plugins are optional, guard plugin configuration so paths are only set when the host build supports filesystem caching

Example fix

# before
swc_core = { version = "...", features = ["ecma_plugin_transform"] }
# plugin loading from path -> bails

# after
swc_core = { version = "...", features = ["ecma_plugin_transform", "plugin_transform_schema_v1"] }
# and on swc_plugin_runner consumers:
swc_plugin_runner = { version = "...", features = ["filesystem_cache"] }
Defensive patterns

Strategy: validation

Validate before calling

# Before relying on path-based plugin loading, confirm the host build supports it
cargo tree -i swc_plugin_runner -f "{f}" # must list filesystem_cache when using store_bytes_from_path

Try / catch

if let Err(e) = cache.store_bytes_from_path(&rt, &path, key) {
    if e.to_string().contains("Filesystem cache is not enabled") {
        // fall back to in-memory bytes: cache.store_bytes(...) or skip fs caching
    } else { return Err(e); }
}

Prevention

When it happens

Trigger: Calling store_bytes_from_path(binary_path, key) on a swc_plugin_runner built without the `filesystem_cache` feature, or running the plugin runner on wasm32 where filesystem plugin loading is unsupported.

Common situations: Using swc core with default features that exclude plugin filesystem caching while a plugin path is configured; embedding the plugin runner in a wasm host (playground) but passing a physical plugin path; feature-flag drift after upgrading swc_core where the feature moved.

Related errors


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

Appendix: 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 5176682b65)