Skip to content

fix: avoid inlining optimizer hidden sourcemaps (fix #23287) - #23288

Open
szupzj18 wants to merge 2 commits into
vitejs:mainfrom
szupzj18:chris/fix/optimizer-hidden-sourcemap
Open

fix: avoid inlining optimizer hidden sourcemaps (fix #23287)#23288
szupzj18 wants to merge 2 commits into
vitejs:mainfrom
szupzj18:chris/fix/optimizer-hidden-sourcemap

Conversation

@szupzj18

@szupzj18 szupzj18 commented Aug 17, 2026

Copy link
Copy Markdown

Root cause

The dependency optimizer emits hidden source maps, but optimized dependencies were sent through the normal transform response path. send() therefore converted the returned map into an inline data URL, making the HTTP response much larger than the optimized file on disk.

Change

Serve optimized dependencies with an external sourceMappingURL that keeps the browser hash query, and return the post-transform map from the dedicated .map endpoint. This avoids base64 response bloat while preserving debugger mappings and existing path-traversal sanitization.

Validation

  • Added a RED/GREEN regression proving the optimized response uses an external map and its .map endpoint serves the generated map
  • pnpm test-unit packages/vite/src/node/__tests__/optimizer/hiddenSourcemap.spec.ts packages/vite/src/node/__tests__/optimizer/customExtensionBundleClose.spec.ts
  • pnpm run test-serve js-sourcemap (9 passed)
  • pnpm exec oxfmt --check ...
  • pnpm exec eslint ...
  • pnpm run build

Fixes #23287

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.

Optimized dependencies are served with their hidden source map inlined, tripling the response size, with no way to opt out

1 participant