Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ansible-language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
NotificationHandler,
ProposedFeatures,
TextDocuments,
} from "vscode-languageserver/node";
} from "vscode-languageserver/node.js";
import { AnsibleLanguageService } from "@src/ansibleLanguageService";
import { getUnsupportedError } from "@src/utils/misc";

Expand Down
2 changes: 1 addition & 1 deletion packages/ansible-language-server/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const tsup: Options = {
// "src/services/settingsManager.ts",
],
minify: env === "production",
bundle: env === "production",
bundle: true,
entry: ["src/**/*.ts"],
format: ["esm", "cjs"],
outDir: env === "production" ? "dist" : "lib",
Comment on lines 25 to 29
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

outDir mismatch with extension host lookup path.

bundle is now unconditional, but outDir still switches to lib when NODE_ENV !== "production". Meanwhile src/extension.ts only looks for the workspace server at packages/ansible-language-server/dist/cli.cjs (and run has no fallback at all). Running a plain build/watch without NODE_ENV=production will place artifacts in lib/ and the Extension Development Host will silently fail to find dist/cli.cjs, defeating the PR's stated goal of enabling development from source.

Consider making outDir unconditionally dist, or update the extension to probe both dist/ and lib/.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ansible-language-server/tsup.config.ts` around lines 25 - 29, The
outDir in tsup.config.ts switches to "lib" when NODE_ENV !== "production" which
breaks src/extension.ts and the run lookup that expect
packages/ansible-language-server/dist/cli.cjs; update the build config so
artifacts always go to "dist" (make outDir unconditionally "dist") or
alternatively update src/extension.ts and the run lookup to probe both
"dist/cli.cjs" and "lib/cli.cjs" (check functions/methods that build the path to
cli.cjs in src/extension.ts and the run command) so development builds placed in
lib/ are discovered.

Expand Down
20 changes: 16 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* "stdlib" */
import * as fs from "node:fs";
import * as path from "node:path";
import * as vscode from "vscode";
import { ExtensionContext, extensions, window, workspace } from "vscode";
Expand Down Expand Up @@ -1156,14 +1157,25 @@ const startClient = async (
"dist",
"cli.cjs",
);
const packageServer = path.join(

// For debug mode: prefer workspace server (development) over node_modules (published package)
const workspaceServer = path.join(
context.extensionPath,
"node_modules",
"@ansible",
"packages",
"ansible-language-server",
"dist",
"cli.js",
"cli.cjs",
);
const packageServer = fs.existsSync(workspaceServer)
? workspaceServer
: path.join(
context.extensionPath,
"node_modules",
"@ansible",
"ansible-language-server",
"dist",
"cli.js",
);

// server is run at port 6009 for debugging
const debugOptions = { execArgv: ["--nolazy", "--inspect=6010"] };
Expand Down
Loading