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

Plugin source maps contain incorrect source paths #55068

Closed
noahtallen opened this issue Oct 4, 2023 · 3 comments · Fixed by #51401
Closed

Plugin source maps contain incorrect source paths #55068

noahtallen opened this issue Oct 4, 2023 · 3 comments · Fixed by #51401
Labels
[Type] Bug An existing feature does not function as intended [Type] Build Tooling Issues or PRs related to build tooling

Comments

@noahtallen
Copy link
Member

Description

When sourcemaps are generated for the Gutenberg plugin, a final source map includes a "sources" section pointing back to the original source files. This can be useful for tools which might map a stack trace to a source file in GitHub.

An example source path for the plugin looks like this: webpack://wp/./packages/annotations/build-module/format/@wordpress/annotations/src/format/annotation.js.

With the duplicate path in the string, it's not immediately correct. (Though you could manually edit it with a script pretty easily.)

After digging into the webpack config, I believe this happens because our babel transform step happens outside of webpack. Webpack ultimately imports the build-module code already generated by bin/packages/build.js (which runs babel transform), and this code already includes source maps. In those files, the source file points to @wordpress/annotations/src/format/annotation.js, for example.

I think when webpack transforms those sources, it sees the original directory of the file it imports as packages/annotations/build-module/format, but when it tries to look up the file name, it gets @wordpress/annotations/src/format/annotation.js and combines the two strings.

I'm not yet sure the best approach for fixing this, as this @wordpress/ source map is technically correct if you were consuming the source map as a 3rd party package from npm.

Step-by-step reproduction instructions

Inspect the source maps included in the plugin release.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@noahtallen noahtallen added [Type] Bug An existing feature does not function as intended [Type] Build Tooling Issues or PRs related to build tooling labels Oct 4, 2023
@noahtallen
Copy link
Member Author

@jsnajdr I'm curious if you have any quick thoughts on this one!

@t-hamano
Copy link
Contributor

t-hamano commented Oct 5, 2023

@noahtallen It looks like #51401 is trying to solve this problem.

@noahtallen
Copy link
Member Author

Nice, I'll test that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended [Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants