Skip to content

Commit 291497e

Browse files
authored
chore: remove duplicate caching layer (#14988)
1 parent cf9d7ec commit 291497e

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

.changeset/tasty-crews-sing.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+
chore: remove duplicate caching layer

packages/enhanced-img/src/vite-plugin.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ const OPTIMIZABLE = /^[^?]+\.(avif|heif|gif|jpeg|jpg|png|tiff|webp)(\?.*)?$/;
1515
* @returns {import('vite').Plugin<void>}
1616
*/
1717
export function image_plugin(imagetools_plugin) {
18-
// TODO: clear this map in dev mode to avoid memory leak
19-
/**
20-
* URL to image details
21-
* @type {Map<string, import('vite-imagetools').Picture>}
22-
*/
23-
const images = new Map();
24-
2518
/** @type {import('vite').ResolvedConfig} */
2619
let vite_config;
2720

@@ -117,11 +110,7 @@ export function image_plugin(imagetools_plugin) {
117110
}
118111

119112
if (OPTIMIZABLE.test(url)) {
120-
let image = images.get(resolved_id);
121-
if (!image) {
122-
image = await process_id(resolved_id, plugin_context, imagetools_plugin);
123-
images.set(resolved_id, image);
124-
}
113+
const image = await process_id(resolved_id, plugin_context, imagetools_plugin);
125114
s.update(node.start, node.end, img_to_picture(content, node, image));
126115
} else {
127116
const metadata = await sharp(resolved_id).metadata();

0 commit comments

Comments
 (0)