From 5b9f38920a219e9c2822c497662f98ad7b49c62d Mon Sep 17 00:00:00 2001 From: "T. R. Bernstein" <137705289+trbernstein@users.noreply.github.com> Date: Wed, 18 Dec 2024 02:27:20 +0100 Subject: [PATCH 1/2] 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. --- packages/vite-plugin-svelte/src/utils/error.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite-plugin-svelte/src/utils/error.js b/packages/vite-plugin-svelte/src/utils/error.js index cbc375b2d..31e3c5af3 100644 --- a/packages/vite-plugin-svelte/src/utils/error.js +++ b/packages/vite-plugin-svelte/src/utils/error.js @@ -108,7 +108,7 @@ function formatFrameForVite(frame) { * @returns {boolean} */ function couldBeFixedByCssPreprocessor(code) { - return code === 'expected_token' || code === 'unexpected_eof' || code.startsWith('css_'); + return code === 'expected_token' || code === 'unexpected_eof' || code?.startsWith('css_'); } /** From 1fa6b180338f74e590b246dba77a3bc342e96294 Mon Sep 17 00:00:00 2001 From: dominikg Date: Wed, 18 Dec 2024 10:53:20 +0100 Subject: [PATCH 2/2] chore: add changeset --- .changeset/giant-plants-learn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/giant-plants-learn.md diff --git a/.changeset/giant-plants-learn.md b/.changeset/giant-plants-learn.md new file mode 100644 index 000000000..5142ca7c4 --- /dev/null +++ b/.changeset/giant-plants-learn.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/vite-plugin-svelte': patch +--- + +fix errorhandling to work with errors that don't have a code property