Skip to content

Commit

Permalink
fix: warn failed source map load instead of erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 14, 2021
1 parent fe7238c commit 7a1261b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ export interface TransformResult {

export async function transformRequest(
url: string,
{ config: { root }, pluginContainer, moduleGraph, watcher }: ViteDevServer
{
config: { root, logger },
pluginContainer,
moduleGraph,
watcher
}: ViteDevServer
): Promise<TransformResult | null> {
url = removeTimestampQuery(url)
const prettyUrl = isDebug ? prettifyUrl(url, root) : ''
Expand Down Expand Up @@ -62,10 +67,16 @@ export async function transformRequest(
}
}
if (code) {
map = (
convertSourceMap.fromSource(code) ||
convertSourceMap.fromMapFileSource(code, path.dirname(file))
)?.toObject()
try {
map = (
convertSourceMap.fromSource(code) ||
convertSourceMap.fromMapFileSource(code, path.dirname(file))
)?.toObject()
} catch (e) {
logger.warn(`Failed to load source map for ${url}.`, {
timestamp: true
})
}
}
} else {
isDebug && debugLoad(`${timeFrom(loadStart)} [plugin] ${prettyUrl}`)
Expand Down

0 comments on commit 7a1261b

Please sign in to comment.