{"record":{"id":"47d5e749ea77640a","repo":"swc-project/swc","slug":"plugin-runner-cannot-detect-plugin-s-schema-versio","errorCode":null,"errorMessage":"Plugin runner cannot detect plugin's schema version. Ensure host is compiled with proper versions","messagePattern":"Plugin runner cannot detect plugin's schema version\\. Ensure host is compiled with proper versions","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_plugin_runner/src/transform_executor.rs","lineNumber":139,"sourceCode":"\n            // TODO: this is incomplete\n            if host_schema_version >= self.plugin_core_diag.ast_schema_version {\n                Ok(())\n            } else {\n                anyhow::bail!(\n                    \"Plugin's AST schema version is not compatible with host's. Host: {}, Plugin: \\\n                     {}\",\n                    host_schema_version,\n                    self.plugin_core_diag.ast_schema_version\n                )\n            }\n        };\n\n        #[cfg(not(all(\n            feature = \"plugin_transform_schema_v1\",\n            feature = \"plugin_transform_schema_vtest\"\n        )))]\n        anyhow::bail!(\n            \"Plugin runner cannot detect plugin's schema version. Ensure host is compiled with \\\n             proper versions\"\n        )\n    }\n}\n\n/// A struct encapsule executing a plugin's transform.\npub struct TransformExecutor {\n    source_map: Arc<SourceMap>,\n    unresolved_mark: swc_common::Mark,\n    metadata_context: Arc<TransformPluginMetadataContext>,\n    plugin_env_vars: Option<Arc<Vec<swc_atoms::Atom>>>,\n    plugin_config: Option<serde_json::Value>,\n    module_bytes: Box<dyn PluginModuleBytes>,\n    runtime: Arc<dyn runtime::Runtime>,\n}\n\n#[cfg(feature = \"encoding-impl\")]","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_plugin_runner/src/transform_executor.rs#L121-L157","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# Cargo.toml before\nswc_plugin_runner = { version = \"0.\", default-features = false }\n\n# Cargo.toml after\nswc_plugin_runner = { version = \"0.\", default-features = false, features = [\"plugin_transform_schema_v1\", \"encoding-impl\"] }","handlingStrategy":"validation","validationCode":"// Rust: fail fast at startup if the host cannot validate plugins at all\nconst SCHEMA_FEATURE: bool = cfg!(any(\n    feature = \"plugin_transform_schema_v1\",\n    feature = \"plugin_transform_schema_vtest\",\n));\n// NB: cfg! in a *downstream* crate only sees that crate's features;\n// the authoritative check is: cargo tree -e features -p swc_plugin_runner | grep plugin_transform_schema\nif !SCHEMA_FEATURE && !plugins.is_empty() {\n    anyhow::bail!(\"host built without plugin_transform_schema_v1; plugins unsupported\");\n}","typeGuard":null,"tryCatchPattern":"match err_message.as_str() {\n    m if m.contains(\"cannot detect plugin's schema version\") => {\n        eprintln!(\"rebuild the host with plugin_transform_schema_v1 enabled, or remove plugins from config\");\n    }\n    _ => {}\n}","preventionTips":["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"],"tags":["swc","plugins","build-features","schema-version","config"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}