Skip to content

fix(flame): rebuild on config edits, prune removed pages, match deploy workflow to package manager - #463

Merged
gitfromwildan merged 2 commits into
mainfrom
fix/flame-bundle-csp-deploy
Nov 5, 2026
Merged

gitfromwildan merged 2 commits into
mainfrom
fix/flame-bundle-csp-deploy

Conversation

@gitfromwildan

@gitfromwildan gitfromwildan commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Why

An audit of the client bundle, the build cache, CSP/nonce handling and flame deploy found four bugs, all reproduced on Bun and Node before fixing. Two make incremental builds publish stale output. Two make the generated GitHub Pages workflow wrong for the project. CSP and nonce handling had no bugs.

Changes

Incremental builds

  • Config edits now rebuild. A docu.json edit that does not touch the theme or meta.basePath (a sidebar title, the navbar text, the repo URL) left every page a cache hit and reused the client bundle, which inlines the config. The change only showed up after flame build --force. configStamp() folds the resolved config into the bundle hash and the page-asset key, and BUILD_CACHE_VERSION is now 9.
  • Removed pages are pruned. HTML of pages whose source was deleted or renamed stayed in the output and kept being published with stale navigation. pruneRemovedPages() removes it and the cache entries right after the docs pages are written, before the docs index, the 404 page and plugins' onEnd, and the build lists what it removed. It uses the cache as the list of files flame wrote, so it only deletes <docsOutDir>/<key>.html, and a key that resolves outside the docs output is dropped without touching the filesystem. previousPageKeys() also reads the page keys from the cache file on disk, ignoring its version and stamps, so pruning still works when --force or a flame upgrade discards the cache.

flame deploy

  • Same workflow on both runtimes. Under Bun, the GitHub Pages workflow was a hard-coded Bun one (bun install, bun run build) even for npm, pnpm and yarn projects, so CI ignored their lockfile. The Node path already detected the package manager. generateWorkflowYml() is now exported from deploy.shared.ts and used by both entries. Bun projects with a lockfile now install with --frozen-lockfile, as on the Node path.
  • pnpm workflow no longer fails at setup. pnpm/action-setup requires version unless package.json declares pnpm in packageManager or devEngines.packageManager, and flame's template declares neither. pnpmSetupVersion() pins the major of the pnpm that ran flame deploy, or latest, and leaves the input out when package.json already pins pnpm.

deployment.mdx documents the package-manager detection and the pnpm pin. Patch changeset for @docubook/flame.

Before and after

Template project, rebuilt without --force. Same results on Bun and Node.

Scenario Before After
Rebuild, nothing changed 5 pages cached, bundle reused 5 pages cached, bundle reused
Only docu.json changed 5 cached, bundle reused, old sidebar and repo link 5 re-rendered, new bundle, new sidebar and repo link
One page renamed, one deleted routing.html and deployment.html still published both removed, build lists them

flame deploy, generated workflow:

Project Before, via Bun After, via Bun and Node (identical files)
npm oven-sh/setup-bun, bun install actions/setup-node, npm ci --include=dev
pnpm oven-sh/setup-bun, bun install pnpm/action-setup with version: "10", pnpm install --frozen-lockfile
bun bun install bun install --frozen-lockfile

CSP and nonce audit

No changes needed:

  • Static output (30 pages, both runtimes): every page has its own nonce, every inline script carries the meta CSP nonce, and there are no inline handlers, javascript: URLs or cross-origin scripts.
  • In Chromium, through flame preview (fresh nonce per request), a plain static server (meta CSP only) and flame dev on Bun and Node: no CSP violations, uncaught errors or failed requests. This included opening search (search-index fetch), toggling the theme and rendering Mermaid.

Verification

  • vitest: 742 tests pass, including 18 new ones for configStamp, pruneRemovedPages (including the out-of-tree key and the prune order), previousPageKeys and generateWorkflowYml/pnpmSetupVersion, plus updated parity checks.
  • tsc, oxlint, prettier and test:release-plan are clean, and the pre-push hook passed.
  • The reproductions in the tables above were re-run on the fixed code, on both runtimes. Link checks pass. The only unresolved links in the rename test are sidebar entries in that project's docu.json that point at the deleted pages, which now correctly 404.
  • All six generated workflows (npm, pnpm, bun × Bun, Node) parse as valid YAML.
  • scripts/flame-browser-smoke.mjs passes on flame's own docs.

Review follow-up (7863f69)

Pullfrog found two problems in the pruning, both fixed and verified on Bun and Node against 6eb4e01:

  • Pruning ran after the 404 page was written, so deleting docs/404.mdx removed the fresh 404. This happened under experimental.pages and also at a root deployment with the flag off. Pruning now runs before the docs index and the 404 page are written.
  • Pages deleted in the same build as --force or a cache-stamp mismatch stayed published, because the discarded cache was the only record of them. The raw cache file is now read for that list.

Notes

  • Sidebar entries in docu.json that point at a removed page now 404 instead of reaching stale HTML. The build does not warn about such routes yet; that could be a follow-up.

…y workflow to package manager

Incremental builds:

- A docu.json edit that does not touch the theme or meta.basePath (a
  sidebar title, the navbar text, the repo URL) left every page a cache hit
  and reused the client bundle, which inlines the config, until --force.
  `configStamp()` now folds the resolved config into the bundle hash and the
  page-asset key (BUILD_CACHE_VERSION 9).
- Pages whose source was deleted or renamed stayed published with stale
  navigation. `pruneRemovedPages()` removes their HTML and cache entries
  before plugins' onEnd, using the cache as the list of files flame wrote,
  and never touches anything outside the docs output.

flame deploy:

- Under Bun it wrote a Bun-only GitHub Pages workflow (`bun install`) even
  for npm, pnpm and yarn projects. Both runtimes now use the shared,
  package-manager-aware `generateWorkflowYml()` and write identical files.
- The pnpm workflow now passes `version` to pnpm/action-setup when
  package.json does not declare pnpm, which the action requires. It pins
  the major of the invoking pnpm, or `latest`.

CSP and nonce were audited on static output, flame preview, the dev server
and a plain static server, in Chromium on both runtimes: no violations.
@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 11:34am 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.

Important

The new page pruning can delete the 404 page the same build just generated. Separately, it misses orphans whenever the build cache is discarded (--force or a flame upgrade). The config-stamp and deploy-workflow changes look correct.

Reviewed changes

Senior-mode review (flame build pipeline + deploy) of the single commit: cache-key additions, prune wiring in both build entries, the shared workflow generator, tests and docs.

  • configStamp() in the cache key: the raw docu.json hash is now part of hashMdxSources() and the __assets__ key in build.ts and build.impl.ts, and BUILD_CACHE_VERSION goes to 9. Correct, and limited to the two build entries.
  • pruneRemovedPages(): removes <DOCS_OUT_DIR>/<key>.html for cache keys that no longer have a source, and refuses to touch anything outside the output root. It runs before runOnEnd.
  • Shared generateWorkflowYml(): the Bun deploy entry now writes the same package-manager-aware workflow as Node/Deno. pnpmSetupVersion() pins pnpm/action-setup, and its README confirms that latest and major-only versions are accepted and that version can be left out when packageManager/devEngines.packageManager declares pnpm.

Top priorities: (1) run the prune before the landing/404 writes, (2) keep a record of the previous build's pages when the cache is discarded, (3) nothing else blocking.

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/build.impl.ts Resolved
Comment thread packages/flame/.docu/node/cache-key.ts Resolved
- Prune removed pages right after the docs pages are written, before the
  docs index and the 404 page. Pruning after them deleted the fresh 404
  when docs/404.mdx was removed: under experimental.pages it shares
  `<basePath>/404.html`, and at a root deployment `404.html`.
- Read the page keys of the previous build from the cache file on disk,
  ignoring its version and stamps (`previousPageKeys()`). `--force` and any
  stamp mismatch, such as a flame upgrade, discard the in-memory cache, and
  with it the only record of which pages to prune.

@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

I reviewed in senior mode (flame build pipeline) the follow-up commit 7863f69, which addresses the two pruning findings from the previous review. Verdict: READY.

  • Moved the prune ahead of generated pages: in build.ts and build.impl.ts, pruneRemovedPages() now runs right after the page task loop. That is before the docs index write, the 404.html write and runOnEnd, so deleting docs/404.mdx no longer removes the 404 page the same build just generated. An index-order assertion in cache-key.test.ts locks this ordering for both entries.
  • Added previousPageKeys(): it reads the non-__ keys of the cache file on disk without checking stamps, and returns [] if the file is missing, corrupt or not an object. Both builds read it after readCache(), and pruneRemovedPages() prunes the union of these keys and the in-memory cache, with the out-of-root guard still applied. This means orphans are pruned even when --force is used or a version/runtime/render stamp mismatch discards the cache.

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

@gitfromwildan
gitfromwildan merged commit 55ae4c3 into main Nov 5, 2026
15 checks passed
@gitfromwildan
gitfromwildan deleted the fix/flame-bundle-csp-deploy branch November 5, 2026 11:45
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