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

Turbopack: Make UnableToExternalize a warning #71477

Merged
merged 2 commits into from
Oct 18, 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
2 changes: 1 addition & 1 deletion crates/next-core/src/next_server/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ struct UnableToExternalize {
impl Issue for UnableToExternalize {
#[turbo_tasks::function]
fn severity(&self) -> Vc<IssueSeverity> {
IssueSeverity::Error.cell()
IssueSeverity::Warning.cell()
}

#[turbo_tasks::function]
Expand Down
24 changes: 22 additions & 2 deletions packages/next/src/server/dev/turbopack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,28 @@ export function isWellKnownError(issue: Issue): boolean {
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.
* This mimics behavior of get-page-static-info's warnOnce.
* @param issue
* @returns
*/
function shouldEmitOnceWarning(issue: Issue): boolean {
const { severity, title } = issue
const { severity, title, stage } = issue
if (severity === 'warning' && title.value === 'Invalid page configuration') {
if (onceErrorSet.has(issue)) {
return false
}
onceErrorSet.add(issue)
}
if (
severity === 'warning' &&
stage === 'config' &&
renderStyledStringToErrorAnsi(issue.title).includes("can't be external")
) {
if (onceErrorSet.has(issue)) {
return false
}
onceErrorSet.add(issue)
}

return true
}
Expand All @@ -107,6 +117,16 @@ export function printNonFatalIssue(issue: Issue) {
}

function isNodeModulesIssue(issue: Issue): boolean {
if (issue.severity === 'warning' && issue.stage === 'config') {
// Override for the externalize issue
// `Package foo (serverExternalPackages or default list) can't be external`
if (
renderStyledStringToErrorAnsi(issue.title).includes("can't be external")
) {
return false
}
}

return (
issue.severity === 'warning' &&
issue.filePath.match(/^(?:.*[\\/])?node_modules(?:[\\/].*)?$/) !== null
Expand Down
Loading