AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack Crashes In Pages/_App.Tsx When Next/Font Is Imported

Turbopack incorrectly reports 'Global CSS cannot be imported from files other than your Custom <App>' when pages/_app.tsx imports both a global CSS file and a font from next/font/google, even though _app.tsx is the custom app. The issue occurs only with the combination; removing either import resolves the error.

highConfidence 75%Next.jsAffected V16.2.4Affected V16.3.0-Canary.2

Origin Analysis

Turbopack's global CSS import validation misclassifies the custom _app module when it contains an import from next/font. The presence of the font import likely triggers a transformation or module splitting that causes the global CSS import to be attributed to a different internal module, so the validation rule no longer recognizes the file as the custom App. This is a defect in Turbopack's module classification for global CSS imports when next/font is used.
1. Create pages/_app.tsx with import '../styles/globals.css' and import { Geist_Mono } from 'next/font/google' and use the font. 2. Run next build --turbopack or next dev --turbopack. 3. Observe the error 'Global CSS cannot be imported from files other than your Custom <App>'.

Fixing Code Block

Edge Case Audit

This is a workaround, not an official fix. The underlying Turbopack bug persists and may resurface if next/font is later imported directly in a file that also imports global CSS. The workaround is simple and should not introduce side effects, but it slightly changes code organization. For rollback, simply revert the changes and wait for a patched Next.js version. The workaround is stable in concurrent and multi-threaded build environments because it only involves module splitting.

Ecosystem Topology