mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #200] Explore Vite transform for next/font/google imports (eliminate generated font catalog) #48
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#48
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?
Originally created by @southpolesteve on GitHub (Feb 28, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/200
Context
PR #57 solved the immediate problem of missing named exports by code-generating all ~1,923 Google Font exports from the Google Fonts API. This works and tree-shakes correctly, but it requires maintaining a generated file that needs periodic re-runs as Google adds new fonts.
How Next.js Does It
Next.js handles
next/font/googleentirely at compile time via an SWC transform:import { Inter } from 'next/font/google'const inter = Inter({...})into a CSS import with query params@font-faceCSS at build timeThe
next/font/googlemodule in Next.js only containsdeclare functiontype stubs. There's zero runtime JavaScript. The font system is a compile-time illusion.Proposed Approach
We could implement a similar pattern using a Vite
transformhook:import { X } from 'next/font/google'in the importing fileimport { createFontLoader } from 'vinext/shims/font-google-base'; const X = createFontLoader("X Name");Benefits
createFontLoadercalls)Considerations
.d.tsdeclarations file (could keep generating that separately)Current State
The generated catalog from PR #57 works well and is the right solution for now. This issue tracks exploring the transform approach as a future improvement.
@yunus25jmi1 commented on GitHub (Mar 5, 2026):
I'm currently working on it.