Skip to content

Commit 34908a3

Browse files
committed
fix(@angular/build): lazy load Node.js inspector for dev server
The Node.js inspector will now only be imported if SSR is enabled and the `inspect` option is used. This prevents potential failures when a custom Node.js binary build is used that has not enabled inspector usage. While this is not common, loading the inspector on demand is a minimal change that also avoids loading code that will not be used for the majority of development server usage.
1 parent c4fa7b6 commit 34908a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/angular/build/src/builders/dev-server/vite-server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type { BuilderContext } from '@angular-devkit/architect';
1010
import type { Plugin } from 'esbuild';
1111
import assert from 'node:assert';
1212
import { readFile } from 'node:fs/promises';
13-
import inspector from 'node:inspector';
1413
import { builtinModules } from 'node:module';
1514
import { join } from 'node:path';
1615
import type { Connect, DepOptimizationConfig, InlineConfig, ViteDevServer } from 'vite';
@@ -275,6 +274,7 @@ export async function* serveWithVite(
275274

276275
if (browserOptions.ssr && serverOptions.inspect) {
277276
const { host, port } = serverOptions.inspect as { host?: string; port?: number };
277+
const { default: inspector } = await import('node:inspector');
278278
inspector.open(port, host, true);
279279
context.addTeardown(() => inspector.close());
280280
}

0 commit comments

Comments
 (0)