Skip to content

fix(ui): rebuild dist automatically on CSS Modules changes in dev - #186

Open
gohabereg wants to merge 1 commit into
mainfrom
fix/ui-dev-watch
Open

fix(ui): rebuild dist automatically on CSS Modules changes in dev#186
gohabereg wants to merge 1 commit into
mainfrom
fix/ui-dev-watch

Conversation

@gohabereg

Copy link
Copy Markdown
Member

Summary

  • playground's dev command builds the whole workspace and watches for changes, but the ui package never rebuilt automatically after the initial build — only a manual yarn build picked up changes.
  • Root cause: ui's dev script (vite build --watch) relies on Rollup's dependency graph to decide what to rebuild. Our CSS Modules (.pcss) pipeline never registers that graph edge, so editing a .pcss file alone never triggered a rebuild. Editing a .ts file did trigger one, and it happened to pick up whatever CSS was on disk at that moment — which made it look like ui just doesn't watch, since most day-to-day work on this package is CSS.
  • Fix: switch ui's dev script to chokidar-cli, which watches every file under src (any type) and reruns a full yarn build per change, sidestepping Rollup's incomplete CSS dependency tracking. Left a comment in vite.config.ts explaining why vite build --watch isn't used directly, since it's a non-obvious workaround for a caching bug in vite-plugin-css-injected-by-js (confirmed by reproducing the same one-rebuild-behind staleness across three different CSS pipelines: postcss-modules, vite-css-modules, and native Lightning CSS).

Test plan

  • yarn build in packages/ui succeeds
  • Ran playground's yarn dev end-to-end; edited a .pcss-only change and confirmed dist/ui.js rebuilds automatically and renders correctly in the browser on refresh, with no manual yarn build needed
  • Verified no console errors in the running playground app

🤖 Generated with Claude Code

vite build --watch relies on Rollup's dependency graph to know what to
rebuild, but our CSS Modules (.pcss) pipeline never registers that
graph edge, so editing a .pcss file alone never triggered a rebuild.
Only editing a .ts file did, which then happened to pick up whatever
CSS was on disk at the time - making it look like the ui package
"doesn't rebuild automatically" in the playground's dev command.

Switch ui's dev script to chokidar-cli, which watches every file under
src and reruns a full `yarn build` on any change, sidestepping the
broken dependency tracking entirely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.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.

2 participants