From fa7155a06916e767df4ff6be5726b0c3b0f7d044 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Thu, 12 Oct 2017 12:34:20 +0100 Subject: [PATCH] fix(@ngtools/webpack): fix rebuild speed regression See https://github.com/angular/angular-cli/issues/7995#issuecomment-336036482 for details. Fix regression introduced in https://github.com/angular/angular-cli/pull/7998 --- packages/@ngtools/webpack/src/loader.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/@ngtools/webpack/src/loader.ts b/packages/@ngtools/webpack/src/loader.ts index 711ad8f8dddd..409645738a17 100644 --- a/packages/@ngtools/webpack/src/loader.ts +++ b/packages/@ngtools/webpack/src/loader.ts @@ -568,7 +568,6 @@ export function ngcLoader(this: LoaderContext & { _compilation: any }, source: s .then(() => { timeEnd(timeLabel + '.ngcLoader.AngularCompilerPlugin'); const result = plugin.getFile(sourceFileName); - const dependencies = plugin.getDependencies(sourceFileName); if (result.sourceMap) { // Process sourcemaps for Webpack. @@ -585,7 +584,10 @@ export function ngcLoader(this: LoaderContext & { _compilation: any }, source: s throw new Error('TypeScript compilation failed.'); } - dependencies.forEach(dep => this.addDependency(dep)); + // Dependencies must use system path separator. + const dependencies = plugin.getDependencies(sourceFileName); + dependencies.forEach(dep => this.addDependency(dep.replace(/\//g, path.sep))); + cb(null, result.outputText, result.sourceMap); }) .catch(err => { @@ -646,8 +648,9 @@ export function ngcLoader(this: LoaderContext & { _compilation: any }, source: s _getResourcesUrls(refactor).forEach((url: string) => { this.addDependency(path.resolve(path.dirname(sourceFileName), url)); }); + // Dependencies must use system path separator. _getImports(refactor, compilerOptions, plugin.compilerHost, plugin.moduleResolutionCache) - .forEach((importString: string) => this.addDependency(importString)); + .forEach((dep) => this.addDependency(dep.replace(/\//g, path.sep))); timeEnd(timeLabel + '.ngcLoader.AotPlugin.addDependency'); }) .then(() => {