mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #656] [MERGED] feat(font): replace generated google font catalog with virtual import rewrites #748
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#748
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/656
Author: @southpolesteve
Created: 3/22/2026
Status: ✅ Merged
Merged: 3/22/2026
Merged by: @southpolesteve
Base:
main← Head:codex/font-google-transform-pr📝 Commits (1)
7fa91cbfeat(font): rewrite next/font/google imports via virtual modules📊 Changes
8 files changed (+473 additions, -2375 deletions)
View changed files
📝
packages/vinext/src/index.ts(+338 -42)📝
packages/vinext/src/shims/font-google-base.ts(+4 -3)➖
packages/vinext/src/shims/font-google.generated.ts(+0 -2251)📝
packages/vinext/src/shims/font-google.ts(+1 -1)📝
packages/vinext/src/shims/next-shims-font-google.generated.d.ts(+1 -0)📝
scripts/generate-google-fonts.js(+1 -17)📝
tests/font-google.test.ts(+116 -56)📝
tests/shims.test.ts(+12 -5)📄 Description
Summary
Closes #200.
This reworks the core idea from #262 by @yunus25jmi1, but switches the implementation to per-import virtual modules instead of local
constrewrites.That keeps the maintenance win of deleting the generated
font-google.generated.tscatalog, while preserving normal ESM semantics for named imports and broadening compatibility for real-world call sites.What Changed
packages/vinext/src/shims/font-google.generated.tsnext/font/googleimports and re-exports to virtual modules that export only the requested fontscreateFontLoaderas a public shim export for direct runtime use and testsfonts.Roboto_Mono(...)next/font/google, not just app source files.d.tsfor IDE autocomplete and typesWhy This Shape
The earlier approach in #262 had a good goal, but converting imports into local
constdeclarations changed module evaluation semantics and dropped compatibility for some import patterns.Using virtual modules avoids the TDZ/hoisting regression for named imports while still removing the giant generated runtime catalog.
Testing
vp test run tests/font-google.test.tsvp test run tests/shims.test.ts -t "next/font/google shim"vp check packages/vinext/src/index.ts packages/vinext/src/shims/font-google.ts packages/vinext/src/shims/font-google-base.ts packages/vinext/src/shims/next-shims-font-google.generated.d.ts scripts/generate-google-fonts.js tests/font-google.test.ts tests/shims.test.tsCredit
Credit to @yunus25jmi1 for the original PR and direction in #262: https://github.com/cloudflare/vinext/pull/262
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.