Skip to content

Commit

Permalink
Remove unnecessary enableSourcemap usage (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Feb 24, 2024
1 parent 0c2695d commit 324f569
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-pans-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

Remove unnecessary `enableSourcemap` option usage and prevent passing it in Svelte 5
7 changes: 0 additions & 7 deletions packages/vite-plugin-svelte/src/utils/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 9 additions & 7 deletions packages/vite-plugin-svelte/src/utils/load-raw.js
Original file line number Diff line number Diff line change
@@ -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
*
Expand All @@ -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,
Expand Down

0 comments on commit 324f569

Please sign in to comment.