next.js
0329a7e2 - fix(turbopack): Allow google font fetch errors to propagate when in production (#79999)

Commit
323 days ago
fix(turbopack): Allow google font fetch errors to propagate when in production (#79999) ## Fail Google Fonts in Production Builds When Fetch Fails ### What? This PR changes the behavior of Google Fonts in Next.js to properly fail production builds when font fetching fails, while still allowing development to continue with fallback fonts. ### Why? Previously, font fetch failures were only logged as warnings but didn't stop production builds. This could lead to production deployments with missing fonts, creating a poor user experience. Development mode should be more forgiving to allow work to continue offline. ### How? - Added `is_dev_mode()` method to the `ChunkingContext` trait to determine the current environment - Modified the Google font fetching logic to: - In development: Show a warning and use fallback fonts when fetching fails - In production: Throw an error that fails the build when fetching fails - Passed the execution context to the font file replacer to access the chunking context This ensures that production builds will fail fast when font resources can't be fetched, while development builds can continue with appropriate fallbacks. Fixes #PACK-4667 ### Future Hopes I would hope to eventually expose an enum for the build mode rather than just a boolean flag like I have here. I started going down that path for this PR, but it was expanding the scope significantly of what would have to be done, so I have left it as a bool to fix this problem.
Author
Parents
Loading