forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
39 lines (34 loc) · 1.27 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as ts from 'typescript/lib/tsserverlibrary';
import {NgLanguageService, PluginConfig} from './api';
interface PluginModule extends ts.server.PluginModule {
create(createInfo: ts.server.PluginCreateInfo): NgLanguageService;
onConfigurationChanged?(config: PluginConfig): void;
}
const factory: ts.server.PluginModuleFactory = (tsModule): PluginModule => {
let plugin: PluginModule;
return {
create(info: ts.server.PluginCreateInfo): NgLanguageService {
plugin = require(`./bundles/language-service.js`)(tsModule);
return plugin.create(info);
},
getExternalFiles(project: ts.server.Project): string[] {
return plugin?.getExternalFiles?.(project) ?? [];
},
onConfigurationChanged(config: PluginConfig): void {
plugin?.onConfigurationChanged?.(config);
},
};
};
/**
* Tsserver expects `@angular/language-service` to provide a factory function
* as the default export of the package. See
* https://github.com/microsoft/TypeScript/blob/f4d0ea6539edb6d8f70b626132d6f9ac1ac4281a/src/server/project.ts#L1611
*/
export = factory;