Skip to content

Commit

Permalink
fix(gatsby): Pass reporter from functions code for reporting warning (#…
Browse files Browse the repository at this point in the history
…31336) (#31363)

* fix(gatsby): Pass reporter from functions code for reporting warning

Also include the file that the warning is for in the message

* Update packages/gatsby/src/internal-plugins/functions/gatsby-node.ts

Co-authored-by: Ward Peeters <ward@coding-tech.com>

Co-authored-by: Ward Peeters <ward@coding-tech.com>
(cherry picked from commit f09fae8)

Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
  • Loading branch information
GatsbyJS Bot and KyleAMathews committed May 11, 2021
1 parent 01de613 commit 4eca6cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -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))
reportWebpackWarnings(rawMessages.warnings, reporter)
}

if (err) return reject(err)
Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby/src/utils/webpack-error-utils.ts
Expand Up @@ -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: [],
Expand Down

0 comments on commit 4eca6cc

Please sign in to comment.