Skip to content

refactor: share Next.js rendering for fragments and websites - #717

Merged
abernier merged 2 commits into
mainfrom
codex/next-fragment-rendering
Oct 13, 2026
Merged

abernier merged 2 commits into
mainfrom
codex/next-fragment-rendering

Conversation

@abernier

@abernier abernier commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

HTML fragments currently render through a separate React renderer bundled into the CLI, with esbuild handling consumer configuration, CSS, and images. Build fragments and websites through the same Next.js static-export pipeline, then extract document HTML for fragment output.

Preserve stdin/file/folder inputs, HTML-only stdout, titles, static Mermaid and Sandpack representations, referenced assets, and consumer configuration with scope values and server/client components. Next logs go to stderr, and each build uses a temporary application directory removed on completion. Relative references remain anchored to the original fragment source. esbuild is now a development dependency used only to package the CLI.

Rendering even one fragment now incurs a full Next build. Includes documentation and a patch changeset. Folder fragments reuse the compiled corpus within each export worker; website search retains the complete document index.

This branch is ported directly onto current main, preserving current configuration loading, version options, Markdown exports, and favicon handling. It has no dependency on feat/cli-dev.

Validation

  • pnpm run LGTM on ca7f14b9: typecheck, lint/format, registry validation, 664 passing unit/integration tests (4 skipped), and all 118 Playwright tests passed.
  • Real Next folder export exercises nested documents, external Sandpack folders, client and asynchronous server components, configuration scope, CSS imports, imported SVGs, asset copying, and clean HTML output.
  • Existing fragment/compiler tests preserved after removing the production standalone renderer.
  • Existing lint warning in VersionSwitcher.tsx remains; no lint errors.

Pre-merge review

Fixed responsive imported images (img[srcset] and source[srcset]) so every candidate remains usable after temporary Next assets are removed. Preserve descriptors and external/data URLs. Reuse folder compilation per export worker, avoiding quadratic metadata/MDX collection across pages while preserving rich Entries and CodeSandbox data. Both fixes include regressions demonstrated failing before the changes.

@abernier
abernier added this pull request to stack #719 October 13, 2026 16:09
@abernier
abernier marked this pull request as ready for review October 13, 2026 16:17
@abernier
abernier merged commit d34c023 into main Oct 13, 2026
7 of 8 checks passed
@pmndrs-release pmndrs-release Bot mentioned this pull request Oct 13, 2026

This branch was successfully deployed

1 active deployment
Preview — ca7f14b9 Deployed Oct 13, 2026 by abernier via main-job #1253
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