Skip to content

fix(build): resolve extensionless CSS imports and directory indexes - #173

Open
cixiangtao wants to merge 1 commit into
shadcn-ui:mainfrom
cixiangtao:fix/extensionless-css-imports
Open

cixiangtao wants to merge 1 commit into
shadcn-ui:mainfrom
cixiangtao:fix/extensionless-css-imports

Conversation

@cixiangtao

Copy link
Copy Markdown

cn build rejects relative CSS imports that Tailwind resolves successfully:

/* app.css */
@import "tailwindcss";
@import "./theme";

/* theme.css */
@theme {
  --radius-card: 12px;
}

Tailwind compiles rounded-card, but cn build --css app.css --full tries to read the literal theme path and throws ENOENT. Importing a directory containing index.css throws EISDIR. An unexported package directory such as theme-kit/tokens is silently skipped, leaving its custom theme classes unmerged.

Resolve filesystem imports in order: exact file, .css, then index / index.css. Preserve trailing slashes so an explicit directory import cannot select a sibling .css file. The resolved stylesheet remains in cssFiles for watching, and missing relative imports retain their diagnostic.

Nine regression cases cover sibling and parent imports, directory indexes, trailing slashes, file/index precedence, explicit filenames, and an unexported package subdirectory. They check both dependency tracking and generated tables: cn("rounded-card rounded-lg") returns "rounded-lg". A patch changeset is included.

Validation:

  • The new regression fails against upstream main before the fix.
  • Independently reproduced with published cn@0.5.2 and @tailwindcss/node@4.3.5. Tailwind generates both utilities in all nine fixtures; the patched builder resolves the same theme in every case.
  • vp check and vp run typecheck pass.
  • FUZZ_ITERS=300000 vp run test passes all suites, including 56,353 correctness cases and 300,000 fuzz cases.
  • vp run size passes: default entry remains 26,631 bytes minified / 11,021 bytes gzip, below the 11,100-byte budget.

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.

1 participant