Repository navigation
fix(build): prefer the most specific CSS export pattern - #171
Open
cixiangtao wants to merge 1 commit into
Open
cixiangtao wants to merge 1 commit into
cixiangtao wants to merge 1 commit into
Conversation
cixiangtao
force-pushed
the
fix/css-export-pattern-specificity
branch
from
November 9, 2026 11:47
fe0e8b6 to
fa67962
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
cn buildcan read the wrong stylesheet when a CSS package exports overlapping patterns with the same prefix. For example:{ "exports": { "./themes/*": "./fallback/*.css", "./themes/*.css": "./specific/*.css" } }Importing
pkg/themes/card.cssshould select./specific/card.css. The current matcher only compares prefix lengths, so it selects the first pattern instead. If that target is missing, the theme is silently skipped. A customrounded-cardutility then survivescn("rounded-card rounded-lg")even though Tailwind generates its CSS and both utilities set the border radius.Break equal-prefix ties by pattern length, selecting the longest suffix. Exact exports retain priority, and a more specific
nullexport continues to exclude the subpath.The regression test fails on the original implementation and passes with the fix. Six end-to-end cases cover both declaration orders, a missing broad target, longer-prefix priority, exact exports, and
nullexclusions. They also check the generated tables' merge behavior. A patch changeset is included.Validation:
cn@0.5.2and@tailwindcss/node@4.3.5: Node and Tailwind select the specific file; unpatched cn selects the broad target or misses the stylesheet. The patched build agrees with Tailwind, including reversed-order and exact-export controls.vp checkandvp run typecheck.FUZZ_ITERS=300000 vp run test: all suites pass, including 56,353 correctness cases and 300,000 fuzz cases.vp run size: default entry remains 26,631 bytes minified / 11,021 bytes gzip, below the 11,100-byte budget.