From d169c1a20029d512f3b257cc4f5a50d34278b042 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Fri, 25 Jun 2021 12:01:42 -0400 Subject: [PATCH] fix: throw a clearer error for non-existent sources --- packages/vite/src/node/server/sourcemap.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/sourcemap.ts b/packages/vite/src/node/server/sourcemap.ts index 65c57423206008..6b1ba9ee6c359c 100644 --- a/packages/vite/src/node/server/sourcemap.ts +++ b/packages/vite/src/node/server/sourcemap.ts @@ -20,7 +20,13 @@ export async function injectSourcesContent( if (!isVirtual) { sourcePath = path.resolve(sourceRoot, sourcePath) } - map.sourcesContent![i] = await fs.readFile(sourcePath, 'utf-8') + try { + map.sourcesContent![i] = await fs.readFile(sourcePath, 'utf-8') + } catch (e) { + throw new Error( + `Sourcemap for "${file}" has a non-existent source: "${sourcePath}"` + ) + } }) ) }