swc-project/swc · error · anyhow::Error
Plugin runner cannot detect plugin's schema version. Ensure
Error message
Plugin runner cannot detect plugin's schema version. Ensure host is compiled with proper versions
What it means
Raised by the cfg(not(...)) arm of is_transform_schema_compatible: the host binary was compiled without any of the plugin_transform_schema_v1/plugin_transform_schema_vtest feature flags, so it has no notion of an AST schema version and cannot validate plugins at all. Using plugins on such a build is unsupported by construction.
Source
Thrown at crates/swc_plugin_runner/src/transform_executor.rs:139
// TODO: this is incomplete
if host_schema_version >= self.plugin_core_diag.ast_schema_version {
Ok(())
} else {
anyhow::bail!(
"Plugin's AST schema version is not compatible with host's. Host: {}, Plugin: \
{}",
host_schema_version,
self.plugin_core_diag.ast_schema_version
)
}
};
#[cfg(not(all(
feature = "plugin_transform_schema_v1",
feature = "plugin_transform_schema_vtest"
)))]
anyhow::bail!(
"Plugin runner cannot detect plugin's schema version. Ensure host is compiled with \
proper versions"
)
}
}
/// A struct encapsule executing a plugin's transform.
pub struct TransformExecutor {
source_map: Arc<SourceMap>,
unresolved_mark: swc_common::Mark,
metadata_context: Arc<TransformPluginMetadataContext>,
plugin_env_vars: Option<Arc<Vec<swc_atoms::Atom>>>,
plugin_config: Option<serde_json::Value>,
module_bytes: Box<dyn PluginModuleBytes>,
runtime: Arc<dyn runtime::Runtime>,
}
#[cfg(feature = "encoding-impl")]View on GitHub (pinned to d7d7434666)
Solutions
- Enable the plugin_transform_schema_v1 feature (the current schema) on swc_plugin_runner in your build
- Or drop jsc.experimental.plugins from the config for this stripped build
- Verify with cargo tree -e features that the flag actually reaches swc_plugin_runner
Example fix
# Cargo.toml before
swc_plugin_runner = { version = "0.", default-features = false }
# Cargo.toml after
swc_plugin_runner = { version = "0.", default-features = false, features = ["plugin_transform_schema_v1", "encoding-impl"] } Defensive patterns
Strategy: validation
Validate before calling
// Rust: fail fast at startup if the host cannot validate plugins at all
const SCHEMA_FEATURE: bool = cfg!(any(
feature = "plugin_transform_schema_v1",
feature = "plugin_transform_schema_vtest",
));
// NB: cfg! in a *downstream* crate only sees that crate's features;
// the authoritative check is: cargo tree -e features -p swc_plugin_runner | grep plugin_transform_schema
if !SCHEMA_FEATURE && !plugins.is_empty() {
anyhow::bail!("host built without plugin_transform_schema_v1; plugins unsupported");
} Try / catch
match err_message.as_str() {
m if m.contains("cannot detect plugin's schema version") => {
eprintln!("rebuild the host with plugin_transform_schema_v1 enabled, or remove plugins from config");
}
_ => {}
} Prevention
- When trimming default features, always re-add plugin_transform_schema_v1 if plugins stay enabled
- Add a cargo feature assertion step to CI for downstream swc builds
- Prefer stock feature presets over hand-picked lists when plugin support is required
When it happens
Trigger: A downstream build of swc_plugin_runner/swc that disabled the schema feature flags (default-features = false, custom feature selection) but still enables plugin usage, so compile_wasm_plugins + transform path runs into this bail.
Common situations: Custom embeddings or downstream distros of swc trimming features; Cargo feature unification changes after dependency edits; building analysis/plugin tooling against a stripped swc_core.
Related errors
- Failed to resolve plugin path: {resolved_path:?}
- Filesystem cache is not enabled, cannot read plugin from phs
- Plugin's AST schema version is not compatible with host's. H
- derive(Merge) does not support an enum
- Failed to serialize output: {e}
AI-assisted analysis of swc-project/swc@d7d7434666 (2026-08-16).
Data as JSON: /api/errors/47d5e749ea77640a.
Report an issue: GitHub.