fix(rollup-plugin-import-css): register CSS files with rollup watcher#7822
Conversation
Add `this.addWatchFile(sourceId)` in the transform hook so that rollup's watch mode detects changes to CSS files. Without this, CSS-only edits are invisible to the watcher — only TSX/TS changes trigger rebuilds. This fixes the primerize workflow where developers editing CSS modules in watch mode see no rebuild until they also touch the importing TSX. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
There was a problem hiding this comment.
Pull request overview
This PR fixes Rollup watch-mode behavior in the internal rollup-plugin-import-css workspace package by ensuring the original CSS source file is registered with Rollup’s file watcher, so CSS-only edits correctly trigger rebuilds.
Changes:
- Register the resolved
.cssfile path viathis.addWatchFile(sourceId)in the plugintransformhook for.css.jsvirtual modules.
Show a summary per file
| File | Description |
|---|---|
| packages/rollup-plugin-import-css/src/index.ts | Adds addWatchFile for the underlying CSS file so watch mode rebuilds on CSS changes. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
Overview
Primer's internal
rollup-plugin-import-cssplugin reads CSS files viafs.readFilein itstransformhook but never callsthis.addWatchFile()to register them with rollup's file watcher. CSS-only edits are invisible in watch mode, while TSX/TS changes trigger rebuilds fine.One-line fix: add
this.addWatchFile(sourceId)before reading the file. Verified end-to-end in a github-ui Codespace — CSS changes now trigger rollup rebuilds and propagate through to github-ui's node_modules.This primarily affects the primerize workflow in github-ui, where developers editing Primer CSS modules in watch mode see no rebuild until they also touch the importing TSX file.
Rollout strategy
rollup-plugin-import-cssis a private workspace package, not published to npm. No consumer-facing change.Changeset skipped
The affected package is private and internal (
"private": true, version0.0.0). Nothing published, no version bump needed.