Skip to content

Commit

Permalink
fix(sourcemap): tolerate virtual modules in sources array
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Nov 8, 2021
1 parent a473570 commit 8be81db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vite/src/node/server/sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const debug = createDebugger('vite:sourcemap', {
onlyWhenFocused: true
})

const virtualSourceRE = /:|\0/

interface SourceMapLike {
sources: string[]
sourcesContent?: (string | null)[]
Expand All @@ -30,7 +32,7 @@ export async function injectSourcesContent(
const missingSources: string[] = []
map.sourcesContent = await Promise.all(
map.sources.map((sourcePath) => {
if (sourcePath) {
if (sourcePath && !virtualSourceRE.test(sourcePath)) {
sourcePath = decodeURI(sourcePath)
if (sourceRoot) {
sourcePath = path.resolve(sourceRoot, sourcePath)
Expand Down

0 comments on commit 8be81db

Please sign in to comment.