Bundle docs in the package and clean up private files - #1382
Conversation
🦋 Changeset detectedLatest commit: 30ba823 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 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 |
🟢 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", |
There was a problem hiding this comment.
FYI these deps are already installed in the monorepo and not new. Prevents hoisting errors.
There was a problem hiding this comment.
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 rootllms.txtindex, and verify the bundled output (presence + size) in CI. - Switch UMD type generation to a dedicated allowlist
tsconfig.umd.jsonpass, 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 |
🟢 Bundle size report
|
🟢 Unit test coverage changes foundUnit test coverage has been updated through this PR. Changes: 0 new tests, 0 removed tests, 0 improved, 1 decreased
|
🟢 No visual differences foundOur visual comparison tests did not find any differences in the UI. |
Summary
Towards https://github.com/github/brand-experience/issues/248
Adds version-pinned, markdown-based documentation to the
@primer/react-brandpackage, 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
esmwhich was leaking some recipes and other things it shouldn't have.🔗 Preview on unpkg
List of notable changes:
.mdxfiles in Next docs to thepackages/react/docsfolder, 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.tscdirectly. Now consistent with ESM by doing it as a separate stage.Steps to test:
Contributor checklist:
update snapshotslabel to the PR)Reviewer checklist:
Screenshots: