Skip to content

chore(css-modules): 🤖 ship pre-compiled CSS alongside components#956

Draft
punkbit wants to merge 20 commits intochore/init-css-modules-setupfrom
chore/colocated-precompiled-css
Draft

chore(css-modules): 🤖 ship pre-compiled CSS alongside components#956
punkbit wants to merge 20 commits intochore/init-css-modules-setupfrom
chore/colocated-precompiled-css

Conversation

@punkbit
Copy link
Copy Markdown
Collaborator

@punkbit punkbit commented Mar 27, 2026

Why?

To improve the developer experience for consumers of this library by eliminating the need for them to configure and run CSS Modules compilation in their build pipeline (e.g. dependency-library node_modules are generally ignored, which'd require consumer apps to whitelist them). By shipping pre-compiled CSS alongside components, it reduces builder/bundler configuration and speeds up compilation times in consuming applications.

How?

  • Custom Vite plugin (plugins/css-colocate/): Replaces vite-plugin-static-copy with a build-time pipeline
  • Shared scoped name pattern (hashing)
  • sideEffects updated to ["**/.css"] (removed **/.module.css since modules are no longer shipped raw)
  • postcss added as a runtime dependency (needed for the pre-processing step), postcss-modules, fs-extra, glob as dev dependencies
  • tsconfig.node.json extended to include plugins/**/*.ts

Tickets?

N/A

Contribution checklist?

  • You've done enough research before writing
  • You have reviewed the PR
  • The commit messages are detailed
  • The build command runs locally
  • Assets or static content are linked and stored in the project
  • For documentation, guides or references, you've tested the commands

Security checklist?

  • All user inputs are validated and sanitized
  • No usage of dangerouslySetInnerHTML
  • Sensitive data has been identified and is being protected properly
  • Build output contains no secrets or API keys

Preview?

N/A

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 27, 2026

🦋 Changeset detected

Latest commit: 33c7dc4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

Claude finished @punkbit's task in 1m 21s —— View job


PR Review: chore(css-modules): ship pre-compiled CSS alongside components

  • Gather context and read changed files
  • Review changes against previous feedback
  • Post final review

All previously raised issues have been resolved in this iteration:

  • magic-string undeclared dependency — import-inject.ts was fully refactored to use plain string operations, eliminating the dependency entirely (no import, no need to add to package.json)
  • vite-plugin-static-copy removed from devDependencies
  • ✅ Virtual module IDs are now deterministic — path-based (virtual:css-module:components/Button/Button.module.css)
  • insertAtTop() helper is now used consistently in injectComponentCss (import-inject.ts:116)
  • ✅ Legacy .scripts/js/preprocess-css-modules script removed
  • ✅ Changeset added with clear consumer-facing migration notes

💡 Minor observation (non-blocking)

buildStart in index.ts:33 calls fs.remove(getTempDir(...)) before preprocessCssModules(), which itself also calls fs.remove(tempDir) internally (css-preprocess.ts:12). The double-remove is harmless but slightly redundant — the fs.remove in buildStart could be dropped since preprocessCssModules already handles cleanup.


✅ No blocking issues. This is well-structured and ready to merge.

@ClickHouse ClickHouse deleted a comment from github-actions bot Mar 27, 2026
@ClickHouse ClickHouse deleted a comment from github-actions bot Mar 27, 2026
@workflow-authentication-public
Copy link
Copy Markdown
Contributor

📚 Storybook Preview Deployed

✅ Preview URL: https://click-mkxo79uqu-clickhouse.vercel.app

Built from commit: 7c8697ca2f5ddd44aa07d7201ed95745298e0552

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