Skip to content

Commit

Permalink
fix(sourcemap): ensure sources and sourcesContent are the same le…
Browse files Browse the repository at this point in the history
…ngth
  • Loading branch information
aleclarson committed Jul 21, 2021
1 parent ba1871e commit ed09cb7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/vite/src/node/server/sourcemap.ts
Expand Up @@ -29,15 +29,18 @@ export async function injectSourcesContent(

const missingSources: string[] = []
map.sourcesContent = await Promise.all(
map.sources.filter(Boolean).map((sourcePath) => {
sourcePath = decodeURI(sourcePath)
if (sourceRoot) {
sourcePath = path.resolve(sourceRoot, sourcePath)
map.sources.map((sourcePath) => {
if (sourcePath) {
sourcePath = decodeURI(sourcePath)
if (sourceRoot) {
sourcePath = path.resolve(sourceRoot, sourcePath)
}
return fs.readFile(sourcePath, 'utf-8').catch(() => {
missingSources.push(sourcePath)
return null
})
}
return fs.readFile(sourcePath, 'utf-8').catch(() => {
missingSources.push(sourcePath)
return null
})
return null
})
)

Expand Down

0 comments on commit ed09cb7

Please sign in to comment.