Fix webpack processing of global stylesheets - #1466
Conversation
🦋 Changeset detectedLatest commit: 08206ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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 |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The Webpack change is narrowly scoped to the exact module being tree-shaken and aligns with the stated bundling regression without introducing broader behavioral changes.
Review tier: Lite
Findings: None
What changed in this PR
Fixes a production bundling regression where the package’s “global stylesheet aggregator” (src/css/stylesheets.ts) could be tree-shaken out by Webpack (notably after the Webpack v5.108.0+ behavior change), causing global CSS/design-token imports to be dropped from the compiled UMD CSS output.
Changes:
- Marks
src/css/stylesheets.tsassideEffects: truein the React package’s Webpack config so it’s retained during production optimization. - Adds a changeset for a patch release of
@primer/react-brand. - Updates lockfile versions (0.74.0 → 0.75.0) and includes a no-op trailing newline change in an auto-generated CSS module typings file.
| File | Description |
|---|---|
| packages/react/webpack.config.js | Adds a targeted rule to treat src/css/stylesheets.ts as side-effectful so Webpack won’t drop global stylesheet imports in production bundles. |
| packages/react/src/SubdomainNavBar/SubdomainNavBar.module.css.d.ts | Trailing newline change in generated typings output. |
| package-lock.json | Updates workspace/package versions to 0.75.0 in the lockfile. |
| .changeset/bright-cats-style.md | Adds a patch changeset describing the fix to missing global styles/tokens in the compiled bundle. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🟢 No design token changes found |
🟢 Bundle size report
|
🟢 No unit test coverage changes foundAll components and hooks with tests maintain the same coverage as the main branch. |
🟢 No visual differences foundOur visual comparison tests did not find any differences in the UI. |
Summary
Fixes a package + production docs bug where global stylesheets are being dropped in production bundles.
From Webpack
v5.108.0the bundler began more aggressively tree-shaking out "unused modules". The stylsheet.ts file is used however, so we need to make sure it's included in the list of files Webpack processes. This was a latent bug in our build.This happened now because we recently updated our webpack version from
5.105.4to5.110.3.🔗 Preview deployment confirms the fix worked
List of notable changes:
What should reviewers focus on?
Steps to test:
Supporting resources (related issues, external links, etc):
Contributor checklist:
update snapshotslabel to the PR)Reviewer checklist:
Screenshots: