Skip to content

Commit 97ee68c

Browse files
authored
fix: output sourcemap from hmr helper preprocessor (#71)
* fix: output sourcemap from hmr helper preprocessor * chore: update lockfile
1 parent 377d464 commit 97ee68c

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

.changeset/wicked-hairs-share.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
output sourcemap in hmr helper preprocessor

packages/vite-plugin-svelte/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@rollup/pluginutils": "^4.1.0",
4848
"chalk": "^4.1.1",
4949
"debug": "^4.3.2",
50+
"magic-string": "^0.25.7",
5051
"require-relative": "^0.8.7",
5152
"svelte-hmr": "^0.14.4"
5253
},

packages/vite-plugin-svelte/src/utils/preprocess.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ResolvedConfig, TransformResult } from 'vite';
2+
import MagicString from 'magic-string';
23
import { Preprocessor, PreprocessorGroup, ResolvedOptions } from './options';
34
import { TransformPluginContext } from 'rollup';
45
import { log } from './log';
@@ -67,9 +68,12 @@ export function createVitePreprocessorGroup(
6768
*/
6869
function createInjectScopeEverythingRulePreprocessorGroup(): PreprocessorGroup {
6970
return {
70-
style({ content }) {
71+
style({ content, filename }) {
72+
const s = new MagicString(content);
73+
s.append(' *{}');
7174
return {
72-
code: `${content} *{}`
75+
code: s.toString(),
76+
map: s.generateDecodedMap({ file: filename })
7377
};
7478
}
7579
};

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)