-
Notifications
You must be signed in to change notification settings - Fork 17
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
Broken source-maps #28
Comments
I've realized that we were using @originjs/vite-plugin-commonjs and not this repository. However, I believe the argument still stands. |
Thanks for your feedback, I'm not sure exactly where the problem you describe is occurring.
https://github.com/vite-plugin/vite-plugin-commonjs/blob/v0.8.0/test/fixtures/src/dynamic.tsx https://github.com/vite-plugin/vite-plugin-commonjs/blob/v0.8.0/test/fixtures/__snapshots__/dynamic.tsx |
That's quite a hack to avoid source-maps.
Yes, this report is invalid then. As I was mentioning: I accidentally reported the bug here while I was using a different plugin with a similar name (vite-plugin/vite-plugin-commonjs vs. originjs/vite-plugins/vite-plugin-commonjs). |
Yeah! I'm not very clear on sourcemap, and I think blindly generating sourcemap would break it, because Vite has already converted the So, I think we should keep the original sourcemap generated by Vite and not generate it again. |
I've limited experience with this, but - I think - I have successfully patched that originjs plugin I mentioned to generate proper source-maps (because they add new lines, instead of your hack). I believe, Vite expects plugins to return the transformed code + a new source-map for the transformed-code (vs. the code it gave you). So if you modify code, then you should generate and return a source-map for your changes only; Vite appears to deal with the rest. Your hack avoids the need for this in most cases (because you abuse that the first line is a comment). |
Thanks for your persistence! I think I may have found the answer in the Vite source code.
I'll try to fix this in the next release(v0.8.1 #30) using magic-string. |
I believe this plugin corrupts source-maps.
Chrome devtools will not point at
debugger
statements; I believe this plugin is causing the misalignment in the source-maps.See vite-plugin/vite-plugin-utils#8 for my speculation as to why that is.
The text was updated successfully, but these errors were encountered: