Skip to content

Commit 1a91581

Browse files
trbernsteindominikg
authored andcommitted
Use optional chaining to catch null error codes in error.js (#1054)
* Use optional chaining to catch null error codes in error.js Starting a new vite project and selecting svelte-ts template results in an error, because `code` var in error.js is null. Optional chaining resolves this issue. * chore: add changeset --------- Co-authored-by: dominikg <[email protected]> (cherry picked from commit 47184d4)
1 parent c8862d9 commit 1a91581

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/giant-plants-learn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
fix errorhandling to work with errors that don't have a code property

packages/vite-plugin-svelte/src/utils/error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function formatFrameForVite(frame) {
108108
* @returns {boolean}
109109
*/
110110
function couldBeFixedByCssPreprocessor(code) {
111-
return code === 'expected_token' || code === 'unexpected_eof' || code.startsWith('css_');
111+
return code === 'expected_token' || code === 'unexpected_eof' || code?.startsWith('css_');
112112
}
113113

114114
/**

0 commit comments

Comments
 (0)