fix(language-service): implement realpath to resolve symlinks (#40593)

The `LanguageServiceAdapter` must implement `realpath` in order to resolve
symlinks in `node_modules`.

Local libraries are often symlinked in `node_modules` by adding a local
dependency in `package.json`.

Fix https://github.com/angular/vscode-ng-language-service/issues/1083

PR Close #40593
This commit is contained in:
Keen Yee Liau 2021-01-27 09:17:03 -08:00 committed by Jessica Janiuk
parent 27a818a0e7
commit e43cba5c82
1 changed files with 8 additions and 0 deletions

View File

@ -51,6 +51,14 @@ export class LanguageServiceAdapter implements NgCompilerAdapter {
return this.project.projectService.toCanonicalFileName(fileName);
}
/**
* Return the real path of a symlink. This method is required in order to
* resolve symlinks in node_modules.
*/
realpath(path: string): string {
return this.project.realpath?.(path) ?? path;
}
/**
* readResource() is an Angular-specific method for reading files that are not
* managed by the TS compiler host, namely templates and stylesheets.