1 Commits

Author SHA1 Message Date
Divanshu Chauhan (divkix) 9b285e3c9f perf: async I/O + cache for og-inline-fetch-assets transform (#435)
* perf: convert og-inline-fetch-assets transform to async I/O with per-build cache

The `vinext:og-inline-fetch-assets` plugin used synchronous `fs.readFileSync()`
in Vite's transform hook, blocking the transform pipeline. This converts both
Pattern 1 (fetch inlining) and Pattern 2 (readFileSync inlining) to use
`await fs.promises.readFile()` and adds a per-build `Map<string, string>` cache
so repeated reads of the same file (common with shared fonts) hit memory instead
of disk.

* fix: use strict undefined check in og-inline cache and restore spies via afterEach

Replace falsy `if (!fileBase64)` with `if (fileBase64 === undefined)` in both
og-inline patterns to correctly handle hypothetical empty-string cache values.
Add `afterEach(() => vi.restoreAllMocks())` to prevent spy leaks on assertion
failure, replacing the manual mockRestore() call.

* fix: address og-inline review feedback

* style: format og-inline test assertions
2026-03-11 16:44:48 +00:00