From e43cba5c820e9aea83abd99055b85a718ace3436 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Wed, 27 Jan 2021 09:17:03 -0800 Subject: [PATCH] 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 --- packages/language-service/ivy/adapters.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/language-service/ivy/adapters.ts b/packages/language-service/ivy/adapters.ts index 9582177175..28855dd210 100644 --- a/packages/language-service/ivy/adapters.ts +++ b/packages/language-service/ivy/adapters.ts @@ -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.