From 429ba0f3f01bccd5dd0533c1b7788da884a41ea9 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Fri, 7 May 2021 16:38:09 -0700 Subject: [PATCH 1/2] fix(gatsby): Pass reporter from functions code for reporting warning Also include the file that the warning is for in the message --- packages/gatsby/src/internal-plugins/functions/gatsby-node.ts | 2 +- packages/gatsby/src/utils/webpack-error-utils.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts b/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts index 7c11342c90888..306ae88f9b8cf 100644 --- a/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts +++ b/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts @@ -220,7 +220,7 @@ export async function onPreBootstrap({ function callback(err, stats): any { const rawMessages = stats.toJson({ moduleTrace: false }) if (rawMessages.warnings.length > 0) { - reporter.warn(reportWebpackWarnings(rawMessages.warnings)) + reporter.warn(reportWebpackWarnings(rawMessages.warnings, reporter)) } if (err) return reject(err) diff --git a/packages/gatsby/src/utils/webpack-error-utils.ts b/packages/gatsby/src/utils/webpack-error-utils.ts index c01d5b9aef7bb..6c00bae073297 100644 --- a/packages/gatsby/src/utils/webpack-error-utils.ts +++ b/packages/gatsby/src/utils/webpack-error-utils.ts @@ -148,7 +148,9 @@ export const reportWebpackWarnings = ( warnings: StatsCompilation["warnings"] = [], reporter: Reporter ): void => { - const warningMessages = warnings.map(warning => warning.message) + const warningMessages = warnings.map( + warning => `${warning.moduleName}\n\n${warning.message}` + ) formatWebpackMessages({ errors: [], From acd854a09812c8d1f968e815ba3aab084a840032 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 10 May 2021 15:09:01 -0700 Subject: [PATCH 2/2] Update packages/gatsby/src/internal-plugins/functions/gatsby-node.ts Co-authored-by: Ward Peeters --- packages/gatsby/src/internal-plugins/functions/gatsby-node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts b/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts index 306ae88f9b8cf..ca5506df6906d 100644 --- a/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts +++ b/packages/gatsby/src/internal-plugins/functions/gatsby-node.ts @@ -220,7 +220,7 @@ export async function onPreBootstrap({ function callback(err, stats): any { const rawMessages = stats.toJson({ moduleTrace: false }) if (rawMessages.warnings.length > 0) { - reporter.warn(reportWebpackWarnings(rawMessages.warnings, reporter)) + reportWebpackWarnings(rawMessages.warnings, reporter) } if (err) return reject(err)