mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-31 08:07:10 -05:00
Enable TS Server plugins on web (#47377)
* Prototype TS plugins on web This prototype allows service plugins to be loaded on web TSServer Main changes: - Adds a new host entryPoint called `importServicePlugin` for overriding how plugins can be loaded. This may be async - Implement `importServicePlugin` for webServer - The web server plugin implementation looks for a `browser` field in the plugin's `package.json` - It then uses `import(...)` to load the plugin (the plugin source must be compiled to support being loaded as a module) * use default export from plugins This more or less matches how node plugins expect the plugin module to be an init function * Allow configure plugin requests against any web servers in partial semantic mode * Addressing some comments - Use result value instead of try/catch (`ImportPluginResult`) - Add awaits - Add logging * add tsserverWeb to patch in dynamic import * Remove eval We should throw instead when dynamic import is not implemented * Ensure dynamically imported plugins are loaded in the correct order * Add tests for async service plugin timing * Update src/server/editorServices.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> * Partial PR feedback * Rename tsserverWeb to dynamicImportCompat * Additional PR feedback Co-authored-by: Ron Buckton <ron.buckton@microsoft.com> Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
3
src/dynamicImportCompat/dynamicImportCompat.ts
Normal file
3
src/dynamicImportCompat/dynamicImportCompat.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace ts.server {
|
||||
export const dynamicImport = (id: string) => import(id);
|
||||
}
|
||||
16
src/dynamicImportCompat/tsconfig.json
Normal file
16
src/dynamicImportCompat/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"extends": "../tsconfig-library-base",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../built/local",
|
||||
"rootDir": ".",
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"lib": ["esnext"],
|
||||
"declaration": false,
|
||||
"sourceMap": true,
|
||||
"tsBuildInfoFile": "../../built/local/dynamicImportCompat.tsbuildinfo"
|
||||
},
|
||||
"files": [
|
||||
"dynamicImportCompat.ts",
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user