Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
There was a problem hiding this comment.
Greptile Summary
This PR addresses middleware-related issues with locale detection during Static Site Generation (SSG) in Next.js applications using General Translation. The core problem being fixed is that SSG disrupts locale resolution because Next.js request APIs (headers() and cookies()) are not available during build time.
The changes introduce several key improvements:
-
Custom
getLocaleSupport: Enables users to provide their own locale detection logic for SSG scenarios through a new configuration option and webpack aliasing system. -
Version-Aware Next.js Compatibility: Implements detection logic for different Next.js versions (15.1-15.4 uses
unstable_rootParams, 15.5+ uses experimentalnext/root-params) to handle the evolving root parameters API. -
Enhanced Error Handling: Adds specific error messages that guide users to SSG documentation when locale determination fails, replacing generic errors with actionable guidance.
-
Request Access Detection: Introduces utility functions to detect when Next.js request APIs are available before attempting to use them, preventing crashes during static generation.
-
Documentation Updates: Adds comprehensive SSG documentation with version-specific implementation examples for custom locale resolution.
The solution maintains backward compatibility while providing a clear upgrade path for users experiencing locale detection issues in SSG environments. The changes integrate across multiple packages (next, docs) and include proper TypeScript support and webpack configuration.
Confidence score: 2/5
- This PR addresses a legitimate issue but contains several implementation problems that could cause runtime failures
- Score lowered due to critical logic errors in version comparison, potential silent failures in async imports, and inconsistent locale validation paths
- Pay close attention to
packages/next/src/plugin/getStableNextVersionInfo.tsandpackages/next/src/next/detectRequestAccess.tsfor logic errors
9 files reviewed, 8 comments
No description provided.