Skip to content

[WIP] Fix pre-transform error with next/fonts/google in monorepo#103

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/fix-pre-transform-error
Draft

[WIP] Fix pre-transform error with next/fonts/google in monorepo#103
Copilot wants to merge 1 commit intomainfrom
copilot/fix-pre-transform-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

  • Understand the issue: Pre-transform error with next/font/google in monorepo packages
  • Fix the font plugin to correctly resolve font file paths in monorepo packages
  • Fix the \0 virtual module prefix handling in the load hook
  • Add/update tests if applicable
  • Run existing tests to validate changes
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] Pre-transform error with next/fonts/google in monorepo package</issue_title>
<issue_description>### Describe the bug

I've setup a monorepo and located all my UI components in a shared package, packages/ui. This includes a utility class for importing fonts with next/font/google at packages/ui/lib/fonts.ts.

On startup, Storybook fails with the following error:

7:13:43 AM [vite] (client) Pre-transform error: Failed to load url
packages/ui/lib/fonts.ts","import":"Inter","arguments":[{"subsets":["latin"],"display":"swap","variable":"--font-
inter"}],"variableName":"inter"} (resolved id: packages/ui/lib/fonts.ts","import":"Inter","arguments":[{"subsets"
["latin"],"display":"swap","variable":"--font-inter"}],"variableName":"inter"}) in /<omitted>/sb-next-vite-
fonts/packages/ui/lib/fonts.ts. Does the file exist?

If I move the fonts.ts file into the same project as Storybook, e.g. at apps/storybook/lib/fonts.ts, then it works as expected.

Steps to reproduce the behavior

  1. git clone https://github.com/jcarlson/sb-next-vite-fonts
  2. cd sb-next-vite-fonts && pnpm install
  3. cd apps/storybook && pnpm run storybook
  4. See error

Expected behavior

Next.js Font optimization should work correctly through library packages.

Environment

  • OS: MacOS 15.6.1
  • Node.js version: v22.19.0
  • PNPM version: v10.11.0

Additional context

Bare bones repository to replicate this issue can be found here:
https://github.com/jcarlson/sb-next-vite-fonts
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Pre-transform error with next/fonts/google in monorepo package

2 participants