From 09fd5a9eaad251942099b7d1a0d61f1313338d9c Mon Sep 17 00:00:00 2001 From: lucygramley Date: Wed, 3 Jun 2026 10:59:59 -0700 Subject: [PATCH 1/2] fix: use DI for vscode API in nodeLauncher instead of direct import nodeLauncher.ts was directly importing 'vscode', which causes both a build error (esbuild can't resolve it) and a runtime error (module doesn't exist outside VS Code) for standalone server bundles like vsDebugServerBundle. Switch to the established pattern used elsewhere in the codebase (e.g. defaultBrowserProvider.ts, nodeBinaryProvider.ts): - Use 'import type' so no require() is emitted at runtime - Inject the vscode API via @optional() @inject(VSCodeApi) - Guard usage with an undefined check for non-VS Code contexts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/targets/node/nodeLauncher.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/targets/node/nodeLauncher.ts b/src/targets/node/nodeLauncher.ts index 9bf4027aa..ddb218b28 100644 --- a/src/targets/node/nodeLauncher.ts +++ b/src/targets/node/nodeLauncher.ts @@ -2,9 +2,9 @@ * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ -import { inject, injectable, multiInject } from 'inversify'; +import { inject, injectable, multiInject, optional } from 'inversify'; import { extname, resolve } from 'path'; -import * as vscode from 'vscode'; +import type * as vscodeType from 'vscode'; import { IBreakpointsPredictor } from '../../adapter/breakpointPredictor'; import { IPortLeaseTracker } from '../../adapter/portLeaseTracker'; import Cdp from '../../cdp/api'; @@ -16,6 +16,7 @@ import { fixDriveLetterAndSlashes } from '../../common/pathUtils'; import { delay } from '../../common/promiseUtil'; import { absolutePathToFileUrl, urlToRegex } from '../../common/urlUtils'; import { AnyLaunchConfiguration, INodeLaunchConfiguration } from '../../configuration'; +import { VSCodeApi } from '../../ioc-extras'; import { fixInspectFlags } from '../../ui/configurationUtils'; import { retryGetNodeEndpoint } from '../browser/spawn/endpoints'; import { ISourcePathResolverFactory } from '../sourcePathResolverFactory'; @@ -77,6 +78,7 @@ export class NodeLauncher extends NodeLauncherBase { @inject(IPackageJsonProvider) private readonly packageJson: IPackageJsonProvider, @inject(ISourcePathResolverFactory) pathResolverFactory: ISourcePathResolverFactory, @inject(IPortLeaseTracker) portLeaseTracker: IPortLeaseTracker, + @optional() @inject(VSCodeApi) private readonly vscode?: typeof vscodeType, ) { super(pathProvider, logger, portLeaseTracker, pathResolverFactory); } @@ -313,7 +315,11 @@ export class NodeLauncher extends NodeLauncherBase { return targetProgram; } - const resolve = readConfig(vscode.workspace, Configuration.ResolveDebugEntrypoint); + if (!this.vscode) { + return targetProgram; + } + + const resolve = readConfig(this.vscode.workspace, Configuration.ResolveDebugEntrypoint); if (!resolve) { return targetProgram; } From 83dbd3c0897216fa3a60dc2eff10448c63eb40e9 Mon Sep 17 00:00:00 2001 From: lucygramley Date: Wed, 3 Jun 2026 15:13:13 -0700 Subject: [PATCH 2/2] Update src/targets/node/nodeLauncher.ts Co-authored-by: Connor Peet --- src/targets/node/nodeLauncher.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/targets/node/nodeLauncher.ts b/src/targets/node/nodeLauncher.ts index ddb218b28..72cd52ca9 100644 --- a/src/targets/node/nodeLauncher.ts +++ b/src/targets/node/nodeLauncher.ts @@ -315,11 +315,7 @@ export class NodeLauncher extends NodeLauncherBase { return targetProgram; } - if (!this.vscode) { - return targetProgram; - } - - const resolve = readConfig(this.vscode.workspace, Configuration.ResolveDebugEntrypoint); + const resolve = this.vscode ? readConfig(this.vscode.workspace, Configuration.ResolveDebugEntrypoint) : true; if (!resolve) { return targetProgram; }