🔎 Search Terms
"language server", "because only package name is allowed plugin name", "language server plugins"
🕗 Version & Regression Information
This behaviour must be going back to 4.2.2 as per #43124.
⏯ Playground Link
No response
💻 Code
tsconfig.json
{
"compilerOptions": {
"plugins": [
{
"name": "package/lsp"
}
]
}
}🙁 Actual behavior
TypeScript rejects sub-path package plugins, as per:
| if(!pluginConfigEntry.name||parsePackageName(pluginConfigEntry.name).rest){ |
| this.logger.info(`Skipped loading plugin ${pluginConfigEntry.name||JSON.stringify(pluginConfigEntry)} because only package name is allowed plugin name`); |
| return; |
| } |
- and;
| exportfunctionparsePackageName(moduleName: string): {packageName: string;rest: string;}{ |
| letidx=moduleName.indexOf(directorySeparator); |
| if(moduleName[0]==="@"){ |
| idx=moduleName.indexOf(directorySeparator,idx+1); |
| } |
| returnidx===-1 ? {packageName: moduleName,rest: ""} : {packageName: moduleName.slice(0,idx),rest: moduleName.slice(idx+1)}; |
| } |
tsserver log
Info 11 [15:52:00.931] Enabling plugin package/subpath from candidate paths: [...]node_modules/typescript/lib/tsserver.js/../../..
Info 12 [15:52:00.931] Skipped loading plugin package/lsp because only package name is allowed plugin name
🙂 Expected behavior
Plugins are loaded as per either package.json:exports with subfolders specified, or via package/sub-path/package.json or package/sub-path/index.js.
Additional information about the issue
Related issues: #42688 and #42688.
If my understanding is correct, TypeScript only wants to allow packages that:
- have been installed via a package manager, so that opening VSCode without installing doesn't immediately run unauthorised code
- are not relative paths or local code that's checked into a repository
Neither applies to sub-packages. The use-case here is to publish packages that both provide code and an LSP package in one, without splitting this into two packages because of the assertion in TypeScript.
🔎 Search Terms
"language server", "because only package name is allowed plugin name", "language server plugins"
🕗 Version & Regression Information
This behaviour must be going back to 4.2.2 as per #43124.
⏯ Playground Link
No response
💻 Code
tsconfig.json
{ "compilerOptions": { "plugins": [ { "name": "package/lsp" } ] } }🙁 Actual behavior
TypeScript rejects sub-path package plugins, as per:
TypeScript/src/server/editorServices.ts
Lines 4490 to 4493 in 23faef9
TypeScript/src/compiler/moduleNameResolver.ts
Lines 2525 to 2531 in 23faef9
tsserver log
🙂 Expected behavior
Plugins are loaded as per either
package.json:exportswith subfolders specified, or viapackage/sub-path/package.jsonorpackage/sub-path/index.js.Additional information about the issue
Related issues: #42688 and #42688.
If my understanding is correct, TypeScript only wants to allow packages that:
Neither applies to sub-packages. The use-case here is to publish packages that both provide code and an LSP package in one, without splitting this into two packages because of the assertion in TypeScript.