From 7d6f6d62a574b9d6013c1c465140255a72ef6e52 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Fri, 9 Apr 2021 20:50:23 -0700 Subject: [PATCH 1/2] fix(gatsby): webpack warnings are no longer in object format by default --- packages/gatsby/src/commands/build.ts | 3 ++- packages/gatsby/src/services/start-webpack-server.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/commands/build.ts b/packages/gatsby/src/commands/build.ts index 3d99a04f8b517..a08d8e4cf2831 100644 --- a/packages/gatsby/src/commands/build.ts +++ b/packages/gatsby/src/commands/build.ts @@ -128,7 +128,8 @@ module.exports = async function build(program: IBuildArgs): Promise { stats = await buildProductionBundle(program, buildActivityTimer.span) if (stats.hasWarnings()) { - reportWebpackWarnings(stats.compilation.warnings, report) + const rawMessages = stats.toJson({ moduleTrace: false }) + reportWebpackWarnings(rawMessages.warnings, report) } } catch (err) { buildActivityTimer.panic(structureWebpackErrors(Stage.BuildJavascript, err)) diff --git a/packages/gatsby/src/services/start-webpack-server.ts b/packages/gatsby/src/services/start-webpack-server.ts index 6698b31938a8b..e52c4fcbcca80 100644 --- a/packages/gatsby/src/services/start-webpack-server.ts +++ b/packages/gatsby/src/services/start-webpack-server.ts @@ -112,7 +112,8 @@ export async function startWebpackServer({ if (webpackActivity) { if (stats.hasWarnings()) { - reportWebpackWarnings(stats.compilation.warnings, report) + const rawMessages = stats.toJson({ moduleTrace: false }) + reportWebpackWarnings(rawMessages.warnings, report) } if (!isSuccessful) { From e2a17caf3d6900cfe284b2aeaeb31169b7398180 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 12 Apr 2021 09:31:05 -0700 Subject: [PATCH 2/2] Fix (maybe) Typescript errors --- packages/gatsby/src/utils/webpack-error-utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/utils/webpack-error-utils.ts b/packages/gatsby/src/utils/webpack-error-utils.ts index 168ad91b3d901..c01d5b9aef7bb 100644 --- a/packages/gatsby/src/utils/webpack-error-utils.ts +++ b/packages/gatsby/src/utils/webpack-error-utils.ts @@ -1,5 +1,5 @@ import { Reporter } from "gatsby-cli/lib/reporter/reporter" -import { WebpackError, Module, NormalModule } from "webpack" +import { WebpackError, StatsCompilation, Module, NormalModule } from "webpack" import { Stage as StageEnum } from "../commands/types" import formatWebpackMessages from "react-dev-utils/formatWebpackMessages" @@ -145,7 +145,7 @@ export const structureWebpackErrors = ( } export const reportWebpackWarnings = ( - warnings: Array, + warnings: StatsCompilation["warnings"] = [], reporter: Reporter ): void => { const warningMessages = warnings.map(warning => warning.message)