swc-project/swc · error

Transform plugin cannot be used without serialization suppor

Error message

Transform plugin cannot be used without serialization support

What it means

swc_plugin_runner::create_plugin_transform_executor builds the executor that loads a .wasm transform plugin and exchanges serialized ASTs with it. The entire pipeline depends on the serialization protocol enabled by the encoding-impl feature (which turns on swc_common/plugin-rt and swc_plugin_proxy/plugin-rt). Without it, the constructor is compiled as a signature-compatible stub that panics with unimplemented!("Transform plugin cannot be used without serialization support") rather than returning an executor that could never talk to the plugin.

Source

Thrown at crates/swc_plugin_runner/src/lib.rs:54

        unresolved_mark,
        metadata_context,
        plugin_env_vars,
        plugin_config,
        plugin_runtime,
    )
}

#[cfg(not(feature = "encoding-impl"))]
pub fn create_plugin_transform_executor(
    source_map: &Arc<SourceMap>,
    unresolved_mark: &swc_common::Mark,
    metadata_context: &Arc<TransformPluginMetadataContext>,
    plugin_env_vars: Option<Arc<Vec<swc_atoms::Atom>>>,
    plugin_module: Box<dyn PluginModuleBytes>,
    plugin_config: Option<serde_json::Value>,
    runtime: Option<()>,
) -> TransformExecutor {
    unimplemented!("Transform plugin cannot be used without serialization support")
}

View on GitHub (pinned to 5176682b65)

Solutions

  1. Enable the feature: swc_plugin_runner = { features = ["encoding-impl"] } (or let the normal swc/plugin host dependency chain enable it).
  2. Confirm resolution with `cargo tree -e features -i swc_plugin_runner` and check for encoding-impl / plugin-rt edges.
  3. If plugin execution was not intended in this build, remove the call path that constructs the transform executor.

Example fix

# before: executor construction panics
[dependencies]
swc_plugin_runner = { version = "34", default-features = false }

# after
[dependencies]
swc_plugin_runner = { version = "34", default-features = false, features = ["encoding-impl"] }
Defensive patterns

Strategy: validation

Validate before calling

cargo tree -e features -i swc_plugin_runner | grep -E 'encoding-impl|plugin-rt' \
  || echo 'swc_plugin_runner lacks serialization features — create_plugin_transform_executor will panic'

Prevention

When it happens

Trigger: Calling create_plugin_transform_executor in a build of swc_plugin_runner where encoding-impl is not enabled — e.g. default-features = false without re-adding it, or a dependency graph that pulls swc_plugin_runner for host utilities while dropping the plugin runtime features.

Common situations: Embedding swc's plugin runner into a custom host with trimmed features; feature unification across workspace members disabling optional serialization; version drift after feature rewiring between swc releases.

Related errors


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