Skip to content

Commit 9290d85

Browse files
authored
fix(css): show correct error when unknown placeholder is used for CSS modules pattern in lightningcss (#19070)
1 parent afff05c commit 9290d85

File tree

1 file changed

+6
-4
lines changed
  • packages/vite/src/node/plugins

1 file changed

+6
-4
lines changed

packages/vite/src/node/plugins/css.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -3221,10 +3221,12 @@ async function compileLightningCSS(
32213221
})
32223222
} catch (e) {
32233223
e.message = `[lightningcss] ${e.message}`
3224-
e.loc = {
3225-
file: e.fileName.replace(NULL_BYTE_PLACEHOLDER, '\0'),
3226-
line: e.loc.line,
3227-
column: e.loc.column - 1, // 1-based
3224+
if (e.loc) {
3225+
e.loc = {
3226+
file: e.fileName.replace(NULL_BYTE_PLACEHOLDER, '\0'),
3227+
line: e.loc.line,
3228+
column: e.loc.column - 1, // 1-based
3229+
}
32283230
}
32293231
throw e
32303232
}

0 commit comments

Comments
 (0)