From 9290d85b5d2ad64991bd296157cb3bcb959c341d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 25 Dec 2024 14:26:25 +0900 Subject: [PATCH] fix(css): show correct error when unknown placeholder is used for CSS modules pattern in lightningcss (#19070) --- packages/vite/src/node/plugins/css.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 3ff50d4e1b2036..e643f5839be268 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -3221,10 +3221,12 @@ async function compileLightningCSS( }) } catch (e) { e.message = `[lightningcss] ${e.message}` - e.loc = { - file: e.fileName.replace(NULL_BYTE_PLACEHOLDER, '\0'), - line: e.loc.line, - column: e.loc.column - 1, // 1-based + if (e.loc) { + e.loc = { + file: e.fileName.replace(NULL_BYTE_PLACEHOLDER, '\0'), + line: e.loc.line, + column: e.loc.column - 1, // 1-based + } } throw e }