Repository navigation
perf(build): skip unchanged sourcemaps - #4925
Conversation
|
@onmax is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Configure sourcemap source exclusion src/build/plugins/sourcemap.ts, src/build/rolldown/config.ts, src/build/vite/bundler.ts, test/unit/sourcemap.test.ts |
A shared helper determines when sourcemap sources are excluded. Both Rolldown configurations use the helper, and tests cover the settings and explicit user configuration. |
Conditionally rewrite sourcemaps src/build/plugins/sourcemap.ts, test/unit/sourcemap.test.ts |
The plugin updates map fields and serializes the map only when processing changes it. Tests check that unchanged maps do not trigger the asset source setter. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Merge Risk: 
Minimal · up to 064ee
-
No actionable merge-blocking risk was identified in the sourcemap changes.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- 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.
Comment @coderabbitai help to get the list of available commands.
commit: |
🔗 Linked issue
No issue.
❓ Type of change
📚 Description
nitro:sourcemapused to setasset.sourceon every.mapfile, even when nothing changed. Rolldown counts each assignment as an update and copies the map back from JS.On the Rolldown and Vite builders, something always changed anyway: their maps included
sourcesContent, and the hook deleted it.This PR:
nitro:sourcemapwrite back only the maps it actually changes (renamed virtual sources, or removedsourcesContent/x_google_ignoreList/mappings).sourcemapExcludeSourceson the Rolldown and Vite (Rolldown) builders whennitro:sourcemapwould stripsourcesContentanyway: production builds withsourcemapon andexperimental.sourcemapMinifynotfalse. The Rollup builders already set it.sourcemapMinify: false, or in dev, maps keepsourcesContentas before.rolldownConfig.output.sourcemapExcludeSourcesstill applies.On a Nuxt app with about 3,600 server chunks, the Nitro build used about 0.2 s less main-thread CPU.
Output
Emitted files are unchanged. A small app (routes, inlined
node_modulesdeps, virtual modules) was built before and after this PR on the rollup, rolldown and vite builders, each with and withoutsourcemapMinify: false. Once local paths are normalized, all.mjsand.mapfiles match.Behavior notes
The Rolldown and Vite builders now match the Rollup builder in two cases:
sourcesContentbeforenitro:sourcemapruns (buildPluginswithenforce: "pre",rolldownConfig.plugins, Vite plugins ingenerateBundle), or one that readschunk.map, no longer sees it. Tools that read the written.mapfiles (writeBundleor later) are not affected, since those never hadsourcesContent.rolldownConfig.output.sourcemapis overridden to"inline", inline maps no longer includesourcesContent.nitro:sourcemapnever processed inline maps.To keep
sourcesContent, setexperimental.sourcemapMinify: false.