Repository navigation
fix(image-imports): get cache - #59
Conversation
|
/bigbonk review |
There was a problem hiding this comment.
Clean fix. The load hook in Vite/Rolldown doesn't bind this to the plugin object — it binds to the Rolldown plugin context instead, so (this as any)._dimCache was always undefined. Hoisting the Map to a closure variable is the correct approach.
One minor note: now that _dimCache is no longer accessed via this, the property assignment on the plugin object (line 2577: _dimCache: imageImportDimCache) and the type assertion at line 2670 (as Plugin & { _dimCache: ... }) are dead code. Consider removing both to keep things tidy — the property only existed to support the old (this as any)._dimCache pattern.
|
|
||
| // Cache of image dimensions to avoid re-reading files | ||
| _dimCache: new Map<string, { width: number; height: number }>(), | ||
| _dimCache: imageImportDimCache, |
There was a problem hiding this comment.
Nit: This property is now dead code — nothing reads _dimCache from the plugin object anymore. Consider removing it (and the corresponding & { _dimCache: ... } type assertion at line 2670) to keep the plugin definition clean.
|
Review submitted. Here's a summary: Approved — This is a correct fix. The Left one minor nit: the |
commit: |
|
LGTM, thanks @hyoban ! |
Currently,
thisis pointing to the wrong value.