Skip to content

feat(docsite): document published packages on prod, workspace on canary + PR previews#3858

Merged
cixzhang merged 5 commits into
mainfrom
navi/feat/docsite-canary-published-vs-workspace
Jul 12, 2026
Merged

feat(docsite): document published packages on prod, workspace on canary + PR previews#3858
cixzhang merged 5 commits into
mainfrom
navi/feat/docsite-canary-published-vs-workspace

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Problem

The docsite is deployed from main on every push, and its build-time data pipeline reads component docs, props, and package versions straight from the workspace. So the published site always documents work in progress — components and props that only exist on main show up in the docs even though npm install doesn't have them yet. A reader copies an install command, and the thing they just read about isn't in the package.

Approach — one codebase, two content lines, keyed off the deploy environment

The docsite code is always current; only the package sources the pipeline reads docs from differ per target:

Target Reads package docs from Deploys Banner
latest the last published npm release production (astryx.atmeta.com) hidden
canary the live workspace (main, WIP) the canary site + every PR preview shown

The target is derived from Vercel's VERCEL_ENV: production → latest; every other environment (preview = the main canary deploy and all PR previews, plus local dev) → canary. No branch-scoped config — an explicit DOCSITE_TARGET / NEXT_PUBLIC_DOCS_TARGET override is available for local testing.

Content resolution

scripts/resolve-content-root.mjs maps the target to the filesystem root the pipeline reads from:

  • canary → the live monorepo workspace.
  • latest → downloads each docsite @astryxdesign/* dependency's published tarball from npm into a cache laid out like the monorepo (the tarballs ship src/, so the .doc.mjs prop tables are present). The pinned version is read live from npm view @astryxdesign/core@latest version, so it always tracks the current release with nothing to hand-maintain.

generate-data.mjs consumes CONTENT_ROOT from the resolver; every generated registry keeps its exact shape, so no page code changes. Only the documented data is pinned — CLI template demos are live-rendered React that resolve @astryxdesign/core from the bundled workspace version, so CLI_ROOT stays on the workspace (pinning it would make a stale release's demo call API the bundled core no longer exposes).

UI

  • Canary banner — rendered via AppShell's dedicated banner slot, shown only on canary builds, linking to the same page on production. Callers gate the slot on CURRENT_TARGET === 'canary' so production renders no banner region at all.
  • Footer link — a low-key persistent link to the sibling site (production → canary, or back).

Env vars (set in Vercel)

  • System env vars exposed (gives NEXT_PUBLIC_VERCEL_ENV to the client bundle) — required for the banner/footer to know which target they're on.
  • NEXT_PUBLIC_DOCS_LATEST_URL = https://astryx.atmeta.com
  • NEXT_PUBLIC_DOCS_CANARY_URL = https://astryx-canary.vercel.app

Verification

  • pnpm generate (canary) → the full main component set (227), reading from the workspace.
  • resolve-content-root.mjs resolves canary → workspace and production/VERCEL_ENVlatest correctly.
  • Typecheck: exit 0, clean.
  • Docsite tests: 217/217 pass.
  • The full latest tarball-materialization path needs npm network access, so it's exercised on the Vercel production build rather than in the sandbox.

Notes

Supersedes #3513, which mounted canary as a nested static export inside one deployment (output:'export' + /canary basePath) and required a raft of page/route rewrites to make the whole app statically exportable. The two-deploy-from-main model needs none of that — both targets are normal server builds — so this PR is a small, self-contained pipeline + UI change.

The docsite deploys from main to two Vercel targets: production documents the
last published npm release; the canary site and every PR preview document the
live workspace (main, WIP). The target is derived from VERCEL_ENV — production
is 'latest', every other environment is 'canary'.

scripts/resolve-content-root.mjs maps the target to the filesystem root the
data pipeline reads package docs from: 'latest' downloads the published package
tarballs from npm (their src/ ships the .doc.mjs the pipeline needs); 'canary'
reads the live workspace. Only documented DATA is pinned — CLI template demos
are live-rendered React against the bundled core, so they always come from the
workspace.

A CanaryBanner (rendered via AppShell's banner slot) warns readers on canary
builds and links to production; a footer link cross-links the two sites.
@cixzhang
cixzhang requested a review from imdreamrunner as a code owner July 12, 2026 03:55
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 12, 2026
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 12, 2026 5:29am

Request Review

@thedjpetersen thedjpetersen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved.

…tent target

The latest target materializes each docsite @astryxdesign/* dependency from its
published npm tarball, but canaryOnly packages (charts, lab) never publish to the
stable latest dist-tag — npm pack failed with ETARGET and broke the production
build. Filter the latest package set to stable-publishable packages only, using
the same private + astryx.canaryOnly predicate release.yml uses for stable
publishing. Those packages still appear on canary, sourced from the workspace.
…ist-tags

Use plain 'Latest' / 'Canary' labels consistently across the banner, footer
link, and version metadata, matching the @latest and @canary npm dist-tags the
packages publish under. The canary banner now names the @canary tag so readers
know exactly how to install the unreleased version.
@cixzhang
cixzhang merged commit e009fdd into main Jul 12, 2026
16 checks passed
@github-actions
github-actions Bot deleted the navi/feat/docsite-canary-published-vs-workspace branch July 12, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants