Attempt creating globally unique module id's #393
Closed
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.
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:
project-b's export looks like:
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: