[PR #785] [MERGED] fix(plugins): track font call ranges during transform #845

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

📋 Pull Request Information

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

Base: mainHead: fix/issue-751-next-font-google-transform


📝 Commits (8)

  • c92de34 fix(plugins): track font call ranges during transform
  • 0e44a62 test(fonts): remove duplicate test and add E2E build test for #751
  • ed6295c style(fonts): fix lint and formatting issues in #751 test
  • 73858a1 style: fix formatting in font-google-multiple layout
  • 0676075 refactor(tests): move font-google-multiple to standalone fixture and improve assertions
  • 68883af fix(tests): address PR review feedback on font transform build test
  • 65bb0de chore: update pnpm-lock.yaml for font-google-multiple fixture
  • c636958 fix(tests): handle pre-existing node_modules and correct build output extension in font-google-build test

📊 Changes

6 files changed (+158 additions, -0 deletions)

View changed files

📝 packages/vinext/src/plugins/fonts.ts (+1 -0)
📝 pnpm-lock.yaml (+25 -0)
tests/fixtures/font-google-multiple/app/layout.tsx (+28 -0)
tests/fixtures/font-google-multiple/app/page.tsx (+8 -0)
tests/fixtures/font-google-multiple/package.json (+16 -0)
tests/font-google-build.test.ts (+80 -0)

📄 Description

Summary

The injectSelfHostedCss function was calling s.overwrite() to transform font calls but not adding the call range to overwrittenRanges. Every other s.overwrite() call in the transform hook already tracks its range — this was the only one that didn't. This is a defensive consistency fix that prevents a theoretical double-overwrite if the named-call and member-call regexes ever match overlapping spans.

Note: This does not fix #751. The double-comma bug from #751's original report was already fixed by #719. The remaining open issue on #751 is about missing named exports from the font-google shim at build time — a different problem.

Changes

  • Added overwrittenRanges.push([callStart, callEnd]) after font call transformation in injectSelfHostedCss
  • Added build integration test that exercises the full createBuilder + buildApp() pipeline with multiple Google fonts (Geist + Geist_Mono), asserting that _selfHostedCSS injection appears in the output

Testing

  • All existing font-google tests pass
  • New build integration test verifies both fonts are transformed in the built output

🔄 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/785 **Author:** [@Divkix](https://github.com/Divkix) **Created:** 4/5/2026 **Status:** ✅ Merged **Merged:** 4/9/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/issue-751-next-font-google-transform` --- ### 📝 Commits (8) - [`c92de34`](https://github.com/cloudflare/vinext/commit/c92de3422d38756e401964f46370156c49b1c8ef) fix(plugins): track font call ranges during transform - [`0e44a62`](https://github.com/cloudflare/vinext/commit/0e44a62d9761534a0f4fc0192b8eb0c4784b4b4b) test(fonts): remove duplicate test and add E2E build test for #751 - [`ed6295c`](https://github.com/cloudflare/vinext/commit/ed6295ca7e430e4c5ff78170fdcfd30868782a61) style(fonts): fix lint and formatting issues in #751 test - [`73858a1`](https://github.com/cloudflare/vinext/commit/73858a1d00beb51cff9895c56bdcfd0627665801) style: fix formatting in font-google-multiple layout - [`0676075`](https://github.com/cloudflare/vinext/commit/06760754047968d24ceadd0183bc5fc69a268d29) refactor(tests): move font-google-multiple to standalone fixture and improve assertions - [`68883af`](https://github.com/cloudflare/vinext/commit/68883affda7553dc29e1f62369244b33db51f383) fix(tests): address PR review feedback on font transform build test - [`65bb0de`](https://github.com/cloudflare/vinext/commit/65bb0de1046fd7d98e5b0568c84988f40877f922) chore: update pnpm-lock.yaml for font-google-multiple fixture - [`c636958`](https://github.com/cloudflare/vinext/commit/c6369581f3cfe435451c4779a4def27b052865a1) fix(tests): handle pre-existing node_modules and correct build output extension in font-google-build test ### 📊 Changes **6 files changed** (+158 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/plugins/fonts.ts` (+1 -0) 📝 `pnpm-lock.yaml` (+25 -0) ➕ `tests/fixtures/font-google-multiple/app/layout.tsx` (+28 -0) ➕ `tests/fixtures/font-google-multiple/app/page.tsx` (+8 -0) ➕ `tests/fixtures/font-google-multiple/package.json` (+16 -0) ➕ `tests/font-google-build.test.ts` (+80 -0) </details> ### 📄 Description ## Summary The `injectSelfHostedCss` function was calling `s.overwrite()` to transform font calls but not adding the call range to `overwrittenRanges`. Every other `s.overwrite()` call in the transform hook already tracks its range — this was the only one that didn't. This is a defensive consistency fix that prevents a theoretical double-overwrite if the named-call and member-call regexes ever match overlapping spans. Note: This does **not** fix #751. The double-comma bug from #751's original report was already fixed by #719. The remaining open issue on #751 is about missing named exports from the font-google shim at build time — a different problem. ## Changes - Added `overwrittenRanges.push([callStart, callEnd])` after font call transformation in `injectSelfHostedCss` - Added build integration test that exercises the full `createBuilder + buildApp()` pipeline with multiple Google fonts (Geist + Geist_Mono), asserting that `_selfHostedCSS` injection appears in the output ## Testing - All existing font-google tests pass - New build integration test verifies both fonts are transformed in the built output --- <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:26 +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#845
No description provided.