Repository navigation
Description
Describe the bug
vp migrate reads every source-like file under each workspace package, including directories that .gitignore excludes. In our monorepo the shell app has a gitignored static/ folder (2.1 GB of editorial assets that are synced to S3/CDN and never committed). With that folder present, vp migrate on an already-migrated project takes 53s and peaks at 1.47 GB RSS. Without it, the same worktree takes 4.0s and 320 MB. No files change in either case. Our main checkout has about 1.2 GB of matching files in ignored directories (release artifacts, caches, generated SvelteKit output dirs such as .svelte-kit-build), so migrate there runs for several minutes.
The cause seems to be filesInProject() in dist/migration/bin.js, called from planVitestV5Migration(). It recursively walks each package directory, skipping only the fixed SKIP_DIRS names (node_modules, dist, build, .svelte-kit, ...). It reads every .js/.ts/.json/.yml/.sh file with readFileSync and passes each to scanAndRewriteFile. It never consults .gitignore, although the same file already uses the native isDirectoryGitignored() binding for the .vitest check.
Gitignored files can't be part of the committed project, and migrate never writes to them, so reading them only costs time and memory. There is also no CLI option or config to exclude directories (#3406 discussed a migrate.ignorePatterns option, but for a different purpose: excluding projects from rewriting).
Suggested fix: skip directories that git ignores in filesInProject(), for example with isDirectoryGitignored() or git ls-files --cached --others --exclude-standard. Fall back to SKIP_DIRS outside a git repo.
Reproduction
No repository; the script in "Steps to reproduce" creates the reproduction.
Steps to reproduce
setup() {
mkdir "$1" && cd "$1" && git init -q
cat > package.json <<'EOF'
{ "name": "repro", "private": true, "type": "module",
"devDependencies": { "vite": "^8.0.0", "vitest": "^4.0.0" } }
EOF
printf 'node_modules/\nstatic/\n' > .gitignore
mkdir -p src && echo 'export const add = (a, b) => a + b;' > src/add.js
git add -A && git commit -qm init
cd ..
}
setup with && setup without
# 400 gitignored bundles (~158 MB), standing in for an S3-synced asset folder
(cd with && node -e "const fs=require('fs');const s='export const d='+JSON.stringify(Array.from({length:60000},(_, i)=>i*1.5))+';\n';for(let i=0;i<400;i++){fs.mkdirSync('static/d'+i,{recursive:true});fs.writeFileSync('static/d'+i+'/bundle.js',s)}")
for d in without with; do
(cd "$d" && /usr/bin/time -f "$d: %es, peak %M KB" vp migrate --no-interactive --no-agent --no-editor --no-hooks > /dev/null)
doneResult:
without: 1.20s, peak 371316 KB
with: 5.15s, peak 849416 KB
Run time and memory grow with the size of the ignored folder, though nothing in it is tracked.
System Info
vp v1.8.0 (vite 8.3.8, rolldown 1.2.19, vitest 5.1.1, oxlint 1.94.0, oxfmt 0.79.0)
Node.js 26.8.2, pnpm 12.4.1
Linux arm64 (4 cores, 23 GB RAM)Used Package Manager
pnpm
Logs
No errors; migrate completes normally, just slowly.Validations
- Read the Contributing Guidelines.
- Check that there isn't already an issue for the same bug.
- Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc).
- The provided reproduction is a minimal reproducible example.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Start date
Target date
Effort
Activity
voidzero-bot commentedon Nov 26, 2026
Triage failed unexpectedly (attempt 1 of 3).
Run: https://github.com/voidzero-dev/vite-plus/actions/runs/45734783217
I can retry if a new comment provides more information or asks me to try again.
Error:
fix(migrate): skip gitignored directories in the Vitest v5 preflight