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)

* 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>
  • Loading branch information
KyleAMathews and wardpeet authored May 11, 2021
1 parent c1f365a commit f09fae8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 f09fae8

Please sign in to comment.