Skip to content

Conversation

GeorgeTaveras1231
Copy link

What kind of change does this PR introduce?

bugfix

Did you add tests for your changes?

Not yet, I'm interested to see the level of buy-in to these changes before spending time updating/writing new tests

If relevant, did you update the README?

Same as above.

Summary

Module IDs are used to determine whether a css module has been loaded or not. However, webpack's module.id is only unique per webpack build. In our use case, we are trying to distribute css-modules as npm packages which are bundled separately. This causes collisions for consumers when bundling more than one dependency.

Example:

project-a's export looks like:

[[1, '/* css for project-a omitted */', null]]

project-b's export looks like:

[[1, '/* css for project-b omitted */', null]]

When project-c tries to import project-a and project-b, it determines that project-b is already loaded because it has the same id as project-a. See here

Does this PR introduce a breaking change?

I don't think so but I don't know all of the consumption contracts.

Other information

We are using the query string importLoaders=false to bypass the css-loader on imports. This is important to us because we are distributing modules as npm packages and we think that post-bundle js files is the most scalable distribution format.

This is a WIP

Todo:

  • Confirm whether this type of change is a good change or not.
  • Update tests

@jsf-clabot
Copy link

jsf-clabot commented Dec 16, 2016

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@michael-ciniawsky
Copy link
Member

@webpack-contrib/org-maintainers Anyone thoughts on this, personally 👎

@michael-ciniawsky michael-ciniawsky self-assigned this Mar 6, 2017
@bebraw
Copy link
Contributor

bebraw commented Mar 6, 2017

👎 It would be better to handle this some other way. The suggested solution feels too low level. Ideally you could manipulate module ids elsewhere to match your requirements.

@joshwiens
Copy link
Member

Agreed. Global & Unique has never turned out well in my 38 years of life. Honestly, even if you could get to to work properly it would be difficult to maintain and has little benefit to the consumers of this loader.

Thanks @GeorgeTaveras1231 but we are going to have to decline.

@joshwiens joshwiens closed this Mar 6, 2017
@GeorgeTaveras1231
Copy link
Author

Thanks for looking at this @d3viant0ne @bebraw @michael-ciniawsky.

I agree that my solution is rather hacky and there is probably a more elegant solution to @bebraw 's point.

I am surprised that my use case hasn't surfaced elsewhere though, do you guys know of anyone or any project where they are distributing css modules (using css-loader) as npm modules?

@bebraw
Copy link
Contributor

bebraw commented Mar 8, 2017

@GeorgeTaveras1231 react-toolbox is distributed using CSS Modules. Maybe examining that project could give some idea on how to handle the problem.

@GeorgeTaveras1231
Copy link
Author

Thanks, @bebraw! I will look into how they do.

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.

5 participants