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 to remove webpack message per error #36452

Merged
merged 3 commits into from Apr 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions packages/next/build/index.ts
Expand Up @@ -739,13 +739,6 @@ export default async function build(
)
}

const breakingChangeIndex = error.indexOf(
'\n\nBREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.'
)
if (breakingChangeIndex >= 0) {
error = error.slice(0, breakingChangeIndex)
}

console.error(error)
console.error()

Expand Down
Expand Up @@ -27,6 +27,9 @@ import stripAnsi from 'next/dist/compiled/strip-ansi'

const friendlySyntaxErrorLabel = 'Syntax error:'

const WEBPACK_BREAKING_CHANGE_POLYFILLS =
'\n\nBREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.'

function isLikelyASyntaxError(message) {
return stripAnsi(message).indexOf(friendlySyntaxErrorLabel) !== -1
}
Expand All @@ -43,10 +46,17 @@ function formatMessage(message, verbose) {
trace.originName
)
)

let body = message.message
const breakingChangeIndex = body.indexOf(WEBPACK_BREAKING_CHANGE_POLYFILLS)
if (breakingChangeIndex >= 0) {
body = body.slice(0, breakingChangeIndex)
}

message =
(message.moduleName ? stripAnsi(message.moduleName) + '\n' : '') +
(message.file ? stripAnsi(message.file) + '\n' : '') +
message.message +
body +
(message.details && verbose ? '\n' + message.details : '') +
(filteredModuleTrace && filteredModuleTrace.length && verbose
? '\n\nImport trace for requested module:' +
Expand Down