fix: skip fallback sourcemap generation for ?raw imports#22148
fix: skip fallback sourcemap generation for ?raw imports#22148sapphi-red merged 4 commits intovitejs:mainfrom
?raw imports#22148Conversation
|
What if we fix it this way? vite/packages/vite/src/node/plugins/asset.ts Lines 208 to 213 in 6e585dc We can add Honestly, I still think generating a fallback sourcemap in general doesn't make sense at all, but this could be an easy workaround for now. ref #13514. cc @sapphi-red |
That sounds better to me. |
|
@bluwy @sapphi-red Updated to emit map: { mappings: '' } from the asset plugin instead of adding skipFallbackSourcemap flag. |
61bd45b to
401b3c0
Compare
?raw imports
Summary
Skip dev-server fallback sourcemap generation for
?rawimports.?rawresponses already embed the full source text in the generated JS module. Injecting an additional fallback inline sourcemapduplicates that content and can lead to severe memory amplification for large newline-heavy files.
This change keeps
?rawimport behavior intact, but disables fallback sourcemap injection for raw requests only.Changes
skipFallbackSourcemapsupport tosend()skipFallbackSourcemap: truefor?rawrequests in transform middlewareWhy
The reported OOM happens in the dev-server fallback sourcemap path rather than in the raw file read alone. This is a narrow fix that
avoids changing
?rawsemantics while removing the highest-cost duplication path.Validation
pnpm exec eslint packages/vite/src/node/server/send.ts packages/vite/src/node/server/middlewares/transform.ts packages/vite/src/node/ server/__tests__/send.spec.tspnpm exec tsc -p packages/vite/src/node/tsconfig.json --noEmitpnpm exec vitest run packages/vite/src/node/server/__tests__/send.spec.ts packages/vite/src/node/server/__tests__/ transformRequest.spec.tsFixes part of #22132