Commit ecb436b
authored
fix: use compiler context for CSS modules hash to avoid collisions (#20799)
* test: add test case reproducing CSS modules hash collision across directories
Files with the same name in different directories (e.g. f1/style.module.css
and f2/style.module.css) generate identical hashed class names, causing
style collisions.
Ref: #20795
* fix: use compiler context for CSS modules hash to avoid collisions
Use compiler.context instead of module.context as the base path when
computing relativeResourcePath for CSS module local ident hashing.
Previously, files with the same name in different directories would
produce identical relative paths (both "./style.module.css"), leading
to hash collisions.
Fixes #20795
* chore: add changeset for CSS modules hash collision fix1 parent c0e8cf4 commit ecb436b
6 files changed
Lines changed: 36 additions & 1 deletion
File tree
- .changeset
- lib/dependencies
- test/configCases/css/css-modules-hash-collision
- f1
- f2
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments