Skip to content

Commit

Permalink
fix: using new dev server API for v4 (#2886)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Aug 13, 2021
1 parent a4c83e9 commit f66d01f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions packages/serve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ class ServeCommand {
process.stdin.on("end", () => {
Promise.all(
servers.map((server) => {
if (typeof server.stop === "function") {
return server.stop();
}

// TODO remove in the next major release
return new Promise<void>((resolve) => {
server.close(() => {
resolve();
Expand Down Expand Up @@ -333,15 +338,20 @@ class ServeCommand {
server = new DevServer(compiler, devServerOptions);
}

server.listen(
devServerOptions.port,
devServerOptions.host,
(error): void => {
if (error) {
throw error;
}
},
);
if (typeof server.start === "function") {
await server.start();
} else {
// TODO remove in the next major release
server.listen(
devServerOptions.port,
devServerOptions.host,
(error): void => {
if (error) {
throw error;
}
},
);
}

servers.push(server);
} catch (error) {
Expand Down

0 comments on commit f66d01f

Please sign in to comment.