Skip to content

Allow the swc plugin to work with recent next.js versions #10352

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

valkum
Copy link
Contributor

@valkum valkum commented May 14, 2025

Description

This PR:

  • updates swc_core to v22 which is the most recent supported version by next.js (see https://plugins.swc.rs/). It is also the most recent version supported by rspack and @swc/core.
  • Bumps the version of the npm package to 22. The breaking changes with swc_core seem to be infrequent now so it makes sense to start tracking swc_core in some way.
  • Preserved top level directives by using swc_core provided functionality (@graphql-codegen/client-preset-swc-plugin adds imports before "use client" #9445)
  • Updates the implementation to be a fold pass. The SWC maintained Relay plugin also uses a Fold pass. Changes applied to the Relay plugin will mostly map 1 to 1 to this plugin and thus this change reduces maintenance overhead.
  • Updates the used Rust version in CI to 1.87. This just builds a binary so we don't need to maintain any minimal supported Rust versions.

Related #9445
Related #9450

Parts of this work were done by @tbakerx

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

How Has This Been Tested?

This added a codegen test for the top-level directives.

Test Environment:

  • OS: MacOS
  • @graphql-codegen/...:
  • NodeJS: 22

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Copy link

changeset-bot bot commented May 14, 2025

⚠️ No Changeset found

Latest commit: 9940e01

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@valkum valkum force-pushed the update-swc-plugin branch from 6ad3c31 to 50b026f Compare May 16, 2025 12:00
@valkum valkum force-pushed the update-swc-plugin branch from 9ae71f1 to 9940e01 Compare May 16, 2025 12:59
@valkum
Copy link
Contributor Author

valkum commented May 16, 2025

I am not sure why the Testing / Examples - SWC steps fails. It works locally (even with the same node version as in CI).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant