Skip to content

fix(build): count each output file once in the size report - #4568

Merged
pi0 merged 1 commit into
nitrojs:mainfrom
maxmaxme:fix/fstree-count-symlinked-files-once
Sep 2, 2026
Merged

fix(build): count each output file once in the size report#4568
pi0 merged 1 commit into
nitrojs:mainfrom
maxmaxme:fix/fstree-count-symlinked-files-once

Conversation

@maxmaxme

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #4567

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

generateFSTree globbed the server output with symlink traversal left at its default, while the output itself is built from directory symlinks — externals traced in more than one version are written to .nitro/<pkg>@<version> and linked into place, both flat and under each parent. Every file behind those links was therefore read, and gzipped when compressedSizes is on, once per path, inflating the reported total.

Disabling traversal alone under-counts: the only real copies sit inside the .nitro dot directory that globs skip by default, so dot is needed too. With both, the report matches the bytes actually on disk.

On the reproduction from #4567:

reported real on disk
before 25.2 MB (62.8 kB gzip) 5.2 MB
after 5.15 MB (42.4 kB gzip) 5.2 MB

The remaining 0.05 MB is the three sourcemaps that ignore: ["**/*.map"] now excludes — the previous pattern had no **/, so it matched only the root of the output.

For scale, on a production Nuxt 4.5 app the glob returned 413250 paths for 11415 unique files, and the report alone took 98 s of a 4-minute CI build.

No tests reference generateFSTree, and the change is confined to how the report is gathered — build output is untouched.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

`generateFSTree` globbed the server output with symlink traversal left at its
default, while the output itself is built from directory symlinks: externals
traced in more than one version are written to `.nitro/<pkg>@<version>` and
linked into place, both flat and under each parent. Every file behind those
links was therefore read — and gzipped, when `compressedSizes` is on — once per
path, inflating the reported total.

Disabling symlink traversal alone under-counts, because the only real copies sit
inside the `.nitro` dot directory that globs skip by default, so `dot` is needed
too. With both, the report matches the bytes actually on disk.

Also adds the missing `**/` to the sourcemap ignore pattern, which previously
matched only the root of the output.

Resolves nitrojs#4567
@maxmaxme
maxmaxme requested a review from pi0 as a code owner August 31, 2026 14:51
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@maxmaxme is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b342488-af7f-41fa-a50e-cddfcdcfb0ad

📥 Commits

Reviewing files that changed from the base of the PR and between 5d83475 and 9af64b4.

📒 Files selected for processing (1)
  • src/utils/fs-tree.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

generateFSTree now excludes nested .map files, avoids symbolic-link traversal, and includes dotfiles during file discovery.

Changes

File tree globbing

Layer / File(s) Summary
Glob traversal and filtering
src/utils/fs-tree.ts
The file glob uses recursive .map exclusion, disables symbolic-link traversal, and includes dotfiles.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 9af64

This localized change makes the size report count symlinked output files once without changing build output, and no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits syntax with the fix(build): prefix and accurately describes the size-report fix.
Description check ✅ Passed The description clearly explains the symlink, dot-directory, and sourcemap changes and relates them to issue #4567.
Linked Issues check ✅ Passed The changes satisfy issue #4567 by disabling symlink traversal, including dot directories, and excluding nested sourcemaps with **/*.map.
Out of Scope Changes check ✅ Passed All described changes are limited to generateFSTree report gathering and directly support the linked issue. No unrelated changes are identified.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4568

commit: 9af64b4

@pi0x pi0x added bug Something isn't working v3 labels Sep 2, 2026
@pi0
pi0 merged commit eee779f into nitrojs:main Sep 2, 2026
12 of 13 checks passed
@pi0x pi0x mentioned this pull request Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generateFSTree follows symlinks it created itself, counting files many times over

3 participants