Skip to content

Commit a956da4

Browse files
committed
types: update types for webpack-dev-middleware@5
1 parent 7a350ee commit a956da4

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { showExperimentNotices } from "../utils/show-experiment-notice"
1313
import { printInstructions } from "../utils/print-instructions"
1414
import { prepareUrls } from "../utils/prepare-urls"
15-
import { startServer, IWebpackWatchingPauseResume } from "../utils/start-server"
15+
import { startServer, WebpackWatching } from "../utils/start-server"
1616
import { WebsocketManager } from "../utils/websocket-manager"
1717
import { IBuildContext } from "./"
1818
import {
@@ -29,7 +29,7 @@ export async function startWebpackServer({
2929
}: Partial<IBuildContext>): Promise<{
3030
compiler: Compiler
3131
websocketManager: WebsocketManager
32-
webpackWatching: IWebpackWatchingPauseResume
32+
webpackWatching: WebpackWatching
3333
}> {
3434
if (!program || !app || !store) {
3535
report.panic(`Missing required params`)

packages/gatsby/src/services/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { GatsbyWorkerPool } from "../utils/worker/pool"
1010
import { Actor, AnyEventObject } from "xstate"
1111
import { Compiler } from "webpack"
1212
import { WebsocketManager } from "../utils/websocket-manager"
13-
import { IWebpackWatchingPauseResume } from "../utils/start-server"
13+
import { type WebpackWatching } from "../utils/start-server"
1414

1515
type Reporter = typeof reporter
1616

@@ -46,7 +46,7 @@ export interface IBuildContext {
4646
nodeMutationBatch?: Array<IMutationAction>
4747
compiler?: Compiler
4848
websocketManager?: WebsocketManager
49-
webpackWatching?: IWebpackWatchingPauseResume
49+
webpackWatching?: WebpackWatching
5050
webpackListener?: Actor<unknown, AnyEventObject>
5151
queryFilesDirty?: boolean
5252
sourceFilesDirty?: boolean

packages/gatsby/src/utils/start-server.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import webpackHotMiddleware from "@gatsbyjs/webpack-hot-middleware"
2-
import webpackDevMiddleware from "webpack-dev-middleware"
2+
import webpackDevMiddleware, { type Watching } from "webpack-dev-middleware"
33
import got, { Method } from "got"
44
import webpack, { Compilation } from "webpack"
55
import express from "express"
@@ -54,18 +54,15 @@ import { isFileInsideCompilations } from "./webpack/utils/is-file-inside-compila
5454

5555
type ActivityTracker = any // TODO: Replace this with proper type once reporter is typed
5656

57+
export type WebpackWatching = NonNullable<Watching>
58+
5759
interface IServer {
5860
compiler: webpack.Compiler
5961
listener: http.Server | https.Server
6062
webpackActivity: ActivityTracker
6163
websocketManager: WebsocketManager
6264
workerPool: WorkerPool.GatsbyWorkerPool
63-
webpackWatching: IWebpackWatchingPauseResume
64-
}
65-
66-
export interface IWebpackWatchingPauseResume {
67-
suspend: () => void
68-
resume: () => void
65+
webpackWatching: WebpackWatching
6966
}
7067

7168
export async function startServer(
@@ -895,6 +892,7 @@ export async function startServer(
895892
webpackActivity,
896893
websocketManager,
897894
workerPool,
898-
webpackWatching: webpackDevMiddlewareInstance.context.watching,
895+
webpackWatching: webpackDevMiddlewareInstance.context
896+
.watching as WebpackWatching,
899897
}
900898
}

0 commit comments

Comments
 (0)