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

feat: apply pathMapping when loading sourcemaps #1241

Merged
merged 1 commit into from
Apr 21, 2022
Merged

feat: apply pathMapping when loading sourcemaps #1241

merged 1 commit into from
Apr 21, 2022

Conversation

timvahlbrock
Copy link
Contributor

Fixes #1240

@ghost
Copy link

ghost commented Apr 20, 2022

CLA assistant check
All CLA requirements met.

@timvahlbrock
Copy link
Contributor Author

Introducing this might break launch configurations, where the source maps are available in the non-mapped path, but not in the mapped path, but I think that this should be a pretty rare case.

compiledPath: absolutePath || url,
})
) {
absoluteSourceMapPath = await this.sourcePathResolver.urlToAbsolutePath({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source map might not always exist at an absolute path on disk. For example, when using the webpack-dev-server. That would cause this to be undefined, or an invalid path.

Did the initial code pointer to making the change within the SourceMapFactory not work out? If we make the change in there, then we could also easily add fallback logic to avoid breaking existing configurations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used this way to keep this as much as possible like the pathMapping of the original file source. But I can give it another shot with the code points you provided tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed another commit. SourceMapFactory now tries to load from the path mapped path first, but if that's unsuccessful, loading from the original path is attempted. Also logs a trace message if this happens.

Copy link
Member

@connor4312 connor4312 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. Thanks for the tests!

@connor4312 connor4312 merged commit 0cca6a4 into microsoft:main Apr 21, 2022
@connor4312 connor4312 added this to the April 2022 milestone Apr 21, 2022
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

Successfully merging this pull request may close these issues.

Apply pathMapping when loading sourcemaps
2 participants