Skip to content

Bundle docs in the package and clean up private files - #1382

Merged
rezrah merged 4 commits into
mainfrom
rezrah/bundle-docs
Jun 29, 2026
Merged

Bundle docs in the package and clean up private files#1382
rezrah merged 4 commits into
mainfrom
rezrah/bundle-docs

Conversation

@rezrah

@rezrah rezrah commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Towards https://github.com/github/brand-experience/issues/248

Adds version-pinned, markdown-based documentation to the @primer/react-brand package, so that agents can retrieve documentation specific to their installed version of the library.

They will currently fetch documentation from primer.style/brand, but this is problematic because our production docs show unreleased features, and the installed version might be several minor versions behind.

Also cleans up the package files, particularly esm which was leaking some recipes and other things it shouldn't have.

🔗 Preview on unpkg

List of notable changes:

  • Added a script to parse, transpile and copy all .mdx files in Next docs to the packages/react/docs folder, which is allow-listed through the NPM package. The script it kinda heavy only because may of our markdown files contain React components. We need to transpile those to make them readable. This isn't a simple copy/paste of our markdown files.
  • Added some lightweight CI checks to make sure this continues to work correctly behind the scenes
  • Backfilled a README, which was previously missing
  • Fixed some package leakiness, now uses ALLOWLIST approach vs previous DENYLIST one
  • Cleaned up some d.ts outputs in the UMD bundle, which were happening because tsc was emitting via Webpack loader instead of through tsc directly. Now consistent with ESM by doing it as a separate stage.

Steps to test:

  1. Check the output of docs here, and report if you see anything that looks off in the generated markdown files.

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:

Screenshot 2026-06-24 at 15 23 39

Copilot AI review requested due to automatic review settings June 24, 2026 12:04
@rezrah
rezrah requested a review from a team as a code owner June 24, 2026 12:04
@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30ba823

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

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

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

@github-actions

Copy link
Copy Markdown
Contributor

🟢 No design token changes found

"postcss": "8.5.10",
"postcss-loader": "8.2.1",
"postcss-preset-env": "11.2.0",
"remark-frontmatter": "^5.0.0",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

FYI these deps are already installed in the monorepo and not new. Prevents hoisting errors.

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.

Pull request overview

This pull request adds version-pinned, package-bundled Markdown documentation for @primer/react-brand (generated from the Next docs MDX) and tightens package outputs to prevent shipping internal-only files, particularly around declaration outputs and esm/lib contents.

Changes:

  • Bundle Next docs MDX into packages/react/docs/ plus a root llms.txt index, and verify the bundled output (presence + size) in CI.
  • Switch UMD type generation to a dedicated allowlist tsconfig.umd.json pass, and prevent webpack/ts-loader from emitting whole-tree declarations.
  • Add/adjust package allowlist (files) and repo ignores so generated docs are packaged but not committed/linted/formatted.
Show a summary per file
File Description
packages/react/webpack.config.js Disables declaration emit during webpack bundling to avoid unscoped .d.ts output.
packages/react/tsconfig.umd.json New allowlist tsconfig to emit only public-graph declarations into lib/.
packages/react/tsconfig.esm.json Restricts ESM declaration emission scope to entry + ambient .d.ts.
packages/react/scripts/bundle-docs.mjs New script to transpile MDX → Markdown and generate docs/ + llms.txt.
packages/react/scripts/verify-docs-bundle.mjs New verification script to ensure docs are included in the packed tarball and within size limits.
packages/react/README.md Adds package README pointing agents/users to bundled version-matched docs.
packages/react/package.json Packages docs/ + llms.txt, adds bundling scripts/hooks, and adds MDX processing dependencies.
packages/react/eslint.config.mjs Ignores generated docs/** within the package workspace.
packages/react/.prettierignore Ignores generated docs/ and llms.txt.
packages/react/.gitignore Ignores generated docs/ and llms.txt.
package-lock.json Locks new unified/remark/mdast dependencies for docs bundling.
apps/next-docs/content/layout/Stack/react.mdx Corrects source/storybook metadata to Stack (was Box).
apps/next-docs/content/forms/TextArea/index.mdx Fixes storybook path and updates import example to @primer/react-brand.
apps/next-docs/content/components/Tooltip/index.mdx Updates content but currently includes unresolved merge conflict markers.
apps/next-docs/content/components/SubdomainNavBar/index.mdx Fixes default URL typo and table formatting.
apps/next-docs/content/components/Section/react.mdx Fixes doc typos and corrects the as prop type union.
.github/workflows/ci.yml Adds CI step to verify docs bundle output.
.changeset/exclude-internal-type-declarations.md Changeset documenting filtered outputs for shipped bundles/types.
.changeset/bundle-version-pinned-docs.md Changeset documenting bundled docs + llms.txt.

Copilot's findings

Comments suppressed due to low confidence (1)

apps/next-docs/content/components/Tooltip/index.mdx:71

  • This file still contains unresolved git merge conflict markers (<<<<<<<, =======, >>>>>>>). MDX parsing/bundling will fail and the conflict text could ship into the bundled docs.
- [Popover](/components/Popover): For displaying more complex interactive content that appears when triggered
- [Button](/components/Button): Often used in conjunction with tooltips

  • Files reviewed: 18/19 changed files
  • Comments generated: 1

/**
* Bundles version-pinned, agent-readable Markdown docs into @primer/react-brand
* Also outputs an llms.txt, which serves as a table of contents for LLMs
* For complete accuracy, we transpile all the MDX to flat Markdown bcause we have a lot
@github-actions

Copy link
Copy Markdown
Contributor

🟢 Bundle size report

CheckMainBranchChange
UMD — full bundle (JS)99.46 kB99.46 kB🟢 No change
UMD — full bundle (CSS)65.46 kB65.46 kB🟢 No change
ESM — full bundle (JS + CSS)1.50 MB1.50 MB🟢 No change
ESM — tree-shaken simple (Button)68.33 kB68.33 kB🟢 No change
ESM — tree-shaken complex (ActionMenu)77.11 kB77.11 kB🟢 No change

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🟢 Unit test coverage changes found

Unit test coverage has been updated through this PR.

Changes: 0 new tests, 0 removed tests, 0 improved, 1 decreased

Component/Hook Statements Functions Branches Change
IDE 91.6% 91.2% 97.4% 83.4% 82.8% -0.7%

@github-actions

Copy link
Copy Markdown
Contributor

🟢 No visual differences found

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

@rezrah
rezrah requested a review from danielguillan June 24, 2026 14:24

@danielguillan danielguillan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@rezrah
rezrah merged commit 04e5a9d into main Jun 29, 2026
26 checks passed
@rezrah
rezrah deleted the rezrah/bundle-docs branch June 29, 2026 09:59
@primer primer Bot mentioned this pull request Jun 29, 2026
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