@utoo/pack 1.4.12-alpha.5 → 1.4.12-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -234,8 +234,19 @@ async function runDev(options, projectPath, rootPath, serverOptions) {
234
234
  : serveOptsBase.hostname;
235
235
  (0, printServerInfo_1.printServerInfo)(scheme, displayHost, serveOptsBase.port);
236
236
  }
237
- const cleanup = () => {
238
- hotReloader.close();
237
+ let cleanupStarted = false;
238
+ const cleanup = async () => {
239
+ if (cleanupStarted) {
240
+ return;
241
+ }
242
+ cleanupStarted = true;
243
+ try {
244
+ await hotReloader.close();
245
+ }
246
+ catch (err) {
247
+ console.error(err);
248
+ process.exit(1);
249
+ }
239
250
  // We always create HTTP/1.1 server (http or https), so closeAllConnections exists; Hono's
240
251
  // ServerType union includes HTTP/2, so TS does not narrow. Use runtime check to satisfy types.
241
252
  if ("closeAllConnections" in server &&
package/cjs/core/hmr.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface HotReloaderInterface {
38
38
  /** Handle a message from a client (JSON string). */
39
39
  handleClientMessage(ws: WSLike, data: string): void;
40
40
  buildFallbackError(): Promise<void>;
41
- close(): void;
41
+ close(): Promise<void>;
42
42
  }
43
43
  export type ChangeSubscriptions = Map<string, Promise<AsyncIterableIterator<TurbopackResult>>>;
44
44
  export type ReadyIds = Set<string>;
package/cjs/core/hmr.js CHANGED
@@ -548,11 +548,11 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
548
548
  async buildFallbackError() {
549
549
  // Not implemented yet.
550
550
  },
551
- close() {
551
+ async close() {
552
552
  closed = true;
553
- void disposeBackgroundWatchSubscriptions();
553
+ const disposePromise = disposeBackgroundWatchSubscriptions();
554
554
  closePromise !== null && closePromise !== void 0 ? closePromise : (closePromise = project
555
- .onExit()
555
+ .shutdown()
556
556
  .catch((err) => {
557
557
  console.error(err);
558
558
  })
@@ -563,6 +563,7 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
563
563
  wsClient.close();
564
564
  }
565
565
  clients.clear();
566
+ await Promise.all([disposePromise, closePromise]);
566
567
  },
567
568
  };
568
569
  handleEntrypointsSubscription().catch((err) => {
@@ -228,8 +228,19 @@ async function runDev(options, projectPath, rootPath, serverOptions) {
228
228
  : serveOptsBase.hostname;
229
229
  printServerInfo(scheme, displayHost, serveOptsBase.port);
230
230
  }
231
- const cleanup = () => {
232
- hotReloader.close();
231
+ let cleanupStarted = false;
232
+ const cleanup = async () => {
233
+ if (cleanupStarted) {
234
+ return;
235
+ }
236
+ cleanupStarted = true;
237
+ try {
238
+ await hotReloader.close();
239
+ }
240
+ catch (err) {
241
+ console.error(err);
242
+ process.exit(1);
243
+ }
233
244
  // We always create HTTP/1.1 server (http or https), so closeAllConnections exists; Hono's
234
245
  // ServerType union includes HTTP/2, so TS does not narrow. Use runtime check to satisfy types.
235
246
  if ("closeAllConnections" in server &&
package/esm/core/hmr.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface HotReloaderInterface {
38
38
  /** Handle a message from a client (JSON string). */
39
39
  handleClientMessage(ws: WSLike, data: string): void;
40
40
  buildFallbackError(): Promise<void>;
41
- close(): void;
41
+ close(): Promise<void>;
42
42
  }
43
43
  export type ChangeSubscriptions = Map<string, Promise<AsyncIterableIterator<TurbopackResult>>>;
44
44
  export type ReadyIds = Set<string>;
package/esm/core/hmr.js CHANGED
@@ -543,11 +543,11 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
543
543
  async buildFallbackError() {
544
544
  // Not implemented yet.
545
545
  },
546
- close() {
546
+ async close() {
547
547
  closed = true;
548
- void disposeBackgroundWatchSubscriptions();
548
+ const disposePromise = disposeBackgroundWatchSubscriptions();
549
549
  closePromise !== null && closePromise !== void 0 ? closePromise : (closePromise = project
550
- .onExit()
550
+ .shutdown()
551
551
  .catch((err) => {
552
552
  console.error(err);
553
553
  })
@@ -558,6 +558,7 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
558
558
  wsClient.close();
559
559
  }
560
560
  clients.clear();
561
+ await Promise.all([disposePromise, closePromise]);
561
562
  },
562
563
  };
563
564
  handleEntrypointsSubscription().catch((err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack",
3
- "version": "1.4.12-alpha.5",
3
+ "version": "1.4.12-alpha.6",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "types": "esm/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "@hono/node-server": "^1.19.11",
42
42
  "@hono/node-ws": "^1.3.0",
43
43
  "@swc/helpers": "0.5.15",
44
- "@utoo/pack-shared": "1.4.12-alpha.5",
44
+ "@utoo/pack-shared": "1.4.12-alpha.6",
45
45
  "domparser-rs": "^0.0.7",
46
46
  "find-up": "4.1.0",
47
47
  "get-port": "5.1.1",
@@ -96,12 +96,12 @@
96
96
  "directory": "packages/pack"
97
97
  },
98
98
  "optionalDependencies": {
99
- "@utoo/pack-darwin-arm64": "1.4.12-alpha.5",
100
- "@utoo/pack-darwin-x64": "1.4.12-alpha.5",
101
- "@utoo/pack-linux-arm64-gnu": "1.4.12-alpha.5",
102
- "@utoo/pack-linux-arm64-musl": "1.4.12-alpha.5",
103
- "@utoo/pack-linux-x64-gnu": "1.4.12-alpha.5",
104
- "@utoo/pack-linux-x64-musl": "1.4.12-alpha.5",
105
- "@utoo/pack-win32-x64-msvc": "1.4.12-alpha.5"
99
+ "@utoo/pack-darwin-arm64": "1.4.12-alpha.6",
100
+ "@utoo/pack-darwin-x64": "1.4.12-alpha.6",
101
+ "@utoo/pack-linux-arm64-gnu": "1.4.12-alpha.6",
102
+ "@utoo/pack-linux-arm64-musl": "1.4.12-alpha.6",
103
+ "@utoo/pack-linux-x64-gnu": "1.4.12-alpha.6",
104
+ "@utoo/pack-linux-x64-musl": "1.4.12-alpha.6",
105
+ "@utoo/pack-win32-x64-msvc": "1.4.12-alpha.6"
106
106
  }
107
107
  }