fix: node_modules relative paths in sourcemaps #5146
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3500
Checklist
Changes proposed in this pull request:
Taking a stab at fixing #3500.
The source maps published with blueprint are incorrect. For example:
The resolved path of that second source is
app/node_modules/node_modules/@blueprintjs/core/src/common/_react-transition.scss
(notice the doublenode_modules
). This leads to webpack errors like:Where does
"../../../../node_modules
come from?When the sass is compiled, the path
"~@blueprintjs/core/src/common/react-transition"
is resolved to"node_modules/@blueprintjs/core/src/common/_react-transition.scss"
, andnode_modules
is 4 directories up, hence the final result of../../../../node_modules/@blueprintjs/core/src/common/_react-transition.scss
. Ideally node-sass-chokidar could resolve/follow the symlink to figure out that there's a more direct route to that file (../../../core/src/common/_react-transition.scss
), but it doesn't seem like that's possible.I tried moving to
dart-sass
sincenode-sass-chokidar
is deprecated, but it looks like the source maps have the same issue (paths going through node_modules).So this PR is a "cheap" solution - after writing the source maps files, convert the "roundabout"
node_modules
paths to more direct paths:Reviewers should focus on:
Is there a place I can add tests?
Screenshot