[PR #723] [MERGED] fix(fonts): handle nested-brace options objects in self-hosting transform #799

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

📋 Pull Request Information

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

Base: mainHead: fix/font-nested-brace-options


📝 Commits (2)

  • fd164d6 fix(fonts): handle nested-brace options objects in self-hosting transform
  • cb9754f fix(fonts): address bonk review — template literal interpolations, dedup, hoisting

📊 Changes

3 files changed (+341 additions, -6 deletions)

View changed files

📝 packages/vinext/src/index.ts (+3 -0)
📝 packages/vinext/src/plugins/fonts.ts (+155 -6)
📝 tests/font-google.test.ts (+183 -0)

📄 Description

Summary

  • namedCallRe and memberCallRe used \{[^}]*\} which stops at the first }, silently skipping self-hosting for any font call whose options contain a nested object (e.g. Inter({ subsets: ["latin"], axes: { wght: 400 } }))
  • Replace both regexes with a lookahead-only pattern + a findBalancedObject() helper that tracks brace depth and skips string literals
  • Adds regression tests for both the named-import path and the default-import proxy (namespace member) path

🔄 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/723 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/30/2026 **Status:** ✅ Merged **Merged:** 3/30/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/font-nested-brace-options` --- ### 📝 Commits (2) - [`fd164d6`](https://github.com/cloudflare/vinext/commit/fd164d60f8791ef635d0d55b9acc2206898ec37c) fix(fonts): handle nested-brace options objects in self-hosting transform - [`cb9754f`](https://github.com/cloudflare/vinext/commit/cb9754ffd91edb900159a76680285f74ccbb9210) fix(fonts): address bonk review — template literal interpolations, dedup, hoisting ### 📊 Changes **3 files changed** (+341 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+3 -0) 📝 `packages/vinext/src/plugins/fonts.ts` (+155 -6) 📝 `tests/font-google.test.ts` (+183 -0) </details> ### 📄 Description ## Summary - `namedCallRe` and `memberCallRe` used `\{[^}]*\}` which stops at the first `}`, silently skipping self-hosting for any font call whose options contain a nested object (e.g. `Inter({ subsets: ["latin"], axes: { wght: 400 } })`) - Replace both regexes with a lookahead-only pattern + a `findBalancedObject()` helper that tracks brace depth and skips string literals - Adds regression tests for both the named-import path and the default-import proxy (namespace member) path --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:09 +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#799
No description provided.