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

Broken source-maps after MagicString #8

Closed
JannikGM opened this issue Jun 23, 2023 · 1 comment
Closed

Broken source-maps after MagicString #8

JannikGM opened this issue Jun 23, 2023 · 1 comment

Comments

@JannikGM
Copy link

JannikGM commented Jun 23, 2023

This particular issue was noticed with https://github.com/vite-plugin/vite-plugin-commonjs but it probably exists in multiple projects.
(Edit: Incorrect, we were using @originjs/vite-plugin-commonjs which is unrelated to this project)


When setting a breakpoint using debugger the Chrome devtools will point to a different line.
I speculate this particular plugin is causing this issue.

I believe the issue is that this class does not handle source-maps:

export class MagicString {

Similar projects do support source-maps:

Other vite plugins appear to use babel for example: https://babeljs.io/docs/options#sourcemaps

Note how a similar plugin (which does not work for us for other reasons) has explicit support for source-maps:

https://github.com/WarrenJones/vite-plugin-require-transform/blob/fb4b9c08b6cf9450ef55c3232b6d61152dfe4c42/src/index.ts#L200

Please integrate source-maps in @vite-plugin plugins by using one of the existing solutions / create fitting source-maps as part of the transform.

@JannikGM
Copy link
Author

JannikGM commented Jun 27, 2023

I believe this issue is still open, given what I explained in vite-plugin/vite-plugin-commonjs#28 (comment)

MagicString should generate a source-map (which, I believe, is the major idea behind MagicString in Rich-Harris/magic-string), and plugins using MagicString should return that source-map to Vite.

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

No branches or pull requests

2 participants