Add classnames.js Set export to the CSS build - #4096
Merged
Conversation
Extend script/export-css-selectors to emit static/classnames.js, a default-exported Set of every unique component CSS class name (excluding the utilities.css and layout.css utility classes). Publish the file via package.json files.
🦋 Changeset detectedLatest commit: 9a247f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Introduce a package.json exports field so consumers can use @primer/view-components/classnames. Includes a ./* wildcard fallback to preserve existing deep imports.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the CSS build pipeline to additionally emit static/classnames.js, intended to provide consumers/tooling with a single published list of all unique CSS class names used by Primer ViewComponents (similar to primer/css).
Changes:
- Update
script/export-css-selectorsto collect class tokens across all selectors and write a newstatic/classnames.jsartifact. - Publish
static/classnames.jsviapackage.json#files. - Add a changeset documenting the new export.
Show a summary per file
| File | Description |
|---|---|
static/classnames.js |
New generated artifact exporting the collected class-name set. |
script/export-css-selectors |
Adds cross-file class-name collection and writes static/classnames.js. |
package.json |
Publishes static/classnames.js in the package files list. |
.changeset/classnames-export.md |
Declares a minor release and documents the new export. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
joshblack
approved these changes
Jun 17, 2026
Emit static/classnames.cjs (module.exports = Set) and static/classnames.d.ts alongside the ESM static/classnames.js. Make ./classnames a conditional export (types/import/require) and publish the new files.
Merged
This was referenced Jun 18, 2026
myabc
added a commit
to opf/primer_view_components
that referenced
this pull request
Jul 21, 2026
Syncs the fork with primer/view_components up to upstream commit 6733f3c (parent of Release Tracking primer#4098), the last release in this batch reaching v0.51.6. Notable upstream changes pulled in: - classnames.js Set export (primer#4096): static/classnames.{js,cjs,d.ts} plus the package.json exports subpath and files entries. - perf(css): removed universal `*` subjects and expanded merged `:is()` selector lists (primer#4095). Conflicts resolved keeping the fork's identity, scope and its higher dependency versions; upstream's new exports/files additions and the static class-name output were merged in and regenerated cleanly.
myabc
added a commit
to opf/primer_view_components
that referenced
this pull request
Jul 21, 2026
Syncs the fork with primer/view_components up to upstream commit 6733f3c (parent of Release Tracking primer#4098), reaching v0.51.6. Upstream changes pulled in: - classnames.js Set export (primer#4096): static/classnames.{js,cjs,d.ts}, the export-css-selectors collection logic, and the package.json exports subpath plus files entries. - perf(css): removed universal `*` subjects and expanded merged `:is()` selector lists (primer#4095). Conflict resolution kept the fork's identity, scope and its higher dependency versions; upstream's new exports were merged in. The recursive tsconfig include is re-applied here so nested component TS keeps experimentalDecorators under Vite 8/rolldown. All generated static files were regenerated from a clean tree.
myabc
added a commit
to opf/primer_view_components
that referenced
this pull request
Jul 21, 2026
Syncs the fork with primer/view_components up to upstream commit 6733f3c (parent of Release Tracking primer#4098), reaching v0.51.6. Upstream changes pulled in: - classnames.js Set export (primer#4096): static/classnames.{js,cjs,d.ts}, the export-css-selectors collection logic, and the package.json exports subpath plus files entries. - perf(css): removed universal `*` subjects and expanded merged `:is()` selector lists (primer#4095). Conflict resolution kept the fork's identity, scope and its higher dependency versions; upstream's new exports were merged in. The recursive tsconfig include is re-applied here so nested component TS keeps experimentalDecorators under Vite 8/rolldown. All generated static files were regenerated from a clean tree.
myabc
added a commit
to opf/primer_view_components
that referenced
this pull request
Jul 21, 2026
Syncs the fork with primer/view_components up to upstream commit 6733f3c (parent of Release Tracking primer#4098), reaching v0.51.6. Upstream changes pulled in: - classnames.js Set export (primer#4096): static/classnames.{js,cjs,d.ts}, the export-css-selectors collection logic, and the package.json exports subpath plus files entries. - perf(css): removed universal `*` subjects and expanded merged `:is()` selector lists (primer#4095). Conflict resolution kept the fork's identity, scope and its higher dependency versions; upstream's new exports were merged in. The recursive tsconfig include is re-applied here so nested component TS keeps experimentalDecorators under Vite 8/rolldown. All generated static files were regenerated from a clean tree. The upstream css change makes CI lint the whole text_field.pcss, which surfaced a pre-existing false positive: nesting-selector-no-missing- scoping-root fires on the & selectors inside the fork's FormControl-input-width @define-mixin (the & resolves at the @mixin include site). Silenced with a scoped stylelint-disable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extends the CSS build to emit a new
static/classnames.jsfile that default-exports a JavaScriptSetof every unique component CSS class name in the library, giving consumers and tooling a single published list of classnames. This is for parity withprimer/css.Changes
script/export-css-selectors— In the same build that already producesstatic/classes.json, collect every bare class token (without the leading.) from all rule selectors (traversing every compound/token, not just the first). Results are deduplicated via aSetand sorted alphabetically for stable diffs.@keyframeschildren are skipped as before. The utility/layout classes inapp/lib/primer/css/utilities.cssandapp/lib/primer/css/layout.cssare intentionally excluded via a newclassNameExcludedFilesoption.static/classnames.js(generated) — emits:package.json— addsstatic/classnames.jsto the publishedfileslist..changeset/classnames-export.md—minorchangeset describing the new export.Verification
static/classnames.jsis generated, default-exports a non-emptySet(435 entries), contains known component classes (e.g.Label,Box-body), has no leading dots, and no duplicates.eslint static/classnames.jspasses clean.static/classes.jsonand the per-file*.css.jsonoutputs are unchanged.Notes
The
exportsmap step was skipped because the package does not currently use anexportsfield. Pre-existing unrelatedpackage-lock.jsonchanges were excluded from this branch.