Skip to content

Commit 4908558

Browse files
authored
[typespec-vscode] LSP connection failure after dynamically loading a certain library in the package (#8573)
Fix: #8553 . LSP connection failure after dynamically loading a certain library in the package
1 parent 33a84a2 commit 4908558

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
3+
changeKind: fix
4+
packages:
5+
- "@typespec/compiler"
6+
---
7+
8+
LSP connection failure after dynamically loading a certain library in the package

packages/compiler/src/server/lib-provider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ export class LibraryProvider {
5757
const data = await pkg.getPackageJsonData();
5858
// don't add to cache when failing to load package.json which is unexpected
5959
if (!data) return false;
60+
// Only check dependencies and peerDependencies for @typespec/compiler and exclude devDependencies
61+
// to further limit the libraries to load and avoid potential issues cause by loading random libraries.
62+
// TODO: add more filter condition when needed
6063
if (
61-
(data.devDependencies && data.devDependencies["@typespec/compiler"]) ||
64+
(data.peerDependencies && data.peerDependencies["@typespec/compiler"]) ||
6265
(data.dependencies && data.dependencies["@typespec/compiler"])
6366
) {
6467
const exports = await pkg.getModuleExports();

0 commit comments

Comments
 (0)