Skip to content

Commit 9c5ebee

Browse files
fix: webpack v4 compatibility
1 parent b1ae0b3 commit 9c5ebee

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/Server.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,10 +1130,15 @@ class Server {
11301130
needForceShutdown = true;
11311131

11321132
this.stopCallback(() => {
1133-
this.compiler.close(() => {
1133+
if (this.compiler.close) {
1134+
this.compiler.close(() => {
1135+
// eslint-disable-next-line no-process-exit
1136+
process.exit();
1137+
});
1138+
} else {
11341139
// eslint-disable-next-line no-process-exit
11351140
process.exit();
1136-
});
1141+
}
11371142
});
11381143
});
11391144
});

test/server/setupExitSignals-option.test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ describe("setupExitSignals option", () => {
3737
.spyOn(process.stdin, "resume")
3838
.mockImplementation(() => {});
3939
stopCallbackSpy = jest.spyOn(server, "stopCallback");
40-
closeCallbackSpy = jest.spyOn(server.compiler, "close");
40+
41+
if (server.compiler.close) {
42+
closeCallbackSpy = jest.spyOn(server.compiler, "close");
43+
}
4144
});
4245

4346
afterEach(async () => {
@@ -58,7 +61,10 @@ describe("setupExitSignals option", () => {
5861
const interval = setInterval(() => {
5962
if (doExit) {
6063
expect(stopCallbackSpy.mock.calls.length).toEqual(1);
61-
expect(closeCallbackSpy.mock.calls.length).toEqual(1);
64+
65+
if (server.compiler.close) {
66+
expect(closeCallbackSpy.mock.calls.length).toEqual(1);
67+
}
6268

6369
clearInterval(interval);
6470

0 commit comments

Comments
 (0)