From b572862d9a7120a4e34872db26dc40587b70ba96 Mon Sep 17 00:00:00 2001 From: Bob Brinks Date: Fri, 3 Feb 2017 10:27:55 +0100 Subject: [PATCH 1/2] Fix for #3875 The problem: duplication of symlinked source files (npm linked sources) in CompilerHost's stats. The solution: resolve these paths before of all Gift of jdavidls --- packages/@ngtools/webpack/src/compiler_host.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/@ngtools/webpack/src/compiler_host.ts b/packages/@ngtools/webpack/src/compiler_host.ts index df8cd1d221b9..f90cfeb54216 100644 --- a/packages/@ngtools/webpack/src/compiler_host.ts +++ b/packages/@ngtools/webpack/src/compiler_host.ts @@ -117,12 +117,15 @@ export class WebpackCompilerHost implements ts.CompilerHost { private _resolve(path: string) { path = this._normalizePath(path); if (path[0] == '.') { - return join(this.getCurrentDirectory(), path); + path = join(this.getCurrentDirectory(), path); } else if (path[0] == '/' || path.match(/^\w:\//)) { - return path; + //return path; } else { - return join(this._basePath, path); + path = join(this._basePath, path); } + if( fs.existsSync(path) ) // FIX symlink duplication in npm linked modules (#3875) + path = fs.realpathSync(path); + return path; } private _setFileContent(fileName: string, content: string) { From 897aa3391a6a1d1011c2c54fdbcdfffe973cdb42 Mon Sep 17 00:00:00 2001 From: Bob Brinks Date: Fri, 3 Feb 2017 10:54:06 +0100 Subject: [PATCH 2/2] Fixed lint issues --- packages/@ngtools/webpack/src/compiler_host.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@ngtools/webpack/src/compiler_host.ts b/packages/@ngtools/webpack/src/compiler_host.ts index f90cfeb54216..2df000556a05 100644 --- a/packages/@ngtools/webpack/src/compiler_host.ts +++ b/packages/@ngtools/webpack/src/compiler_host.ts @@ -119,12 +119,14 @@ export class WebpackCompilerHost implements ts.CompilerHost { if (path[0] == '.') { path = join(this.getCurrentDirectory(), path); } else if (path[0] == '/' || path.match(/^\w:\//)) { - //return path; + // return path; } else { path = join(this._basePath, path); } - if( fs.existsSync(path) ) // FIX symlink duplication in npm linked modules (#3875) + // FIX symlink duplication in npm linked modules (#3875) + if (fs.existsSync(path)) { path = fs.realpathSync(path); + } return path; }