Skip to content

feat(flame): add experimental.pages to bring your own landing page - #461

Merged
gitfromwildan merged 1 commit into
mainfrom
feat/flame-experimental-pages
Nov 5, 2026
Merged

gitfromwildan merged 1 commit into
mainfrom
feat/flame-experimental-pages

Conversation

@gitfromwildan

@gitfromwildan gitfromwildan commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Why

Projects that already have a site, for example a React + Tailwind + daisyUI app at the repository root, want flame to build only their docs. Today flame also writes the landing page at /, a root 404.html and its bundles in the dist-root assets/. Those collide with the app's own index.html, 404.html and Vite's /assets/, so the two cannot share an origin cleanly.

experimental.pages is an opt-in flag that keeps everything flame builds under meta.basePath. One route rule for the docs prefix is then enough to serve the docs next to any app, by merging the outputs or through a host rewrite. With the flag off, nothing changes for existing projects.

Changes

Build output with experimental.pages: true

  • No landing page and no landing bundle. home in docu.json is ignored with a warning.
  • The 404 page stays flame's and moves to <basePath>/404.html, so it never replaces the app's root 404. An authored docs/404.mdx takes its place and is rendered with root-absolute assets, like the generated one, so it works at any request depth.
  • Hashed bundles, manifest.json and search-index.json move from assets/ to <basePath>/_flame/. Pages link them relatively, the 404 page root-absolutely, and the search modal fetches the index from the new path.
  • Stale output from a build with the other setting is removed, and the flag is part of the build cache key.
.docu/dist/
└── docs/            # meta.basePath, the only directory flame writes
    ├── _flame/      # bundles, manifest.json, search-index.json
    ├── assets/      # copied from docs/assets
    ├── 404.html
    └── index.html

Commands

  • flame dev and flame preview redirect / to the docs prefix. At a root deployment the docs index owns /.
  • flame deploy --docker: the nginx config redirects / to <basePath>/ with a relative Location, sends 404s to <basePath>/404.html and caches <basePath>/_flame/ as immutable.
  • flame deploy for GitHub Pages: the generated workflow builds with FLAME_STANDALONE=1, which adds a root index.html that redirects to the docs and a root copy of the 404, generated or authored. A plain flame build never writes either. The env var is a no-op without the flag.
  • Both deploy flows warn when a kept nginx.conf or workflow predates the flag. A hand-edited config does not warn while the flag is off.

Validation

  • With the flag on, a root meta.basePath ("" or "/") warns in the build and dev server, because the docs would own /, index.html and 404.html. A docs-only site without a landing page still builds. The schema flags the combination through a draft-07 if/then rule.
  • Independently of the flag, a whitespace-only meta.basePath such as " " is now a build error instead of being read as the deployment root.

Plugin API

  • The onEnd context gains assetsDir, the absolute bundle directory. Plugins should resolve assetManifest entries against it rather than a hard-coded outDir/assets.
  • Type change: AssetManifest.home is now optional, because no landing bundle is built under the flag. TypeScript plugins that read assetManifest.home.css must null-check it under strictNullChecks, even with the flag off. The changeset and plugins.mdx call this out.

Docs

  • base-path.mdx has a new "Bring your own pages" section: the output layout, vercel.json examples for merged output and for a rewrite between two deployments, the Netlify and nginx equivalents, and a table of what each command does.
  • configuration.mdx, deployment.mdx and plugins.mdx are updated to match.

Bun and Node/Deno entries are changed in mirrored pairs: build, hydrate, server, preview and deploy.

Behavior with the flag off

Built the template with main and with this branch, on Bun and Node, for basePath "/", " " (on main) and "docs":

  • Same file layout. All HTML, CSS, JSON and asset files are identical after normalizing CSP nonces and bundle hashes.
  • The only real change is in the client JS: the search index URL is built from a bundlePath constant that is still /assets. Bundle hashes therefore change once, as with any release that touches client code.
  • nginx config and _headers are byte-identical for five basePath variants.

Verification

  • vitest: 727 tests pass across 36 files, including a new experimental.test.ts. It covers runtime parity between the mirrored entries, root bundle cleanup on temp directories (incl. basePath /assets, which a mutation check confirmed is caught), redirect HTML, nginx and _headers generation, and the warnings.
  • tsc, oxlint, prettier and test:release-plan are clean. The pre-push hook passed.
  • Schema checked with Ajv 8 in strict mode, across flag × basePath combinations.
  • End to end on Bun and Node, template project, basePath "/", " " → now an error, and "docs", plain and standalone builds: every relative link resolves, and Bun/Node output is identical after normalization. Remaining CSS hash and search-record order differences also exist on main.
  • flame dev and flame preview probed on both runtimes: / redirect, docs pages, moved search index, 404 page.
  • Authored docs/404.mdx under the flag: served from nginx:alpine and loaded in Chromium at /docs/guide/missing, /docs/a/b/c/missing and /docs/missing. Each returns the authored page with status 404, the stylesheet applied and no failed requests. Before the review fix, nested misses loaded the JS from /docs/docs/_flame/… and rendered unstyled. Standalone builds ship it as the root 404.html.
  • Docker: the generated nginx.conf passes nginx -t in nginx:alpine. A port-mapped container serves the redirect, pages, cache headers and 404 correctly; this caught and fixed an absolute redirect that dropped the mapped port.
  • Browser: scripts/flame-browser-smoke.mjs passes on flame's own docs built with the flag and merged into a stub React app with its own index.html, 404.html and /assets/, with no file collisions. It also passes on the default build.

Notes

  • Minor changeset for @docubook/flame.
  • The whitespace-only basePath error changes existing behavior outside the flag. Affected projects should set "" or "/".

@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docu Ignored Ignored Preview Nov 5, 2026 10:17am UTC

@pullfrog pullfrog Bot 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.

ℹ️ No critical issues. Two rough edges worth a look, both inline.

Reviewed changes

Reviewed in senior mode, because the PR touches the flame build/render pipeline, hydration and deploy. It covers the full experimental.pages feature plus the stricter meta.basePath validation. Verdict: READY WITH MINOR FIXES. Top priorities: (1) the docs/404.mdx override under the flag, (2) the public AssetManifest.home type change.

  • experimental.pages flag: new ExperimentalConfig, schema entry with a draft-07 if/then rule against a root basePath, and pure helpers in experimental.ts re-exported from paths.ts.
  • Output layout under the flag: the landing page and the home-client entry are dropped, the 404 moves to <basePath>/404.html, and bundles, manifest and search index move to <basePath>/_flame/ (ASSETS_DIR is now derived from bundlePath()).
  • Mirrored build entries: build.ts and build.impl.ts gate the landing page, clean stale root and prefixed output, and write the standalone root redirect and 404 under FLAME_STANDALONE=1.
  • Client and HTML shells: bundlePath is threaded through htmlShell, client-routes.ts and both virtual modules. Search.tsx fetches the index from the moved tree. Flag-off output stays byte-identical.
  • Dev and preview servers: / is routed through resolveRootRoute, and preview falls back to the prefixed 404.
  • Deploy: nginx gets a relative root redirect and a prefixed error_page, _headers follows the bundle path, and kept nginx.conf and workflow files get staleness warnings.
  • Plugin API: onEnd gains assetsDir.
  • Validation: a whitespace-only meta.basePath is now a build error.
  • Cache: the flag is folded into basePathStamp(), and experimental.ts is added to the render sources.

I checked these and found no problem: the dev server serves /docs/_flame/* and the moved search index through serveStatic. The location, return and error_page values that now use basePath without the guard stay valid nginx, because the canonical basePath charset is [a-z0-9-._~/]. redirectHtml interpolation is safe for the same reason. Runtime parity between the Bun and Node/Deno pairs holds.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread packages/flame/.docu/node/build.ts Resolved
Comment thread packages/flame/.docu/node/types.ts Resolved
With `experimental.pages: true` in docu.json, flame keeps everything it
builds under `meta.basePath`, so the docs can share an origin with the
project's own app (React, or anything else):

- no landing page and no landing bundle; `home` is ignored with a warning
- the 404 page stays flame's and moves to `<basePath>/404.html`; an
  authored docs/404.mdx takes its place with root-absolute assets
- hashed bundles, manifest.json and search-index.json move from the
  dist-root `assets/` to `<basePath>/_flame/`
- stale output from a build with the other setting is cleaned up, and the
  flag is part of the build cache key

Dev and preview redirect `/` to the docs prefix; at a root deployment the
docs index owns `/`. `flame deploy --docker` writes an nginx config that
redirects `/` and serves the prefixed 404. The GitHub Pages workflow builds
with FLAME_STANDALONE=1, which adds a root redirect and 404 to the artifact.
Both deploy flows warn when a kept nginx.conf or workflow predates the flag.

A root basePath ("" or "/") next to the flag warns in the build and dev
server, and the schema flags it, because the docs would own `/`.
Independently of the flag, a whitespace-only basePath is now a build error
instead of being read as the deployment root.

Plugins get the bundle directory as `assetsDir` in the onEnd context.
`AssetManifest.home` is now optional in the published types, since no
landing bundle is built under the flag.

With the flag off, output layout and page content are unchanged; only the
client bundle hashes change once.
@gitfromwildan
gitfromwildan force-pushed the feat/flame-experimental-pages branch from 75a5be7 to 6e2e347 Compare November 5, 2026 10:17

@pullfrog pullfrog Bot 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.

✅ No new issues found. Both findings from the previous review are fixed, and their threads are resolved.

Reviewed changes

Reviewed in senior mode (flame build pipeline). This review covers the 6e2e347 amend relative to 75a5be7. Verdict: READY.

  • Authored docs/404.mdx under the flag: both build entries now render the 404 slug with absoluteAssets: true and deployPath() when ownPages() is set. The page loads its CSS, JS and favicon from any request depth, the same way the generated 404 does.
  • Standalone root 404: when the docs page owns the 404, FLAME_STANDALONE=1 now copies <basePath>/404.html to the root instead of deleting the root 404.html. This works for cached pages too, because the prefixed file is still on disk.
  • Parity test: experimental.test.ts now checks both changes in the mirrored build.ts / build.impl.ts pair.
  • AssetManifest.home type change: the changeset and a plugins.mdx warning callout now document it, with a home?.css example.

build.ts and build.impl.ts are both listed in RENDER_SOURCE_FILES, so cached 404 docs pages from an earlier build are invalidated and re-rendered with the new asset URLs.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@gitfromwildan
gitfromwildan merged commit dcd326e into main Nov 5, 2026
15 checks passed
@gitfromwildan
gitfromwildan deleted the feat/flame-experimental-pages branch November 5, 2026 10:43
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