mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Rename API to importPlugin (#50554)
* Rename API to importPlugin * Make it internal too
This commit is contained in:
@@ -4068,7 +4068,7 @@ namespace ts.server {
|
||||
|
||||
/*@internal*/
|
||||
requestEnablePlugin(project: Project, pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map<any> | undefined) {
|
||||
if (!this.host.importServicePlugin && !this.host.require) {
|
||||
if (!this.host.importPlugin && !this.host.require) {
|
||||
this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
||||
return;
|
||||
}
|
||||
@@ -4080,7 +4080,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
// If the host supports dynamic import, begin enabling the plugin asynchronously.
|
||||
if (this.host.importServicePlugin) {
|
||||
if (this.host.importPlugin) {
|
||||
const importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
||||
this.pendingPluginEnablements ??= new Map();
|
||||
let promises = this.pendingPluginEnablements.get(project);
|
||||
|
||||
@@ -256,12 +256,12 @@ namespace ts.server {
|
||||
|
||||
/*@internal*/
|
||||
public static async importServicePluginAsync(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void, logErrors?: (message: string) => void): Promise<{} | undefined> {
|
||||
Debug.assertIsDefined(host.importServicePlugin);
|
||||
Debug.assertIsDefined(host.importPlugin);
|
||||
const resolvedPath = combinePaths(initialDir, "node_modules");
|
||||
log(`Dynamically importing ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`);
|
||||
let result: ModuleImportResult;
|
||||
try {
|
||||
result = await host.importServicePlugin(resolvedPath, moduleName);
|
||||
result = await host.importPlugin(resolvedPath, moduleName);
|
||||
}
|
||||
catch (e) {
|
||||
result = { module: undefined, error: e };
|
||||
@@ -1607,7 +1607,7 @@ namespace ts.server {
|
||||
protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map<any> | undefined): void {
|
||||
const host = this.projectService.host;
|
||||
|
||||
if (!host.require && !host.importServicePlugin) {
|
||||
if (!host.require && !host.importPlugin) {
|
||||
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
||||
return;
|
||||
}
|
||||
@@ -1658,7 +1658,7 @@ namespace ts.server {
|
||||
*/
|
||||
/*@internal*/
|
||||
async beginEnablePluginAsync(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map<any> | undefined): Promise<BeginEnablePluginResult> {
|
||||
Debug.assertIsDefined(this.projectService.host.importServicePlugin);
|
||||
Debug.assertIsDefined(this.projectService.host.importPlugin);
|
||||
|
||||
let errorLogs: string[] | undefined;
|
||||
const log = (message: string) => this.projectService.logger.info(message);
|
||||
@@ -2522,8 +2522,7 @@ namespace ts.server {
|
||||
/*@internal*/
|
||||
enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: ESMap<string, any> | undefined): void {
|
||||
const host = this.projectService.host;
|
||||
|
||||
if (!host.require && !host.importServicePlugin) {
|
||||
if (!host.require && !host.importPlugin) {
|
||||
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ declare namespace ts.server {
|
||||
gc?(): void;
|
||||
trace?(s: string): void;
|
||||
require?(initialPath: string, moduleName: string): ModuleImportResult;
|
||||
importServicePlugin?(root: string, moduleName: string): Promise<ModuleImportResult>;
|
||||
/*@internal*/
|
||||
importPlugin?(root: string, moduleName: string): Promise<ModuleImportResult>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user