diff --git a/packages/angular_devkit/build_angular/BUILD.bazel b/packages/angular_devkit/build_angular/BUILD.bazel index 43d70d4bc2eb..3428cb23d4d9 100644 --- a/packages/angular_devkit/build_angular/BUILD.bazel +++ b/packages/angular_devkit/build_angular/BUILD.bazel @@ -340,6 +340,7 @@ LARGE_SPECS = { ], }, "browser-esbuild": { + "shards": 10, "extra_deps": [ "@npm//buffer", ], diff --git a/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts b/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts index 53d6dc8a4d4e..3a07f9004671 100644 --- a/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts +++ b/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts @@ -148,7 +148,14 @@ export async function* serveWithVite( yield { success: true, port: listeningAddress?.port } as unknown as DevServerBuilderOutput; } - await server?.close(); + if (server) { + let deferred: () => void; + context.addTeardown(async () => { + await server?.close(); + deferred?.(); + }); + await new Promise((resolve) => (deferred = resolve)); + } } async function setupServer(