Skip to content

Commit b9947f6

Browse files
authored
perf: use dynamic import for node:dns (#5312)
1 parent fa0f574 commit b9947f6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/core/src/server/helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ export function getServerTerminator(
469469
server: Server | Http2SecureServer,
470470
): () => Promise<void> {
471471
let listened = false;
472-
const pendingSockets = new Set<net.Socket>();
472+
const pendingSockets = new Set<Socket>();
473473

474-
const onConnection = (socket: net.Socket) => {
474+
const onConnection = (socket: Socket) => {
475475
pendingSockets.add(socket);
476476
socket.on('close', () => {
477477
pendingSockets.delete(socket);

packages/core/src/server/hmrFallback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { promises as dns } from 'node:dns';
21
import type { DevConfig, ServerConfig } from '../types/config';
32
import { isWildcardHost } from './helper';
43

@@ -12,6 +11,7 @@ import { isWildcardHost } from './helper';
1211
export async function getLocalhostResolvedAddress(): Promise<
1312
string | undefined
1413
> {
14+
const { promises: dns } = await import('node:dns');
1515
const [defaultLookup, explicitLookup] = await Promise.all([
1616
dns.lookup('localhost'),
1717
dns.lookup('localhost', { verbatim: true }),

0 commit comments

Comments
 (0)