Skip to content

WIP: Make API-only the default build and exclude site pages from the API bundle - #240

Draft
dlabaj wants to merge 1 commit into
mainfrom
api-only-default
Draft

WIP: Make API-only the default build and exclude site pages from the API bundle#240
dlabaj wants to merge 1 commit into
mainfrom
api-only-default

Conversation

@dlabaj

@dlabaj dlabaj commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Builds on main's existing PF_API_ONLY feature and delivers the two follow-ups discussed:

  1. API-only is now the default. build produces the API only; the full documentation site UI is opt-in via build --site. The dev server (start) always serves the full site.
  2. Heavy site pages are excluded from the API-only bundle. Previously api-only kept the .astro docs pages in src/pages and just returned [] from getStaticPaths, so their modules (and @patternfly/react-core, LiveExample, MDX rendering) were still SSR-bundled. They now live in src/site-pages/, outside Astro's file-based routing, and are injected only for full-site builds.

How it works

  • Site UI pages moved src/pages/**src/site-pages/** (same depth, so relative imports are unchanged).
  • New optional-site-pages integration in astro.config.mjs:
    • full site (dev or BUILD_SITE=true) → injects home + docs routes
    • API-only (default) → injects a lightweight api-landing.astro stub at /
  • CLI: --api-only flag replaced by --site; default sets PF_API_ONLY=true, --site sets BUILD_SITE=true.
  • 404.astro stays in src/pages and keeps its PF_API_ONLY messaging.
  • New architecture.md documents the whole design.

Scripts

Script Builds
npm run build API only (default)
npm run build:all API + full site UI (build --site)

Verification

  • All 375 tests + 4 snapshots pass.
  • API-only build: / serves the stub landing, no section HTML, full api/ + apiIndex.json/iconsIndex.json/props.json present. ~44s, ~6.7 GB peak.
  • Full --site build: real home + components/, patterns/, foundations-and-styles/. ~57s, ~7.2 GB peak.
  • No route collisions in either mode.

Breaking change

The --api-only CLI flag is removed in favor of the inverted --site flag (API-only is now the default). Anyone invoking build --api-only should switch to plain build; anyone relying on build producing the full site should switch to build --site / npm run build:all.

🤖 Generated with Claude Code

Builds on main's PF_API_ONLY feature with two changes:

1. Flip the default: `build` now produces the API only; the full
   documentation site UI is opt-in via `build --site` (BUILD_SITE). The
   dev server always serves the full site.

2. Actually exclude the heavy site pages from the API-only build. The
   site UI pages move from src/pages to src/site-pages so they leave
   Astro's file-based routing and are no longer part of the SSR bundle. An
   `optional-site-pages` integration injects them only for full-site
   builds; for API-only builds it injects a lightweight api-landing.astro
   stub at `/` so the route still resolves without heavy modules.

Adds architecture.md documenting the split, the build pipeline, and
measured build cost.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a0ef9cd-a01e-4893-9a96-aff615e68a18


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dlabaj
dlabaj marked this pull request as draft August 26, 2026 23:15
@dlabaj dlabaj changed the title Make API-only the default build and exclude site pages from the API bundle WIP: Make API-only the default build and exclude site pages from the API bundle Aug 26, 2026
@dlabaj
dlabaj requested a review from cdcabrera August 26, 2026 23:16
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying patternfly-doc-core with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0a9b8fe
Status: ✅  Deploy successful!
Preview URL: https://881ff937.patternfly-doc-core.pages.dev
Branch Preview URL: https://api-only-default.patternfly-doc-core.pages.dev

View logs

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.

1 participant