Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tasty-crews-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/enhanced-img': patch
---

chore: remove duplicate caching layer
13 changes: 1 addition & 12 deletions packages/enhanced-img/src/vite-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Loading