Skip to content

Wasm plugins are not backward compatible #5060

Closed

Description

@kwonoj

Describe the feature

This is by far the biggest blocker for the official release for the plugin feature. (I thought I filed this already somehow).

The main issue in here is reducing chances of breaking changes for the plugin. There are 3 possible cases which causes diverge between plugins to the host for serialization / deserialization, namely

  • adding a new property into an existing ast struct
  • removing a new property from an existing ast struct
  • rename existing property from an ast struct

Each time this happens, the plugin will not be able to run on the newer versions of swc include those changes. These kind of breaking change itself is unavoidable unfortunately, but also we may be able to reduce the chances of it or at least avoid it happening unexpectedly.

We'll attempt to follow versioned struct approach suggested by underlying serialization mechanism (https://github.com/rkyv/rkyv/blob/master/examples/backwards_compat/src/main.rs) with compiler flags. When we need a possible breaking changes it'll be guarded by flags, providing backward compatibility as much as it can. Still worth mentioning this only applies to adding part - removing, or renaming is a clear breaking change we can't avoid to request plugin bumps up with the latest changes. At least, we hope those kind of operation won't happen that frequently.

Babel plugin or link to the feature description

No response

Additional context

#3540

Activity

  1. added this to the Planned milestone on Jun 28, 2022
  2. changed the title [-]Versioned struct for the plugin-host serialization[/-] [+]Wasm plugins are not backward compatible[/+] on Jan 24, 2024
  3. thesayyn commented on May 19, 2024

    @thesayyn

    FWIW, capn solves this is really good way, there's not really a good way to solve this problem other than inventing a clever encoding mechanism like this.

  4. RobinClowers commented on Jul 19, 2024

    @RobinClowers

    I'm just trying out SWC and this issue is pretty painful for my team. I was excited to find https://github.com/pmndrs/swc-jotai, but then discovered they are pretty far behind on the core version, so to get everything working, I would have to manually downgrade things until I find a set of versions that work together.

  5. frattaro commented on Jul 12, 2025

    @frattaro

    so if the issue with backwards compatibility is solved, does that mean swc plugins will no longer be under experimental in next?

  6. kdy1 commented on Jul 12, 2025

    @kdy1
    Member

    Nope. Wasm plugins are still experimental

  7. old-swc-bot commented on Aug 12, 2025

    @old-swc-bot
    Contributor

    This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

  8. locked as resolved and limited conversation to collaborators on Aug 12, 2025
  9. unlocked this conversation on Nov 4, 2025
  10. kdy1 commented on Nov 4, 2025

    @kdy1
    Member

    It'll be much more backward compatible with v1.15.0.

    https://blog.swc.rs/2025-11-4-wasm-backward-compatibility

  11. old-swc-bot commented on Dec 5, 2025

    @old-swc-bot
    Contributor

    This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

  12. locked as resolved and limited conversation to collaborators on Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions