-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: SWC plugin #9489
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
base: master
Are you sure you want to change the base?
fix: SWC plugin #9489
Conversation
|
oops, based off of the wrong branch |
Possible to get this merged? The swc plugin doesn't work at all right now. |
Is there any progress on this? |
@YassinEldeeb let's rebase this one now? |
I recreated this on top of master, and updated to swc_core 0.79.x but was unable to produce a binary that didn't panic.
I don't know enough about swc or rust to go much further. |
Ehy guys, do you have any updates on this? @YassinEldeeb @saihaj, thanks |
SWC Plugin Concerns & Clarifications:A while ago, I discussed with the team the SWC plugin and the challenges with its integration. Here's an overview of our findings: 1. SWC Core Versioning and Compatibility:
2. My Initial Approach:
And the CLI would decide on the installation version based on the read nextjs version from the project. And, of course, upgrading your nextjs version would likely break the SWC plugin silently. 3. Renovate Configuration Issues:
4. Future Challenges:
5. Development Concerns for SWC Plugin:
Hoping this sheds some light on the SWC plugin challenges. Feedback and suggestions are welcome! We've been busy preparing for the first GraphQL Conf 2023 held in San Francisco, and we plan to connect with SWC maintainers and figure out a solution together once we get back. I appreciate your patience! 🙏 6. Okay, but what for now?As for now, it appears to be that SWC plugins are meant to be built and used at an individual level, so you can:
|
@YassinEldeeb I appreciate the update! I tried to follow your steps on how to update this on my own – but it fails in different ways (basically confirming what @CaptainN commented above). Leaving this comment so maybe the community can figure this out.
Stack trace from
|
Hopefully relevant: The build failure is because of swc-project/swc#7479. Setting I've created a fork and published an npm package that changes
Update Sep 28: I've updated my fork and library to work with Next.js 13.5.3. Approach is basically to update |
Thank you! This saved me. |
That's absolutely amazing, @victorandree!! Sorry, I was late getting back to you, |
Hi @YassinEldeeb and @victorandree, thank you both for this MR and your patched NPM package! This has fixed the original syntax error that I was getting in #9337. Without any further updates to the repo, I was getting an out of bounds memory access error like in #9489 (comment), but that was fixed by upgrading However, the issue isn't entirely fixed yet. As soon as I import code from another TypeScript file, I get a different syntax error, even though I've updated my example repo for #9337 to use the patched SWC plugin and I've updated all dependencies to versions that should be compatible (in particular Could you look into this again please? 😊 |
FWIW, I recently noticed that my Next.js builds started ballooning in size, so I wanted to have another look at this issue (suspecting that maybe the plugin broke again). While I haven't had any issues using the plugin with Next.js 14.0.2, I figured it's good to be up-to-date. TL;DR: New version of my fork released as
IMHO, the concern about matching For now, I think it'd be worthwhile to release a new version of the plugin with an updated |
Hey, really sorry for the very late reply! We are currently tracking the issue with SWC maintainers to figure out a solution. Please add a 👍 to the issue and feel free to join the conversation. I'll keep you updated! |
@victorandree @bvobart @MatteoGiacomo @CaptainN @focux as you can see, unfortunately, they replied simply with |
@YassinEldeeb I appreciate trying to sync with the SWC maintainers on this, and I also appreciate the challenges of trying to keep things in sync between SWC/Next.js versions (and that Next.js isn't the only game in town). That said, would you consider releasing new versions of the plugin with documentation to clarify compatibility, or is this effectively unmaintained until SWC stabilizes? |
@victorandree I really appreciate your enthusiasm and engagement in this issue!
Unfortunately, SWC maintainers weren't able to promise us with up to date documentation on the compatibility between next.js versions and rust's
It's difficult, but I wouldn't say it's completely unmaintained, it's just about chasing up to date compatibility information from SWC, they have effectively claimed plugins to be a "Beta Feature", to avoid people complaining about them releasing breaking changes without notices. So it's tricky. We are thinking of moving the SWC plugin to the GraphQL Codegen Community repo, where the community can file issues of breaking changes as they detect it, lookup https://swc.rs/docs/plugin/selecting-swc-core for updated documentation, if not, ask SWC maintainer to update it by filing an issue, then finally releasing a new version of the SWC plugin, so there would be:
Where each new version doesn't override the previous one, but adds support for newer next.js versions. So, what do you think @victorandree? Would it be feasible to let the community (including most people in the current thread) take care of maintaining it given the challenges mentioned? We think if the community can quickly detect breaking changes, and one person can fix it and release it for everyone else, then it can work. Curious to hear your thoughts! 👀 |
|
Just discovered this thread after trying to update a project to use all the latest and greatest with the client preset. I'm very excited about the direction things are going, especially with the focus on composing fragments up the tree! I'm not using NextJS, just a react app using Vite in an NX monorepo but I'm running into issues with the plugin. Is there a list of known compatible versions of the plugin + swc core version that I could try and pin to? |
When you use the generator, it outputs this at the top of your file:
That makes it sound more necessary than experimental. |
@CaptainN To be fair, there should also be a (stable) Babel Plugin that achieves the same results, see https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size. This is about the SWC plugin specifically. |
@victorandree That's true, but it's pretty challenging to get that to work with nextjs, which uses SWC by default. (It has a way to change back to babel, but it breaks a bunch of stuff - not easy to pull off.) |
How about if we just don't generate the giant file to start with - it's relatively simple to manually edit it so that you don't get that: #9988 |
For anyone still following this thread:
Please note that I just make the bare minimum changes to make the plugin "work" for me. I don't know how newer versions work with the issues mentioned at the top of the issue, or with non-Next.js runtimes, or how to resolve the "version selection" problem. I don't know if |
@YassinEldeeb if I understand correctly, there's no actionable way forward here? Should the |
Fix reproductions and close issues
SIGSEGV
onnext@13.2.4
with@graphql-codegen/client-preset-swc-plugin@0.1.2
#9145@graphql-codegen/client-preset-swc-plugin
makes Jest throw SyntaxError when trying to run unit tests #9337