Fix self references in CSS module JS assets #9080
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.
If a CSS module with
composes
is referenced in multiple different targets, a "Bundle group cannot have more than one entry bundle of the same type" error can occur. This is caused by the self reference dependency that is created in the JS transformer for amodule.exports[...]
reference, which ensures the symbols are preserved. Because a CSS module creates two different assets, the resolution of the dependency in the JS asset back to itself is unclear and may resolve back to the CSS part, messing things up downstream.This changes the self reference dependency to use the asset's
uniqueKey
as the specifier rather than the file name. This means the dependency is resolved directly to the JS asset rather than going through the resolver and maybe going back to the CSS part. If nouniqueKey
has been set, the JS transformer will create one.