Summary
buildCache.get() is called with a hardcoded empty [] for dependencies at packages/stx/src/ssg.ts:1023. The cache key is built from filePath + mtimeMs + deps[], so if the deps array is always empty, the hash only changes when the page file itself changes — not when partials, layouts, or other transitive includes change. A change to a footer partial included in 30 pages re-uses the stale cached output for all 30.
Reproducer
bun stx build(SSG mode) a project withpages/index.stxthat@include('partials/footer').- Edit
partials/footer.stx. bun stx buildagain.- Observed:
index.htmlkeeps the old footer (cache hit). - Expected: Cache is invalidated; new footer is rendered.
Root cause
packages/stx/src/ssg.ts:1023:
html = buildCache.get(url, route.filePath, [])
// ^^ always emptygetHash at ssg.ts:280 iterates the dependencies but the call site always passes []:
getHash(filePath: string, dependencies: string[]): string {
const stats = fs.statSync(filePath)
let hashInput = `${filePath}:${stats.mtimeMs}`
for (const dep of dependencies) {
if (fs.existsSync(dep)) {
const depStats = fs.statSync(dep)
hashInput += `:${dep}:${depStats.mtimeMs}`
}
}
// ...
}The deps Set is populated by processDirectives (passed by reference) but never threaded back to the cache lookup.
Impact
High. Any project using SSG + cache + partials/layouts has stale output after partial edits. The workaround is to disable cache (cache: false) — losing the speedup the cache was meant to provide.
Suggested fix
Make renderPage return {html, dependencies} (or capture deps before the cache call) and pass the collected dependencies to buildCache.get/set:
const dependencies = new Set<string>()
// existing render path populates dependencies via processDirectives
const depArray = Array.from(dependencies)
html = buildCache.get(url, route.filePath, depArray)
if (!html) {
html = await renderPage(/* ... */)
buildCache.set(url, route.filePath, depArray, html)
}Same fix applies to the set side at the corresponding location.
Workaround
Set cache: false in the SSG config, or rm -rf .stx/cache between builds.
Environment
- stx main
- Bun 1.3.13