Skip to content

Commit

Permalink
feat(aot): do not populate the whole filesystem if nothing changed si…
Browse files Browse the repository at this point in the history
…nce the last call.
  • Loading branch information
hansl committed Oct 3, 2016
1 parent 911caa2 commit 472012d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/webpack/src/compiler_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/tests/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

0 comments on commit 472012d

Please sign in to comment.