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

Next 15 compatibility and temporary option to force page router #112

Open
wants to merge 9 commits into
base: canary
Choose a base branch
from

Conversation

serg-and
Copy link

Bump swc_core to 0.106.* to be in line with next@15.0.1.

next changed the filename metadate making this plugin unable to detect app or page router vercel/next.js#72019.

Added a temporary option to force page router, this will make the plugin incompatible with projects using both routers.

@serg-and serg-and changed the title Next 15 compatibility and temporary option to force Next 15 compatibility and temporary option to force page router Oct 29, 2024
@Finkes
Copy link

Finkes commented Nov 14, 2024

Any updates on this?

@orionmiz
Copy link
Collaborator

It seems like a breaking change from upstream.

If that change is intended, we may need to drop router detection feature and should provide an option for the users to select the router type in own hands.

@awkaiser-tr
Copy link

@orionmiz @serg-and a plugin option to manually set the router type would indeed be the most expedient solution

@vinnymac
Copy link

vinnymac commented Mar 7, 2025

I use both routers in production in several apps, and just want to add that I'd be perfectly happy with manually choosing which router I want this plugin to apply to 👍🏼

@serg-and
Copy link
Author

I forked and published this plugin with compatibility for Next.js@15, since this plugins to no longer be maintained.

https://github.com/serg-and/superjson-next
https://www.npmjs.com/package/superjson-next

@Finkes
Copy link

Finkes commented Mar 28, 2025

We were digging into this topic a bit deeper and noticed that for react server components (i.e. app router only) there is a much simpler solution without the need for a SWC plugin.

We've published our results as a new open source project called rsc-superjson.

The library provides a simple react hoc that achieves the same result as this SWC plugin but in a more explicit way—without requiring an SWC plugin.

As a bonus, switching from the SWC plugin to rsc-superjson reduced our build times by approximately 3.5%.

Additionally rsc-superjson also brings support for the return values of server actions

@serg-and
Copy link
Author

Ah, we're still on the pages router so won't be useful for us. But seems like a nice solution.

@awkaiser-tr
Copy link

I forked and published this plugin with compatibility for Next.js@15, since this plugins to no longer be maintained.

https://github.com/serg-and/superjson-next https://www.npmjs.com/package/superjson-next

@orionmiz @siddhsuresh it would be better for the Next / Blitz community if this wasn't necessary, but I understand why it happened RE: how much time has passed 😓

@orionmiz
Copy link
Collaborator

orionmiz commented Apr 4, 2025

Enough time for an upstream fix has passed, but the issue still exists.
I'll create an plugin option to manually select one router type and create a compatibility table that specifies which plugin versions are available based on the version of Next.js. (This option can be removed by a future upstream bug fix.)

And creating a bundler plugin(webpack, turbopack) also can be considered for the future due to the lack of context provided to compiler plugins. (related issue #90)

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.

5 participants