Skip to content

fix: resolve escaped local composition names - #72

Open
Cynnamoroll wants to merge 1 commit into
css-modules:masterfrom
Cynnamoroll:fix/compose-escaped-local
Open

Cynnamoroll wants to merge 1 commit into
css-modules:masterfrom
Cynnamoroll:fix/compose-escaped-local

Conversation

@Cynnamoroll

Copy link
Copy Markdown

Fixes #70.

The default generateExportEntry decodes CSS escapes in export keys, but local composes references were looked up using their escaped spelling. Decode the local lookup name with that same rule when the default export callback is used.

This also handles the ambiguous case where both .tag\:a and .tag\\\:a exist: an escaped reference to the first must not silently compose the second. Keep custom generateExportEntry callbacks' existing exact-key behavior, and leave global/imported references and the missing-class diagnostic unchanged.

Tests add escaped colon/slash composition, the literal-backslash collision, and custom export-key compatibility. All 45 repository tests pass, along with ESLint and Prettier.

I also checked ordinary CSS Modules imports in Vite 8.4.1 production builds, substituting only this plugin in memory. Stock fails the escaped-utility case; the fix emits the intended direct and transitive class tokens. A local Chromium 154 test loads the emitted JS and CSS: the collision renders blue on stock versus red with the fix, and the composed utility card gets the expected color and 42px width. The collision CSS is identical in both builds.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
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.

composes cannot find a local class whose name contains a CSS escape (e.g. sm\:p-2)

1 participant