-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Can't select a universal swc_core
version for my plugin to satisfy all next.js users
#8315
Comments
In short, this is impossible. The issue you created is an umbrella issue for the swc plugin stablization, one of the large reason plugin support is marked as beta. Since there is inevitable breaking changes for the AST struct, each time it happens plugin have to align swc_core version to the host runtime. What we are trying to achieve is however, 1. reduce the frequency of breaking changes 2. provide a better diagnostics for the runtime / plugin mismatch 3. provide some sort of interfaces to handshake in runtime instead of panic There are tracking issues for these kinds of problems: |
I'd suggest closing this issue since we have tracking actionable items already, just blocked by some upstream support / internal blockers need to be resolved. |
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. |
Related Issues:
next build
with 13.2.4 vercel/next.js#46989Issue Description:
Hey! I'm Yassin, a member of The Guild.
Hey there! I'm Yassin, a member of The Guild. A few months ago, in collaboration with our contributor @JesseVelden, we introduced an SWC plugin for GraphQL Code Generator. The aim was to optimize bundle size for SWC (Next.js) projects.
Initially, it worked really well, but after a few weeks, it started breaking with a very common error:
I started digging the root of the issue, I noticed that the Next.js version has a significant impact on the plugin's functionality. Bumping the Next.js version breaks it, while pinning it to a specific version keeps it working.
I recently came across this valuable documentation that sheds light on the issue:
https://swc.rs/docs/plugin/selecting-swc-core
It mentions:
From what I understand, this implies that for each
swc_core
version range (e.g.,v0.78.x
), the plugin works for a specific range of Next.js versions, which is at the root of the problem.Questions and Concerns:
swc_core
version?v0.76.x
works for users with Next.js versions ranging fromnext@v13.4.3-canary.2 to next@v13.4.7
, but it becomes incompatible with users on more up-to-date versions of Next.js. How can we address this?swc_core
version to the latest, likev0.82.x
, makes it compatible with newer Next.js versions but breaks compatibility with older versions. How can we ensure a smoother transition for users as they upgrade Next.js?My Initial Approach:
I explored creating an installation CLI. It would read the Next.js version in a project's
package.json
and determine the right SWC plugin version to use. When publishing from our end, the SWC plugin would provide versions like:@graphql-codegen/swc-plugin@v0.78.x
@graphql-codegen/swc-plugin@v0.76.x
@graphql-codegen/swc-plugin@v0.75.x
The CLI would decide on the installation version based on the read Next.js version from the project. However, upgrading the Next.js version would break the SWC plugin.
Challenges:
Of course, the above is a very frugal solution, and not very practical. So, I abandoned that route.
Proposed Solution:
To ensure that all Next.js users can successfully use the SWC Client Preset plugin (and other SWC plugins, I have seen many complain about the same issue), we need to find a way to handle the version compatibility issue effectively. This could involve better documentation, tooling, or strategies for selecting the appropriate
swc_core
version based on the Next.js version in use.I might be missing a crucial detail in handling maintaining it, please correct me if I'm wrong.
Let's discuss on finding a solution that works for all users and avoids compatibility issues.
I would really appreciate your insights and suggestions! 🙏
Minimal reproduction:
You can checkout to both of those branches and follow the README instructions, the only difference between them is:
The above uses the SWC Client Preset plugin which is compiled with
swc_core@0.75.x
.You will notice that with different Next.js versions, it can break.
Expected behavior
SWC Plugins should work with all Next.js versions with no hassle.
Actual behavior
SWC Plugins break depending on the Next.js versions and the
swc_core
version which conflicts.Version
All
Additional context
No response
The text was updated successfully, but these errors were encountered: