Skip to content

Commit

Permalink
fix: exclude HMR responses from dummy sourcemap generation
Browse files Browse the repository at this point in the history
Compatibility was broken with fix vitejs#9914 but also we don't need and don't want to add dummy sourcemaps to HMR JS requests.
  • Loading branch information
BenceSzalai committed Nov 3, 2022
1 parent 81a1760 commit 6061436
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/vite/src/node/server/transformRequest.ts
Expand Up @@ -253,8 +253,16 @@ async function loadAndTransform(
code = transformResult.code!
map = transformResult.map

// To enable debugging create a sourcemap for known modified JS files without one:
if (!map && mod.file && mod.type === 'js' && code !== originalCode) {
// To enable IDE debugging add a minimal sourcemap for modified non-HMR JS files without one:
if (
!map &&
mod.file &&
mod.type === 'js' &&
code !== originalCode &&
!code.startsWith(
'import { createHotContext as __vite__createHotContext } from'
)
) {
map = new MagicString(code).generateMap({ source: mod.file })
}
}
Expand Down

0 comments on commit 6061436

Please sign in to comment.