Skip to content

perf(build): skip gzip for node_modules files in the size report - #4927

Closed
onmax wants to merge 2 commits into
nitrojs:v2from
onmax:perf/v2-fs-tree-skip-node-modules-gzip
Closed

onmax wants to merge 2 commits into
nitrojs:v2from
onmax:perf/v2-fs-tree-skip-node-modules-gzip

Conversation

@onmax

@onmax onmax commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #4926 to v2. Nuxt 4 prints this report on every build, so this is where most of the gain is.

🔗 Linked issue

None. Follow-up to #4567 and #4569, which touched the same report.

❓ 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

With logging.compressedSizes on (the default), Nitro gzips every server output file to print the size report. The report never lists node_modules files. It only adds them to the total. They are most of the output, so most of the gzip time goes into one number.

This PR stops gzipping node_modules files. They still count in the total size, and the total gzip now says what it covers:

Σ Total size: 62.1 MB (20.2 MB gzip)                          # before
Σ Total size: 62.1 MB (952 kB gzip, excluding node_modules)   # after

Without node_modules in the output, the log does not change.

I timed generateFSTree in a Nuxt 4 app with 149 traced packages (57 MB in node_modules):

wall CPU
before, 4 builds 1.6 to 1.9 s 4.7 to 5.4 s
after, 4 builds (same change patched into nitropack 2.13.5) 0.2 to 0.4 s 0.7 to 1.4 s

I also tried gzip level 6 (half the time), level 1 (sizes change by 10 to 15%) and worker threads (no gain, zlib.gzip already uses the thread pool). Skipping node_modules saves the most and keeps the listed sizes exact.

A new unit test checks that only listed files get gzipped.

📝 Checklist

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

@onmax
onmax requested a review from pi0 as a code owner October 25, 2026 19:50
@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown

@onmax 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 Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4f0a008c-6298-4f62-8fd9-9454464b4afc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 Oct 25, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitropack@4927

commit: 07cfed8

@pi0

pi0 commented Oct 26, 2026

Copy link
Copy Markdown
Member

lets first decide for main

@pi0 pi0 closed this Oct 26, 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