From a0f4c6b2274187ab57b92efa2f112fee43093758 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 25 Nov 2025 18:55:39 -0800 Subject: [PATCH] chore: remove duplicate caching layer --- .changeset/tasty-crews-sing.md | 5 +++++ packages/enhanced-img/src/vite-plugin.js | 13 +------------ 2 files changed, 6 insertions(+), 12 deletions(-) create mode 100644 .changeset/tasty-crews-sing.md diff --git a/.changeset/tasty-crews-sing.md b/.changeset/tasty-crews-sing.md new file mode 100644 index 000000000000..b74781de4abd --- /dev/null +++ b/.changeset/tasty-crews-sing.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/enhanced-img': patch +--- + +chore: remove duplicate caching layer diff --git a/packages/enhanced-img/src/vite-plugin.js b/packages/enhanced-img/src/vite-plugin.js index 2c4599057c36..3812242225f8 100644 --- a/packages/enhanced-img/src/vite-plugin.js +++ b/packages/enhanced-img/src/vite-plugin.js @@ -15,13 +15,6 @@ const OPTIMIZABLE = /^[^?]+\.(avif|heif|gif|jpeg|jpg|png|tiff|webp)(\?.*)?$/; * @returns {import('vite').Plugin} */ export function image_plugin(imagetools_plugin) { - // TODO: clear this map in dev mode to avoid memory leak - /** - * URL to image details - * @type {Map} - */ - 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();