Skip to content

Commit

Permalink
fix: handle sourcemap: false in transformWithEsbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 18, 2021
1 parent 991de93 commit 864d41d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export async function transformWithEsbuild(

try {
const result = await transform(code, resolvedOptions)
if (inMap) {
if (inMap && resolvedOptions.sourcemap) {
const nextMap = JSON.parse(result.map)
nextMap.sourcesContent = []
return {
Expand All @@ -139,7 +139,9 @@ export async function transformWithEsbuild(
} else {
return {
...result,
map: JSON.parse(result.map)
map: resolvedOptions.sourcemap
? JSON.parse(result.map)
: { mappings: '' }
}
}
} catch (e) {
Expand Down

0 comments on commit 864d41d

Please sign in to comment.