chore: remove duplicate caching layer (#14988)
authorBen McCann <322311+benmccann@users.noreply.github.com>
Wed, 26 Nov 2025 13:41:44 +0000 (05:41 -0800)
committerGitHub <noreply@github.com>
Wed, 26 Nov 2025 13:41:44 +0000 (05:41 -0800)
.changeset/tasty-crews-sing.md [new file with mode: 0644]
packages/enhanced-img/src/vite-plugin.js

diff --git a/.changeset/tasty-crews-sing.md b/.changeset/tasty-crews-sing.md
new file mode 100644 (file)
index 0000000..b74781d
--- /dev/null
@@ -0,0 +1,5 @@
+---
+'@sveltejs/enhanced-img': patch
+---
+
+chore: remove duplicate caching layer
index 2c4599057c36fe50e305ce56908e0a562b308877..3812242225f8f6648db042860c8a22b021adad5c 100644 (file)
@@ -15,13 +15,6 @@ const OPTIMIZABLE = /^[^?]+\.(avif|heif|gif|jpeg|jpg|png|tiff|webp)(\?.*)?$/;
  * @returns {import('vite').Plugin<void>}
  */
 export function image_plugin(imagetools_plugin) {
-       // TODO: clear this map in dev mode to avoid memory leak
-       /**
-        * URL to image details
-        * @type {Map<string, import('vite-imagetools').Picture>}
-        */
-       const images = new Map();
-
        /** @type {import('vite').ResolvedConfig} */
        let vite_config;
 
@@ -117,11 +110,7 @@ export function image_plugin(imagetools_plugin) {
                                        }
 
                                        if (OPTIMIZABLE.test(url)) {
-                                               let image = images.get(resolved_id);
-                                               if (!image) {
-                                                       image = await process_id(resolved_id, plugin_context, imagetools_plugin);
-                                                       images.set(resolved_id, image);
-                                               }
+                                               const image = await process_id(resolved_id, plugin_context, imagetools_plugin);
                                                s.update(node.start, node.end, img_to_picture(content, node, image));
                                        } else {
                                                const metadata = await sharp(resolved_id).metadata();