From 472012d38e1d1601720d186536ec4e61e51ae293 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Mon, 3 Oct 2016 11:07:35 -0700 Subject: [PATCH] feat(aot): do not populate the whole filesystem if nothing changed since the last call. --- packages/webpack/src/compiler_host.ts | 8 ++++++++ packages/webpack/src/plugin.ts | 2 +- tests/e2e/tests/test/e2e.ts | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/webpack/src/compiler_host.ts b/packages/webpack/src/compiler_host.ts index a65c46053896..a97e0c57d265 100644 --- a/packages/webpack/src/compiler_host.ts +++ b/packages/webpack/src/compiler_host.ts @@ -91,6 +91,7 @@ export class WebpackCompilerHost implements ts.CompilerHost { private _delegate: ts.CompilerHost; private _files: {[path: string]: VirtualFileStats} = Object.create(null); private _directories: {[path: string]: VirtualDirStats} = Object.create(null); + private _changed = false; constructor(private _options: ts.CompilerOptions, private _setParentNodes = true) { this._delegate = ts.createCompilerHost(this._options, this._setParentNodes); @@ -104,10 +105,15 @@ export class WebpackCompilerHost implements ts.CompilerHost { this._directories[p] = new VirtualDirStats(p); p = dirname(p); } + + this._changed = true; } populateWebpackResolver(resolver: any) { const fs = resolver.fileSystem; + if (!this._changed) { + return; + } for (const fileName of Object.keys(this._files)) { const stats = this._files[fileName]; @@ -121,6 +127,8 @@ export class WebpackCompilerHost implements ts.CompilerHost { fs._statStorage.data[path] = [null, stats]; fs._readdirStorage.data[path] = [null, files.concat(dirs)]; } + + this._changed = false; } fileExists(fileName: string): boolean { diff --git a/packages/webpack/src/plugin.ts b/packages/webpack/src/plugin.ts index 92201ad1c9d8..69611b842b6e 100644 --- a/packages/webpack/src/plugin.ts +++ b/packages/webpack/src/plugin.ts @@ -119,7 +119,7 @@ export class NgcWebpackPlugin { // Virtual file system. compiler.resolvers.normal.plugin('resolve', (request: any, cb?: () => void) => { - // populate the file system cache with the virtual module + // Populate the file system cache with the virtual module. this.compilerHost.populateWebpackResolver(compiler.resolvers.normal); if (cb) { cb(); diff --git a/tests/e2e/tests/test/e2e.ts b/tests/e2e/tests/test/e2e.ts index b0e49f05286d..ca66091906c7 100644 --- a/tests/e2e/tests/test/e2e.ts +++ b/tests/e2e/tests/test/e2e.ts @@ -17,5 +17,7 @@ export default function() { return expectToFail(() => ng('e2e')) // These should work. .then(() => _runServeAndE2e()) - .then(() => _runServeAndE2e('--prod')); + .then(() => _runServeAndE2e('--prod')) + .then(() => _runServeAndE2e('--aot')) + .then(() => _runServeAndE2e('--aot', '--prod')); }