Skip to content

Conversation

@ErnestM1234
Copy link
Contributor

@ErnestM1234 ErnestM1234 commented Dec 28, 2025

Why

  • version 16.1 of nextjs upgrades to version 49.0.0 of swc_core breaking the swc plugin. We disabled this earlier as a temporary fix. This PR follows up on the temporary fix by adding compatibility.

What

  • compatibility fixes (swc_core 49.0.0 has a few API changes)
  • deprecate plugin for nextjs versions earlier than 16.1

Greptile Summary

This PR upgrades the SWC plugin to support Next.js 16.1+ by migrating to swc_core version 49.0.0 and deprecating support for older Next.js versions.

Key changes:

  • Upgraded swc_core from older version to 49.0.0 with forced exact swc_common version 18.0.0
  • Updated SWC_PLUGIN_SUPPORT constant from 15.2.0 to 16.1.0, effectively deprecating the plugin for Next.js < 16.1
  • Migrated Rust code to use new SWC API: JSXAttrValue::Str instead of JSXAttrValue::Lit(Lit::Str(...))
  • Changed string conversion from to_string() to to_string_lossy().into_owned() for proper handling of non-UTF8 sequences
  • Added compatibility warning message when plugin is disabled for older Next.js versions
  • Updated test code to match new API with .into() conversions for Atom values

Issue found:

  • Missing template variable interpolation in swcPluginCompatibilityChangeWarning - the constant reference ${SWC_PLUGIN_SUPPORT} is not being replaced with the actual version value

Confidence Score: 4/5

  • This PR is mostly safe to merge with one logic error that needs fixing
  • The SWC version upgrade and API compatibility changes are well-implemented across Rust code. All string handling, JSX attribute extraction, and test updates follow the new API correctly. However, there's a critical bug in createErrors.ts where the warning message contains ${SWC_PLUGIN_SUPPORT} that won't be interpolated at runtime, showing the literal string instead of version "16.1.0". This needs to be fixed before merge.
  • packages/next/src/errors/createErrors.ts requires a fix for the template string interpolation bug

Important Files Changed

Filename Overview
packages/next/swc-plugin/Cargo.toml Upgraded swc_core to 49.0.0 with forced exact swc_common version 18.0.0 for Next.js 16.1+ compatibility
packages/next/src/plugin/constants.ts Updated SWC_PLUGIN_SUPPORT from 15.2.0 to 16.1.0, deprecating plugin for older Next.js versions
packages/next/src/errors/createErrors.ts Added swcPluginCompatibilityChangeWarning but missing SWC_PLUGIN_SUPPORT import
packages/next/swc-plugin/src/visitor/jsx_utils.rs Updated string handling to use to_string_lossy().into_owned() and changed JSX attribute API from JSXAttrValue::Lit to JSXAttrValue::Str
packages/next/swc-plugin/src/ast/utilities.rs Updated JSX string attribute extraction to match new SWC API (JSXAttrValue::Str instead of JSXAttrValue::Lit)

Sequence Diagram

sequenceDiagram
    participant User as Developer
    participant NextConfig as withGT Config
    participant Validator as validateCompiler
    participant SWCPlugin as SWC Plugin (Rust)
    participant NextJS as Next.js 16.1+
    
    User->>NextConfig: Initialize gt-next
    NextConfig->>Validator: Check compiler compatibility
    
    alt Next.js < 16.1.0
        Validator->>Validator: swcPluginCompatible = false
        Validator->>User: Warn: SWC plugin disabled for Next.js < 16.1
        Validator->>NextConfig: Set compiler type = 'none'
    else Next.js >= 16.1.0
        Validator->>Validator: swcPluginCompatible = true
        Validator->>NextConfig: Keep compiler type = 'swc'
        NextConfig->>SWCPlugin: Load plugin with swc_core 49.0.0
        SWCPlugin->>NextJS: Transform JSX/code using new API
        Note over SWCPlugin,NextJS: Uses JSXAttrValue::Str<br/>instead of JSXAttrValue::Lit<br/>to_string_lossy() for strings
        NextJS->>User: Build succeeds
    end
Loading

@ErnestM1234 ErnestM1234 marked this pull request as ready for review December 29, 2025 00:13
@ErnestM1234 ErnestM1234 requested a review from a team as a code owner December 29, 2025 00:13
@ErnestM1234 ErnestM1234 requested a review from pie575 December 29, 2025 00:13
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@pie575 pie575 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swag 👍

@ErnestM1234 ErnestM1234 merged commit 6df7670 into main Dec 29, 2025
23 checks passed
@ErnestM1234 ErnestM1234 deleted the e/fix-swc-compat branch December 29, 2025 00:32
@github-actions github-actions bot mentioned this pull request Dec 29, 2025
ErnestM1234 pushed a commit that referenced this pull request Dec 29, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Patch Changes

- [#925](#925)
[`6df7670`](6df7670)
Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: deprecate
swc plugin for nextjs versions earlier than 16.1

## @generaltranslation/[email protected]

### Patch Changes

- Updated dependencies
\[[`6df7670`](6df7670)]:
    -   [email protected]

<!-- greptile_comment -->

<h3>Greptile Summary</h3>


Standard automated release PR generated by Changesets action to publish
version 6.12.4 of `gt-next` and version 10.0.4 of
`@generaltranslation/gt-next-lint`.

**Changes:**
- Deleted changeset file `.changeset/easy-eels-walk.md` (consumed by the
release process)
- Bumped `gt-next` from 6.12.3 to 6.12.4 with changelog entry
referencing PR #925
- Bumped `@generaltranslation/gt-next-lint` from 10.0.3 to 10.0.4 as a
dependent package

**Context from PR #925:**
The underlying fix adds Next.js 16.1+ compatibility by upgrading to
`swc_core` 49.0.0 and deprecating SWC plugin support for Next.js
versions < 16.1.0. The issue identified in PR #925's review (missing
`SWC_PLUGIN_SUPPORT` import causing template literal interpolation
failure) has been resolved - the constant is now properly imported and
used in `packages/next/src/errors/createErrors.ts:185`.

<details open><summary><h3>Confidence Score: 5/5</h3></summary>


- This release PR is safe to merge with no issues found
- This is a standard automated release PR following the Changesets
workflow. All version bumps are correct (patch versions), changelogs are
properly formatted, and the consumed changeset file is correctly
deleted. The underlying fix from PR #925 has been verified to be
complete with no remaining issues.
- No files require special attention
</details>


<details><summary><h3>Important Files Changed</h3></summary>




| Filename | Overview |
|----------|----------|
| .changeset/easy-eels-walk.md | Changeset file deleted (standard
behavior for release PRs) |
| packages/next/CHANGELOG.md | Added version 6.12.4 changelog entry with
reference to PR #925 |
| packages/next/package.json | Version bumped from 6.12.3 to 6.12.4 |
| packages/next-lint/CHANGELOG.md | Added version 10.0.4 changelog entry
with dependency update reference |
| packages/next-lint/package.json | Version bumped from 10.0.3 to 10.0.4
|

</details>


</details>


<details><summary><h3>Sequence Diagram</h3></summary>

```mermaid
sequenceDiagram
    participant Dev as Developer
    participant Actions as GitHub Actions
    participant Changesets as Changesets Action
    participant NPM as NPM Registry
    
    Dev->>Actions: Merge PR #925 to main
    Actions->>Changesets: Trigger release workflow
    Changesets->>Changesets: Read .changeset/easy-eels-walk.md
    Changesets->>Changesets: Calculate version bumps
    Note over Changesets: gt-next: 6.12.3 → 6.12.4<br/>gt-next-lint: 10.0.3 → 10.0.4
    Changesets->>Changesets: Update package.json versions
    Changesets->>Changesets: Update CHANGELOG.md files
    Changesets->>Changesets: Delete consumed changeset
    Changesets->>Dev: Create PR #926 for review
    
    alt When PR #926 is merged
        Dev->>Actions: Merge release PR
        Actions->>Changesets: Publish packages
        Changesets->>NPM: Publish [email protected]
        Changesets->>NPM: Publish @generaltranslation/[email protected]
        NPM->>Dev: Packages available
    end
```
</details>


<!-- greptile_other_comments_section -->

<!-- /greptile_comment -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants