diff --git a/.changeset/late-pans-guess.md b/.changeset/late-pans-guess.md new file mode 100644 index 000000000..b031fcc8c --- /dev/null +++ b/.changeset/late-pans-guess.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/vite-plugin-svelte': patch +--- + +Remove unnecessary `enableSourcemap` option usage and prevent passing it in Svelte 5 diff --git a/packages/vite-plugin-svelte/src/utils/compile.js b/packages/vite-plugin-svelte/src/utils/compile.js index 3218a0610..a8017a799 100644 --- a/packages/vite-plugin-svelte/src/utils/compile.js +++ b/packages/vite-plugin-svelte/src/utils/compile.js @@ -71,13 +71,6 @@ export const _createCompileSvelte = (makeHot) => { const hash = `s-${safeBase64Hash(normalizedFilename)}`; compileOptions.cssHash = () => hash; } - if (ssr && compileOptions.enableSourcemap !== false) { - if (typeof compileOptions.enableSourcemap === 'object') { - compileOptions.enableSourcemap.css = false; - } else { - compileOptions.enableSourcemap = { js: true, css: false }; - } - } let preprocessed; let preprocessors = options.preprocess; diff --git a/packages/vite-plugin-svelte/src/utils/load-raw.js b/packages/vite-plugin-svelte/src/utils/load-raw.js index e43ff0dcf..75a697cc7 100644 --- a/packages/vite-plugin-svelte/src/utils/load-raw.js +++ b/packages/vite-plugin-svelte/src/utils/load-raw.js @@ -1,7 +1,7 @@ import fs from 'node:fs'; import { toRollupError } from './error.js'; import { log } from './log.js'; -import { isSvelte4 } from './svelte-version.js'; +import { isSvelte4, isSvelte5 } from './svelte-version.js'; /** * utility function to compile ?raw and ?direct requests in load hook * @@ -27,12 +27,14 @@ export async function loadRaw(svelteRequest, compileSvelte, options) { compilerOptions: { dev: false, css: 'external', - enableSourcemap: query.sourcemap - ? { - js: type === 'script' || type === 'all', - css: type === 'style' || type === 'all' - } - : false, + enableSourcemap: isSvelte5 + ? undefined + : query.sourcemap + ? { + js: type === 'script' || type === 'all', + css: type === 'style' || type === 'all' + } + : false, ...svelteRequest.query.compilerOptions }, hot: false,