Skip to content

fix: include dotfiles in cache output glob matching#1074

Merged
christiango merged 3 commits intomainfrom
chrisgo/fix-dot-caching-pt2
Mar 26, 2026
Merged

fix: include dotfiles in cache output glob matching#1074
christiango merged 3 commits intomainfrom
chrisgo/fix-dot-caching-pt2

Conversation

@christiango
Copy link
Copy Markdown
Member

Related previous PRs: https://github.com/microsoft/backfill/pull/551/changes

Problem

Dotfiles and dotfolders (e.g. .vite/, .next/, .env) in build output directories are silently dropped when lage caches task outputs. A fresh build produces these files correctly, but restoring from cache omits them entirely.

This happens because the glob calls that collect output files for caching use the default dot: false option from globby/fast-glob. Patterns like releaseDeployment/**/* or dist/**/* don't match paths containing dot-prefixed segments (e.g. releaseDeployment/public/.vite/manifest.json).

Root Cause

Three glob call sites were missing dot: true:

  1. CacheStorage.put() — the glob that matches outputGlob patterns to determine which files to store in cache
  2. getHashesFor() — the glob used by incremental caching to enumerate all files for hash comparison
  3. getOutputFiles() — the server-mode function that collects output files for the cache-aware runner

LocalCacheStorage._fetch() already used dot: true when reading files back from cach, but since dotfiles were never stored, there was nothing to restore.

Fix

Add dot: true to all three glob call sites:

File Function Change
packages/backfill-cache/src/CacheStorage.ts getHashesFor() { cwd, dot: true }
packages/backfill-cache/src/CacheStorage.ts put() { cwd: this.cwd, dot: true }
packages/cli/src/commands/server/getOutputFiles.ts getOutputFiles() { cwd: target.cwd, gitignore: false, dot: true }

Tests

Added 4 new tests across 2 test files — all fail before the fix and pass after:

cacheStorage.test.ts (unit):

  • caches dotfiles in subdirectories matched by outputGlob — verifies dist/**/* matches .vite/manifest.json inside dist/public/
  • caches dotfiles when outputGlob uses **/* — verifies **/* matches .env at root level

LocalCacheStorage.test.ts (round-trip put/fetch):

  • will cache and restore dotfiles inside output directories — full cycle with dist/.vite/manifest.json
  • will cache and restore dotfiles when using releaseDeployment/**/* — full cycle matching the exact pattern used by consumers like Loop

How It Was Found

In an internal repo Vite build produces .vite/manifest.json inside releaseDeployment/public/. After running vite the file exists in the right place. But deleting releaseDeployment/ and re-running yarn bundle --to bebop (which restores from lage cache) produces output missing the .vite/ directory. This causes downstream issues since the manifest is needed at runtime.

@christiango christiango requested a review from ecraig12345 March 26, 2026 13:04
@christiango christiango merged commit 4718b38 into main Mar 26, 2026
14 checks passed
@christiango christiango deleted the chrisgo/fix-dot-caching-pt2 branch March 26, 2026 18:10
christiango added a commit that referenced this pull request Mar 27, 2026
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.

2 participants