@knip/language-server 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +11 -0
  2. package/package.json +3 -3
  3. package/src/server.js +11 -7
package/README.md CHANGED
@@ -135,6 +135,17 @@ Example:
135
135
  - [Collect dependency snippets][26]
136
136
  - [Render dependency hover][27]
137
137
 
138
+ ## CLI
139
+
140
+ To run the language server directly from CLI:
141
+
142
+ ```sh
143
+ npx @knip/language-server
144
+ ```
145
+
146
+ Add `--node-ipc`, `--stdio`, `--socket <port>` or `--pipe <name>` to set
147
+ transport (default: `--stdio`).
148
+
138
149
  [1]: https://knip.dev
139
150
  [2]: https://github.com/webpro-nl/knip
140
151
  [3]: https://bsky.app/profile/webpro.nl
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@knip/language-server",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/webpro-nl/knip.git",
7
7
  "directory": "packages/language-server"
8
8
  },
9
- "type": "module",
10
9
  "bin": {
11
10
  "knip-language-server": "./src/cli.js"
12
11
  },
12
+ "type": "module",
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./src/types.d.ts",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "vscode-languageserver": "^9.0.1",
22
22
  "vscode-languageserver-textdocument": "^1.0.12",
23
- "knip": "^5.84.0"
23
+ "knip": "^5.86.0"
24
24
  },
25
25
  "engines": {
26
26
  "node": ">=18.20.0"
package/src/server.js CHANGED
@@ -278,16 +278,20 @@ export class LanguageServer {
278
278
 
279
279
  if (changes.length === 0) return;
280
280
 
281
- const result = await this.session.handleFileChanges(changes);
281
+ try {
282
+ const result = await this.session.handleFileChanges(changes);
282
283
 
283
- if (!result) return;
284
+ if (!result) return;
284
285
 
285
- this.connection.console.log(
286
- `Module graph updated (${Math.floor(result.duration)}ms • ${(result.mem / 1024 / 1024).toFixed(2)}M)`
287
- );
286
+ this.connection.console.log(
287
+ `Module graph updated (${Math.floor(result.duration)}ms • ${(result.mem / 1024 / 1024).toFixed(2)}M)`
288
+ );
288
289
 
289
- const config = await this.getConfig();
290
- this.publishDiagnostics(this.buildDiagnostics(this.session.getIssues().issues, config, this.rules));
290
+ const config = await this.getConfig();
291
+ this.publishDiagnostics(this.buildDiagnostics(this.session.getIssues().issues, config, this.rules));
292
+ } catch (_error) {
293
+ this.connection.console.error(`Error handling file changes: ${_error}`);
294
+ }
291
295
  }
292
296
 
293
297
  /**