Skip to content

Commit 33415c8

Browse files
authored
fix(gatsby): webpack warnings are no longer in object format by default (#30801)
* fix(gatsby): webpack warnings are no longer in object format by default * Fix (maybe) Typescript errors
1 parent 304e585 commit 33415c8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/gatsby/src/commands/build.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {
128128
stats = await buildProductionBundle(program, buildActivityTimer.span)
129129

130130
if (stats.hasWarnings()) {
131-
reportWebpackWarnings(stats.compilation.warnings, report)
131+
const rawMessages = stats.toJson({ moduleTrace: false })
132+
reportWebpackWarnings(rawMessages.warnings, report)
132133
}
133134
} catch (err) {
134135
buildActivityTimer.panic(structureWebpackErrors(Stage.BuildJavascript, err))

packages/gatsby/src/services/start-webpack-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export async function startWebpackServer({
112112

113113
if (webpackActivity) {
114114
if (stats.hasWarnings()) {
115-
reportWebpackWarnings(stats.compilation.warnings, report)
115+
const rawMessages = stats.toJson({ moduleTrace: false })
116+
reportWebpackWarnings(rawMessages.warnings, report)
116117
}
117118

118119
if (!isSuccessful) {

packages/gatsby/src/utils/webpack-error-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Reporter } from "gatsby-cli/lib/reporter/reporter"
2-
import { WebpackError, Module, NormalModule } from "webpack"
2+
import { WebpackError, StatsCompilation, Module, NormalModule } from "webpack"
33
import { Stage as StageEnum } from "../commands/types"
44
import formatWebpackMessages from "react-dev-utils/formatWebpackMessages"
55

@@ -145,7 +145,7 @@ export const structureWebpackErrors = (
145145
}
146146

147147
export const reportWebpackWarnings = (
148-
warnings: Array<WebpackError>,
148+
warnings: StatsCompilation["warnings"] = [],
149149
reporter: Reporter
150150
): void => {
151151
const warningMessages = warnings.map(warning => warning.message)

0 commit comments

Comments
 (0)