[PR #1074] [MERGED] refactor(plugins): dedupe og-asset read-to-base64 wrapper #1071

Closed
opened 2026-05-06 13:11:50 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/1074
Author: @james-elicx
Created: 5/5/2026
Status: Merged
Merged: 5/5/2026
Merged by: @james-elicx

Base: mainHead: refactor/dedupe-og-asset-read


📝 Commits (1)

  • bbb30b4 refactor(plugins): dedupe og-asset read-to-base64 wrapper

📊 Changes

1 file changed (+20 additions, -26 deletions)

View changed files

📝 packages/vinext/src/plugins/og-assets.ts (+20 -26)

📄 Description

Summary

  • Follow-up to #1058.
  • Two near-identical try/catch blocks in packages/vinext/src/plugins/og-assets.ts (one for the fetch(new URL(...)) rewrite, one for the readFileSync(fileURLToPath(...)) rewrite) read a file from disk, base64-encoded it, populated the build cache, and silently skipped on error. Both branches were structurally identical apart from the surrounding regex match and the inline replacement string.
  • Extracted the shared logic into a local readAsBase64(absPath) helper that closes over the existing cache Map and useCache flag. Returns string | null so call sites can short-circuit with a single continue. No behavior change: same cache semantics, same silent-on-error fallback, same return type on miss.

Files changed

  • packages/vinext/src/plugins/og-assets.ts (-26 / +20)

Test plan

  • pnpm vp test run tests/og-inline.test.ts — 8/8 pass
  • pnpm fmt --write clean
  • pnpm knip clean
  • CI green

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/1074 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 5/5/2026 **Status:** ✅ Merged **Merged:** 5/5/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `refactor/dedupe-og-asset-read` --- ### 📝 Commits (1) - [`bbb30b4`](https://github.com/cloudflare/vinext/commit/bbb30b464d34788c8738641ada39933f8654b27e) refactor(plugins): dedupe og-asset read-to-base64 wrapper ### 📊 Changes **1 file changed** (+20 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/plugins/og-assets.ts` (+20 -26) </details> ### 📄 Description ## Summary - Follow-up to #1058. - Two near-identical try/catch blocks in `packages/vinext/src/plugins/og-assets.ts` (one for the `fetch(new URL(...))` rewrite, one for the `readFileSync(fileURLToPath(...))` rewrite) read a file from disk, base64-encoded it, populated the build cache, and silently skipped on error. Both branches were structurally identical apart from the surrounding regex match and the inline replacement string. - Extracted the shared logic into a local `readAsBase64(absPath)` helper that closes over the existing `cache` Map and `useCache` flag. Returns `string | null` so call sites can short-circuit with a single `continue`. No behavior change: same cache semantics, same silent-on-error fallback, same return type on miss. ## Files changed - `packages/vinext/src/plugins/og-assets.ts` (-26 / +20) ## Test plan - [x] `pnpm vp test run tests/og-inline.test.ts` — 8/8 pass - [x] `pnpm fmt --write` clean - [x] `pnpm knip` clean - [ ] CI green 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:50 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#1071
No description provided.