Skip to content

fix(rollup-plugin-import-css): register CSS files with rollup watcher#7822

Merged
joshblack merged 1 commit into
mainfrom
joshfarrant/css-watch-fix
May 8, 2026
Merged

fix(rollup-plugin-import-css): register CSS files with rollup watcher#7822
joshblack merged 1 commit into
mainfrom
joshfarrant/css-watch-fix

Conversation

@joshfarrant
Copy link
Copy Markdown
Contributor

@joshfarrant joshfarrant commented May 8, 2026

Overview

Primer's internal rollup-plugin-import-css plugin reads CSS files via fs.readFile in its transform hook but never calls this.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

  • None — rollup-plugin-import-css is a private workspace package, not published to npm. No consumer-facing change.

Changeset skipped

The affected package is private and internal ("private": true, version 0.0.0). Nothing published, no version bump needed.

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>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 8, 2026

⚠️ No Changeset found

Latest commit: 8c0e506

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .css file path via this.addWatchFile(sourceId) in the plugin transform hook for .css.js virtual 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

@joshblack joshblack added the integration-tests: skipped manually Changes in this PR do not require an integration test label May 8, 2026
@joshblack joshblack enabled auto-merge May 8, 2026 19:52
@joshblack joshblack added this pull request to the merge queue May 8, 2026
Merged via the queue into main with commit 0183b14 May 8, 2026
75 of 76 checks passed
@joshblack joshblack deleted the joshfarrant/css-watch-fix branch May 8, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: skipped manually Changes in this PR do not require an integration test skip changeset This change does not need a changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants