-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
SWC plugin runner no longer provides full file path to metadata #72019
Comments
I did some extra investigation, and next.js/crates/napi/src/transform.rs Lines 99 to 123 in e9c4a75
filename option at first.
|
Do you mean the absolute file path, or path from the project root? |
Path from the project root was what was provided by previous versions of next, so that's what is need for backwards compatibility. |
Giving this a New Years bump! I see @kdy1 self-assigned, identified root cause, then recently unassigned? 😞 If the Next.js team has reasons this won't be patched, that would be great to know so projects such as Footnotes
|
I unassigned me because it's not related to Rust code in next-swc.
2025년 2월 8일 (토) 오전 12:45, August “Kai” Kaiser ***@***.***>님이
작성:
… Giving this a New Years bump! I see @kdy1 <https://github.com/kdy1>
self-assigned, identified root cause, then recently unassigned? 😞
If the Next.js team has reasons this won't be patched, that would be great
to know so projects such as next-superjson-plugin can be prompted to
adapt.
<blitz-js/next-superjson-plugin#112 (comment)>
In the meantime, folks impacted by this have been unable to upgrade their
Next.js projects beyond v14 for *109* days now and it feels bad to be
held back by something so small. The issue can be resolved a few different
ways1
<#m_5700034332485361580_user-content-fn-1-e7b1460250a5b5bb2418f8c1e8f648be>
2
<#m_5700034332485361580_user-content-fn-2-e7b1460250a5b5bb2418f8c1e8f648be>
but, if it makes no difference to Next.js itself, here at the root cause
would be the best patch location.
Footnotes
1.
Suggestion
<blitz-js/next-superjson-plugin#112 (comment)>
to change next-superjson-plugin
<https://www.npmjs.com/package/next-superjson-plugin> behavior ↩
<#m_5700034332485361580_user-content-fnref-1-e7b1460250a5b5bb2418f8c1e8f648be>
2.
Suggestion
<blitz-js/next-superjson-plugin#110 (comment)>
to use next-superjson <https://github.com/remorses/next-superjson>
instead ↩
<#m_5700034332485361580_user-content-fnref-2-e7b1460250a5b5bb2418f8c1e8f648be>
—
Reply to this email directly, view it on GitHub
<#72019 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHELSJ6E7XRCF7YXZKDD3FT2OTIKPAVCNFSM6AAAAABQZNV2WOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNBTGI4DMOBXG4>
.
You are receiving this because you were mentioned.Message ID: <vercel/next
.***@***.***>
|
@kdy1 Hmm. You identified that the problem lies within vendored /crates/napi code last "synched" with 💡 You made some changes six months ago that coincide with this issue's reported bug:
|
@awkaiser-tr It’s failing with something completely unrelated. |
🙇🏻 🍻@kdy1 can you be more specific RE: "something completely unrelated"? My understanding – from this and other related issues on Github – is that @serg-and either I'm going about [the below] wrong1 or your repro implementation would benefit from some adjustments. Can you create a branch on your repo that receives the path you expect, pinning the latest version of Next.js that works? TroubleshootingUsing the reproduction repo from description, Next.js > nextjs-minimal-swc-plugin-issue@0.1.0 dev
> next dev --turbopack
▲ Next.js 15.0.1 (Turbopack)
- Local: http://localhost:3000
- Experiments (use with caution):
· swcPlugins
✓ Starting...
✓ Ready in 1070ms
got filename: _app.tsx
○ Compiling / ...
got filename: _app.tsx
got filename: _document.tsx
got filename: index.tsx
got filename: index.tsx
got filename: helpers.js
✓ Compiled / in 2000ms
GET / 200 in 2145ms > nextjs-minimal-swc-plugin-issue@0.1.0 dev
> next dev --turbo
▲ Next.js 15.0.0-canary.122 (turbo)
- Local: http://localhost:3000
- Experiments (use with caution):
· swcPlugins
✓ Starting...
⚠ Configuration with next.config.ts is currently an experimental feature, use with caution.
✓ Ready in 1069ms
got filename: _app.tsx
○ Compiling / ...
got filename: _app.tsx
got filename: _document.tsx
got filename: index.tsx
got filename: index.tsx
got filename: helpers.js
✓ Compiled / in 1854ms
GET / 200 in 2004ms Testing > nextjs-minimal-swc-plugin-issue@0.1.0 dev
> next dev --turbo
▲ Next.js 15.0.0-canary.121 (turbo)
- Local: http://localhost:3000
- Experiments (use with caution):
· swcPlugins
✓ Starting...
⚠ Configuration with next.config.ts is currently an experimental feature, use with caution.
✓ Ready in 1163ms
got filename: _app.tsx
○ Compiling / ...
got filename: _app.tsx
got filename: _document.tsx
got filename: index.tsx
got filename: index.tsx
got filename: helpers.js
✓ Compiled / in 1758ms
GET / 200 in 1970ms To sanity check, I went back further to known working version > nextjs-minimal-swc-plugin-issue@0.1.0 dev
> next dev --turbo
▲ Next.js 14.2.16 (turbo)
- Local: http://localhost:3000
- Experiments (use with caution):
· swcPlugins
✓ Starting...
✓ Ready in 887ms
got filename: _app.tsx
got filename: hmr-client.ts
got filename: websocket.ts
○ Compiling / ...
got filename: _app.tsx
got filename: _document.tsx
got filename: index.tsx
got filename: index.tsx
got filename: helpers.js
✓ Compiled / in 1353ms
GET / 200 in 1513ms Footnotes
|
Yeap, that's why I said it's not related to swc_core update. |
@awkaiser-tr If you want to bisect, you need to adjust |
There are two problems:
@kdy1 when you consider what this issue is related to, do you have further insights beyond what you wrote in December?
Yeah, I rebuilt the repro repo's plugin with appropriate swc_core version for each of the Next version tests shared above. It'd be clear if I hadn't done that, since an error like this would be thrown: - failed to run Wasm plugin transform. Please ensure the version of `swc_core` used by the plugin is compatible with the host runtime. See https://swc.rs/docs/plugin/selecting-swc-core for compatibility information. If you are an author of the plugin, please update `swc_core` to the compatible version. Given that |
@awkaiser-tr I'm pretty sure i had to throw away the entire @kdy1 why cant this line |
Feel free to send a PR. It would jot fix anything for webpack.
|
Link to the code that reproduces this issue
https://github.com/serg-and/nextjs-minimal-swc-plugin-issue
To Reproduce
Logs will show that the provided filename in the metadata no longer includes the file path, only the filename.
Current vs. Expected behavior
Next's pluggin runner no longer provides the known file path to the metadata for a SWC plugin, only providing the file name.
This is conflict with SWC, saying: swc docs
This breaks several packages such as next-superjson-plugin which rely on the path to determine whether some files are page or app router based.
Provide environment information
Operating System: Platform: linux Arch: arm64 Version: #1 SMP Wed Jul 17 10:51:09 UTC 2024 Available memory (MB): 7185 Available CPU cores: 8 Binaries: Node: 20.11.1 npm: 10.2.4 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 15.0.1 // Latest available version is detected (15.0.1). eslint-config-next: 15.0.1 react: 18.3.1 react-dom: 18.3.1 typescript: 5.0.4 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Pages Router, SWC
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I believe the issue originates from here https://github.com/vercel/next.js/blob/v15.0.1/turbopack/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs#L189
Some(ctx.file_name_str.to_string())
could simply be changed toSome(ctx.file_path_str.to_string())
The text was updated successfully, but these errors were encountered: