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

work-around for lost paths to source files in source map #1053

Closed
wants to merge 2 commits into from

Conversation

alexhisen
Copy link

@alexhisen alexhisen commented Mar 18, 2020

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

When css-loader calls postcss with an existing source map previously generated by postcss-loader, the resulting source map ends up with just the file name for sources without any paths. If there are then collisions of this file name with other same-named files in other directories, only one of these source maps ends up being retained.

This is particularly noticeable for the react-toolbox project which has about a dozen files all named theme.modules.css in different directories.

See https://github.com/alexhisen/mobx-forms-demo project for example config, etc. Note it's currently set up to use this fork, so it doesn't exhibit the problem any more.

Additional Info

This fix is a dirty hack workaround. There is probably a better way to fix this issue but I don't know enough about webpack, postcss, or this loader to know how to fix this better.

 source files in existing map previously generated by postcss-loader
@jsf-clabot
Copy link

jsf-clabot commented Mar 18, 2020

CLA assistant check
All committers have signed the CLA.

 source files in existing map previously generated by postcss-loader
// files in existing map previously generated by postcss-loader:
if (result.map && map && map.file) {
/* eslint-disable no-underscore-dangle, no-param-reassign */
result.map._sourceRoot = path.dirname(map.file);
Copy link
Member

Choose a reason for hiding this comment

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

Ideally sourceRoot should be empty and each sources relative to webpack context with unique prefix, we will improve source maps for css pipeline in near future, so please open issue with reproducible test repo and we will find solution

@alexander-akait
Copy link
Member

Sorry for delay, let's close this in favor #1169, we improve source map supporting, the next version will fix most of bugs

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.

None yet

3 participants