-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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 + SWC appear to generate incorrect sourcemaps #39878
Comments
Can you try the latest version? I think this is fixed. |
By "the latest version", do you mean 12.3.1, or the latest canary release? (I'm also seeing this issue with sourcemaps being sent to Sentry being incorrect; literally just updated to 12.3.1 this afternoon so will monitor, but if I need to update to canary that would be good to know.) |
I meant the canary |
Whoops, somehow I missed seeing the earlier notice. Yeah, will try tomorrow! |
This is still definitely broken. Steps to reproduce:
For comparison, this works correctly with Babel as the compiler: I'm attaching a zip file containing the output
Next Babel and SWC sourcemaps.zip That may be useful in seeing what's different. |
I can't build your app because
And I found that the source map you posted has sourcemap for debug build (webpack HMR) |
Here is the |
Thank you! |
Afraid I'm busy at a conference today, but I should be back online on Monday. Please let me know if you still need something more! |
@markerikson Did you post the correct input/map? This is babel version, and I'm not sure if this is correct |
@kdy : yeah, the zip file I attached should have sourcemaps from four different build setup variations, no other code changes between them. I will say that our sourcemaps have been... seemingly flaky and inconsistent in general, and I'm not sure what other issues we might have with our setup. In this case, I just know that switching from Babel to SWC definitely made things worse. But yeah, that screenshot does look kinda broken too :) |
@markerikson Are you using browserslist or |
Yeah, our current target is |
**Related issue:** - Closes #4578. - Closes #6244. - vercel/next.js#39878. Co-authored-by: Justin Ridgewell <[email protected]>
This should be resolved with swc-project/swc#6561, though that'll need to be rolled into the |
Sweet, thanks! I'll definitely try that out as soon as you've got it available. |
Fixed by #43652 |
Thank you! We're still on Next 12 atm, but I'll try upgrading soon and see what happens. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
N/A
How are you deploying your application? (if relevant)
Vercel, but N/A
Describe the Bug
Next generates different sourcemaps when we switch between using Babel to transpile our code, and SWC. The SWC sourcemaps are incorrect - the mapped output differs from the original source code by a few lines, causing incorrect debugging behavior.
We build https://replay.io , a time-travel debugger for JS. The Replay client uses sourcemaps on both the backend and frontend to parse and display info about the recorded application. In turn, we frequently record replays of our own client app to debug how it's working.
I've made two replays of our codebase built with Next 12.2.6-canary.2 , switching only between using Babel and SWC to transpile:
If you open up
debugger/src/actions/event-listeners.ts
in both files, you can see that the Babel file correctly maps all of the lines that were hit:In the SWC-built version, the line hit info is off by 3-4 lines.
If you open up the sourcemap visualizer tool for both versions, the Babel version is correct:
and the SWC version is wrong:
Expected Behavior
Using SWC to compile our application would generate sourcemaps that accurately map the original source.
Link to reproduction
https://github.com/replayio/devtools/tree/bugfix/FE-434-next-sourcemaps
To Reproduce
bugfix/FE-434-next-sourcemaps
branch.yarn
to installyarn build
, and check the build output + sourcemapsbugfix/FE-434-next-sourcemaps
branch, which just disables.babelrc
to use SWC for buildingyarnbuild
, and check the build output + sourcemapsThe text was updated successfully, but these errors were encountered: