Skip to content

Fix webpack processing of global stylesheets - #1466

Merged
rezrah merged 1 commit into
mainfrom
rezrah/fix-docs-site
Sep 4, 2026
Merged

rezrah merged 1 commit into
mainfrom
rezrah/fix-docs-site

Conversation

@rezrah

@rezrah rezrah commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes a package + production docs bug where global stylesheets are being dropped in production bundles.

From Webpack v5.108.0 the 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.4 to 5.110.3.

🔗 Preview deployment confirms the fix worked

List of notable changes:

  • Adds stylsheets.ts, which includes our design tokens and other important styles to webpack dependency graph

What should reviewers focus on?

  • check the preview deployment works

Steps to test:

  1. check the preview deployment works

Supporting resources (related issues, external links, etc):

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • UI Changes contain new visual snapshots (generated by adding update snapshots label to the PR)
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Screenshots:

Please try to provide before and after screenshots or videos

Before (prod) After (preview)
image image

@rezrah
rezrah requested a review from a team as a code owner September 4, 2026 09:58
Copilot AI lite review requested due to automatic review settings September 4, 2026 09:58
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 08206ae

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

This PR includes changesets to release 9 packages
Name Type
@primer/react-brand Patch
@primer/brand-docs Patch
@primer/brand-css Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-mcp Patch
@primer/brand-config Patch
@primer/brand-storybook Patch

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

@rezrah rezrah changed the title mark global stylesheets as a side effect Fix webpack processing of global stylesheets Sep 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.ts as sideEffects: true in 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.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🟢 No design token changes found

@rezrah
rezrah requested a review from danielguillan September 4, 2026 10:06
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🟢 Bundle size report

CheckMainBranchChange
UMD — full bundle (JS)106.62 kB106.62 kB🟢 No change
UMD — full bundle (CSS)68.20 kB70.84 kB⬆️ +2.64 kB (+3.9%)
ESM — full bundle (JS + CSS)1.85 MB1.85 MB🟢 No change
ESM — tree-shaken simple (Button)74.02 kB74.02 kB🟢 No change
ESM — tree-shaken complex (ActionMenu)83.07 kB83.07 kB🟢 No change

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🟢 No unit test coverage changes found

All components and hooks with tests maintain the same coverage as the main branch.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

@rezrah
rezrah merged commit 9582731 into main Sep 4, 2026
19 of 20 checks passed
@rezrah
rezrah deleted the rezrah/fix-docs-site branch September 4, 2026 11:14
@primer primer Bot mentioned this pull request Sep 4, 2026

This branch was previously deployed

1 inactive deployment
github-pages — 08206ae6 Deployed Sep 4, 2026 by rezrah via Preview / Deploy #6704
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.

3 participants