Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version conflicts between syn 1.x and 2.x when using swc_core 0.59.40 #9793

Closed
asde29873012549 opened this issue Dec 11, 2024 · 2 comments
Closed
Labels

Comments

@asde29873012549
Copy link

Describe the bug

When using swc_core = "0.59.40" and its related crates, there are multiple compilation errors due to version conflicts between syn 1.x and syn 2.x. The errors manifest as type mismatches between similar types from different versions of syn.

Reproduction

Using the following dependencies in Cargo.toml:

[workspace.dependencies]
swc_core = "0.59.40"
testing = "0.31.34"
swc_ecma_parser = "0.124.12"

Error Examples

Type conflicts between syn 1.x and syn 2.x:

syn::Attribute vs syn::attr::Attribute
syn::Fields vs syn::data::Fields
syn::DeriveInput vs syn::derive::DeriveInput
Punctuated<Lit, _> vs Punctuated<Lit, Comma>
Sample error messages:
mismatched types
syn::Attribute and syn::attr::Attribute have similar names, but are actually distinct types
perhaps two different versions of crate syn are being used?

Technical Details

The issue appears to stem from transitive dependencies using different versions of syn:

syn 1.0.109 types are being used in some places
syn 2.0.87 types are being used in others
This causes type mismatches in macros and type definitions, particularly in the ast_node-0.8.8 crate.

I### mpact
This version conflict prevents compilation of projects using these SWC components, making it impossible to build SWC plugins or tools depending on these versions.

Minimal Production

https://codesandbox.io/p/devbox/hf4g3g

Questions

  1. Since I'm using the suggested swc_core version implied by : https://plugins.swc.rs/. It is a bit weird that it can't work by default?
  2. Plus, the minimal nextjs version provided by the version selecting tool is 13.1.6. Does this implies that its impossible to work for lower version nextjs such as 12.2.5 or something like this?

Environment

Rust version: rustc 1.82.0
OS: macOS 14.5

Input code

No response

Config

No response

Playground link (or link to the minimal reproduction)

https://github.com/asde29873012549/swc_plugin_demo

SWC Info output

No response

Expected behavior

It should compile expectedly

Actual behavior

No response

Version

swc_core = "0.59.40"

Additional context

No response

@kdy1
Copy link
Member

kdy1 commented Dec 11, 2024

We don't backport fixes because it requires too much effort without enough gain

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Jan 10, 2025

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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Jan 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants