diff --git a/.changeset/smart-ears-invent.md b/.changeset/smart-ears-invent.md new file mode 100644 index 000000000..134618c0d --- /dev/null +++ b/.changeset/smart-ears-invent.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/vite-plugin-svelte': patch +--- + +fix(prebundleSvelteLibraries): don't try to append missing sourcemap diff --git a/packages/vite-plugin-svelte/src/utils/esbuild.js b/packages/vite-plugin-svelte/src/utils/esbuild.js index 355934832..ac49fd7bb 100644 --- a/packages/vite-plugin-svelte/src/utils/esbuild.js +++ b/packages/vite-plugin-svelte/src/utils/esbuild.js @@ -106,5 +106,7 @@ async function compileSvelte(options, { filename, code }, statsCollection) { if (endStat) { endStat(); } - return compiled.js.code + '//# sourceMappingURL=' + compiled.js.map.toUrl(); + return compiled.js.map + ? compiled.js.code + '//# sourceMappingURL=' + compiled.js.map.toUrl() + : compiled.js.code; }