Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(page-static-info): refine warning message to emit once #65091

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ impl CustomTransformer for NextPageStaticInfo {
messages.push(format!("- `export const preferredRegion = {}`", regions));
}

messages.push("Visit https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config for more information.".to_string());

PageStaticInfoIssue {
file_path: ctx.file_path,
messages,
Expand Down
21 changes: 20 additions & 1 deletion packages/next/src/server/dev/turbopack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,29 @@ export function isWellKnownError(issue: Issue): boolean {
return false
}

const onceErrorSet = new Set()
/**
* Check if given issue is a warning to be display only once.
* This miimics behavior of get-page-static-info's warnOnce.
* @param issue
* @returns
*/
function shouldEmitOnceWarning(issue: Issue): boolean {
const { severity, title } = issue
if (severity === 'warning' && title.value === 'Invalid page configuration') {
if (onceErrorSet.has(issue)) {
return false
}
onceErrorSet.add(issue)
}

return true
}

/// Print out an issue to the console which should not block
/// the build by throwing out or blocking error overlay.
export function printNonFatalIssue(issue: Issue) {
if (isRelevantWarning(issue)) {
if (isRelevantWarning(issue) && shouldEmitOnceWarning(issue)) {
Log.warn(formatIssue(issue))
}
}
Expand Down
Loading