Skip to content

feat(module-runner): send source maps separately when debuggers don't need them - #24000

Open
maschwenk wants to merge 1 commit into
vitejs:mainfrom
maschwenk:feat/module-runner-separate-source-map-pr
Open

maschwenk wants to merge 1 commit into
vitejs:mainfrom
maschwenk:feat/module-runner-separate-source-map-pr

Conversation

@maschwenk

@maschwenk maschwenk commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

closes #23890

the runner gets each module's source map inlined as a base64 comment, and v8 compiles it along with the code even though the prepareStackTrace interceptor never reads it from there. it's 64-78% of the evaluated code for rxjs, effect and three. this adds dev.sourcemapForDebugger (default true, nothing changes). with it off, the server sends the map as a JSON string in ViteFetchResult.sourceMap, the code has no comment, and createServerModuleRunner defaults to prepareStackTrace. runners with the 'node' interceptor and runners that don't send separateSourceMap still get inlined maps

importing effect's 360 source modules in a fresh worker per pass, like vitest does: 10% faster per pass with the option off, within 1% of main with it on. unlike the issue's suggestion, the map stays inlined with the option on, since having each runner re-add the comment made that case 3-9% slower. sourceMap has the same name and type as vitest-dev/vitest#11750. added tests for both modes, the 'node' interceptor, and a transform result shared by both kinds of runner

i used AI to help write the change and the benchmarks, and reviewed it myself

@maschwenk
maschwenk marked this pull request as ready for review November 5, 2026 16:19
@sapphi-red sapphi-red added p2-nice-to-have Not breaking anything but nice to have (priority) feat: ssr labels Nov 6, 2026
@sapphi-red sapphi-red added this to the 8.5 milestone Nov 6, 2026
@github-project-automation github-project-automation Bot moved this to Discussing in Team Board Nov 6, 2026
@sapphi-red sapphi-red moved this from Discussing to P2 - 5 in Team Board Nov 6, 2026
@sapphi-red sapphi-red moved this from P2 - 5 to P2 - 4 in Team Board Nov 6, 2026
@maschwenk
maschwenk force-pushed the feat/module-runner-separate-source-map-pr branch from 217c23b to bdfb9c1 Compare November 6, 2026 11:44
@maschwenk

maschwenk commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

@sapphi-red this is ready for review. it follows your design from

except with dev.sourcemapForDebugger on, the server keeps the map inlined instead of the runner re-adding the comment, since the runner version was 3-9% slower per fresh worker. numbers are in the description

… need them

Add `dev.sourcemapForDebugger` (default true). When it's disabled, the server
returns the map as a JSON string in `ViteFetchResult.sourceMap` instead of
inlining it, so the code V8 compiles has no source map comment, and
createServerModuleRunner defaults to the prepareStackTrace interceptor.
Runners using the 'node' interceptor and older runners keep inline maps.
@maschwenk
maschwenk force-pushed the feat/module-runner-separate-source-map-pr branch from bdfb9c1 to 258442c Compare November 13, 2026 13:09

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: ssr p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

Status: P2 - 4

Development

Successfully merging this pull request may close these issues.

Module runner: send source maps separately from module code

2 participants