Skip to content

Commit ec04dae

Browse files
committed
fix: address Svelte 5 warning
1 parent c8e335a commit ec04dae

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/two-ducks-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/enhanced-img': patch
3+
---
4+
5+
fix: address Svelte 5 warning

packages/enhanced-img/src/preprocessor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from 'node:path';
33

44
import MagicString from 'magic-string';
55
import { asyncWalk } from 'estree-walker';
6+
import { VERSION } from 'svelte/compiler';
67
import { parse } from 'svelte-parse-markup';
78

89
// TODO: expose this in vite-imagetools rather than duplicating it
@@ -159,7 +160,9 @@ export function image(opts) {
159160
// @ts-ignore
160161
s.appendLeft(ast.module.content.start, text);
161162
} else {
162-
s.prepend(`<script context="module">\n${text}</script>\n`);
163+
s.prepend(
164+
`<script ${VERSION.startsWith('4') ? 'context="module"' : 'module'}>\n${text}</script>\n`
165+
);
163166
}
164167
}
165168

0 commit comments

Comments
 (0)