From 7108d9d15d219090edad3fc1987c0f78f6455898 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:55:26 +0200 Subject: [PATCH 1/2] Make UnableToExternalize a warning --- crates/next-core/src/next_server/resolve.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/next-core/src/next_server/resolve.rs b/crates/next-core/src/next_server/resolve.rs index ad0de304dd1e4..69392947c9063 100644 --- a/crates/next-core/src/next_server/resolve.rs +++ b/crates/next-core/src/next_server/resolve.rs @@ -472,7 +472,7 @@ struct UnableToExternalize { impl Issue for UnableToExternalize { #[turbo_tasks::function] fn severity(&self) -> Vc { - IssueSeverity::Error.cell() + IssueSeverity::Warning.cell() } #[turbo_tasks::function] From 6699b97e34cbffa7455c638c7a36f75e7f0b37ca Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:55:44 +0200 Subject: [PATCH 2/2] Output UnableToExternalize even in n_m --- .../next/src/server/dev/turbopack-utils.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/next/src/server/dev/turbopack-utils.ts b/packages/next/src/server/dev/turbopack-utils.ts index be1c11155e207..f5ef19282fe06 100644 --- a/packages/next/src/server/dev/turbopack-utils.ts +++ b/packages/next/src/server/dev/turbopack-utils.ts @@ -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 } @@ -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