Skip to content

Commit 864d41d

Browse files
committedSep 18, 2021
fix: handle sourcemap: false in transformWithEsbuild
1 parent 991de93 commit 864d41d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎packages/vite/src/node/plugins/esbuild.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function transformWithEsbuild(
126126

127127
try {
128128
const result = await transform(code, resolvedOptions)
129-
if (inMap) {
129+
if (inMap && resolvedOptions.sourcemap) {
130130
const nextMap = JSON.parse(result.map)
131131
nextMap.sourcesContent = []
132132
return {
@@ -139,7 +139,9 @@ export async function transformWithEsbuild(
139139
} else {
140140
return {
141141
...result,
142-
map: JSON.parse(result.map)
142+
map: resolvedOptions.sourcemap
143+
? JSON.parse(result.map)
144+
: { mappings: '' }
143145
}
144146
}
145147
} catch (e) {

0 commit comments

Comments
 (0)
Please sign in to comment.