Skip to content

Commit

Permalink
fix: address Svelte 5 warning
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Sep 13, 2024
1 parent c8e335a commit ec04dae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/two-ducks-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/enhanced-img': patch
---

fix: address Svelte 5 warning
5 changes: 4 additions & 1 deletion packages/enhanced-img/src/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from 'node:path';

import MagicString from 'magic-string';
import { asyncWalk } from 'estree-walker';
import { VERSION } from 'svelte/compiler';
import { parse } from 'svelte-parse-markup';

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

Expand Down

0 comments on commit ec04dae

Please sign in to comment.