Repository navigation
fix(flame): rebuild pages and bundle when a @docubook package changes - #437
Merged
Merged
Conversation
The build cache keyed pages on their MDX source and the client bundle on the compiled MDX plus the stylesheet stamp. Both are rendered from the built @docubook/core, markdown, ui-react and themes-colors packages, but no key covered them. Upgrading one of them, or rebuilding it in this monorepo, kept every page a cache hit and reused the old client bundle until --force. Editing markdown's dist left the seven callouts on /docs/components/callout and the client bundle on the previous code. - dev-watch: split resolvePackages() out of resolveWorkspacePackages(). It resolves the copies flame loads, workspace-linked or installed. The dev watcher still skips installed copies - cache-key: packagesStamp() hashes each package's built dist/ JS and CSS plus styles.css with the dev watcher's packageFingerprint(). renderToolchainStamp() folds it in, so a change discards the whole cache through __meta__.render and changes the bundle hash - BUILD_CACHE_VERSION 7 -> 8, also noted in .github/pullfrog-modes.md Hashing the four packages costs about 2.5 ms once per build. On Bun and on Node (.docu/lib), an unchanged rebuild still reports 27 of 27 pages cached. Editing markdown's dist now rebuilds all pages and the bundle, and restoring it rebuilds them again. Co-authored-by: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
I reviewed this in senior mode because it touches the flame build pipeline. It adds a fingerprint of the built sibling @docubook/* packages to flame's build cache key.
resolvePackages()split:dev-watch.tsnow resolves both workspace-linked and installed copies.resolveWorkspacePackages()is that list withnode_modulescopies filtered out, so the dev watcher behaves exactly as before.packagesStamp()in the render stamp:cache-key.tshashes eachWATCHED_PACKAGESentry with the existingpackageFingerprint()and folds the result into the memoizedrenderToolchainStamp(). That one change reaches both__meta__.render(pages) andhashMdxSources()(client bundle).- Cache version bump:
BUILD_CACHE_VERSIONgoes from 7 to 8. The PR also adds a@docubook/flamepatch changeset and updates the cache notes in.github/pullfrog-modes.md.
Things I checked:
- Every package resolves: all four packages expose a
defaultcondition onexports["."], socreateRequire().resolve()finds each of them. None is silently skipped. themes-colorsJSON is covered: itsthemes/*.jsonandsyntax/*.jsonpresets are imported bysrc/registry.tsand inlined intodist/. The fingerprint only readsdist/, but it still covers them.- Tests pass:
cache-key.test.ts,dev-watch.test.tsandbase-path.test.ts(161 tests) pass under Node after building flame's workspace dependencies.
Overall: READY. There are no findings and no top priorities.
claude-opus-5-5 | 𝕏
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
flame buildreused cached pages and the cached client bundle after a@docubook/*package it renders with had changed. Upgrading@docubook/markdown(for example to pick up #435) without editing any MDX kept serving HTML and JavaScript built from the previous version until--force. This PR adds a fingerprint of the built sibling packages to the cache key, so a package change rebuilds what it affects and an unchanged build stays fully cached.Follow-up to #435, listed there under "Out of scope".
Why
What the cache keyed on
.docu/build-cache.jsonper file)@docubook/markdown,ui-react,corevia SSR__bundle__)hashMdxSources(compiled MDX, cssBundleStamp())__meta__)renderToolchainStamp()(flame's own render sources)None of these keys covered the packages' code.
cssBundleStamp()already followed@docubook/markdown/styles.css, but not the JavaScript.Reproduction
With a warm cache in this repo, I added a
data-reproattribute torole: "note"inpackages/markdown/dist/components/Callout.jsand ranflame build:/docs/components/calloutstill had 0 of its 7 callouts with the attribute, and the client bundle did not contain it either. In a user project, the same thing happens afternpm update @docubook/markdown, because.docu/build-cache.jsonlives in the project and survives upgrades.Changes
.docu/node/dev-watch.ts:resolvePackages()is split out ofresolveWorkspacePackages(). It resolves the copies flame actually loads, whether workspace-linked or installed undernode_modules.resolveWorkspacePackages()is now that list without installed copies, so the dev watcher behaves exactly as before..docu/node/cache-key.ts:packagesStamp()hashes everyWATCHED_PACKAGESentry (core,markdown,ui-react,themes-colors) with the dev watcher's existingpackageFingerprint(), which covers the JS and CSS indist/plus a rootstyles.css. A package whose entry is missing (mid-rebuild) is recorded asmissing.renderToolchainStamp()folds inpackagesStamp(). That stamp already guards the whole cache through__meta__.renderand is part ofhashMdxSources(), so one change invalidates both the pages and the bundle.BUILD_CACHE_VERSIONgoes from 7 to 8, with a v8 note..github/pullfrog-modes.md: cache version notes updated to v8, and the built packages added to the listed cache keys..changeset/flame-cache-sibling-packages.md:@docubook/flamepatch.The stamp hashes built output rather than versions. A workspace rebuild has no version bump, while an installed copy keeps the same content for as long as its version stays put.
Verification
Bun (
bun .docu/node/build.ts), sequence on a warm cache:callout.html/ bundledisteditedNode (
FLAME_RUNTIME=node node bin/cli.js buildaftercompile:lib): same results. Cached when nothing changed, rebuilt with the marker after the edit, rebuilt without it after restoring.Cost: fingerprinting the four packages (about 110 KB of JS and CSS) takes about 2.5 ms, once per build process (the result is memoized with the render stamp).
New tests:
resolvePackageskeeps installed copies and skips unresolvable names.packagesStampfollows content in an installed layout, including nesteddist/files and a missing entry, is stable across identical rewrites, and covers all four sibling packages in this monorepo.pnpm lint,pnpm typecheckandpnpm testpass (1,128 tests).pnpm build --forceandpnpm test:browser-smokepass.Impact
.docu/build-cache.jsononce, because of the version bump. After that, builds stay cached until an MDX file, a stylesheet, flame itself, or a@docubook/*package changes.flame devalready restarted on such rebuilds (fix(flame): restart the dev server when a workspace package rebuilds #427).