Skip to content

Commit aa4990a

Browse files
committed
fix(migrations): fix LS server resolve with schematics encapsulation
1 parent 46fa19e commit aa4990a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

projects/igniteui-angular/migrations/common/ServerHost.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Tree } from '@angular-devkit/schematics';
22
import * as pathFs from 'path';
33
import * as ts from 'typescript/lib/tsserverlibrary';
44
import { CUSTOM_TS_PLUGIN_NAME, CUSTOM_TS_PLUGIN_PATH } from './tsUtils';
5+
import { createRequire } from 'module';
56

67
/**
78
* Language server host is responsible for **most** of the FS operations / checks
@@ -11,6 +12,8 @@ export class ServerHost implements ts.server.ServerHost {
1112
public readonly args: string[];
1213
public readonly newLine: string;
1314
public readonly useCaseSensitiveFileNames: boolean;
15+
/** Cached because Angular schematics encapsulation's customRequire doesn't provide `resolve` */
16+
private nativeRequire = createRequire(__filename);
1417

1518
constructor(private host: Tree) {
1619
this.args = ts.sys.args;
@@ -126,7 +129,7 @@ export class ServerHost implements ts.server.ServerHost {
126129
moduleName = CUSTOM_TS_PLUGIN_PATH;
127130
paths.push(__dirname);
128131
}
129-
const modulePath = require.resolve(moduleName, { paths });
132+
const modulePath = this.nativeRequire.resolve(moduleName, { paths });
130133
return {
131134
module: require(modulePath),
132135
error: undefined,

0 commit comments

Comments
 (0)