Skip to content

Commit 472012d

Browse files
committed
feat(aot): do not populate the whole filesystem if nothing changed since the last call.
1 parent 911caa2 commit 472012d

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/webpack/src/compiler_host.ts

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
9191
private _delegate: ts.CompilerHost;
9292
private _files: {[path: string]: VirtualFileStats} = Object.create(null);
9393
private _directories: {[path: string]: VirtualDirStats} = Object.create(null);
94+
private _changed = false;
9495

9596
constructor(private _options: ts.CompilerOptions, private _setParentNodes = true) {
9697
this._delegate = ts.createCompilerHost(this._options, this._setParentNodes);
@@ -104,10 +105,15 @@ export class WebpackCompilerHost implements ts.CompilerHost {
104105
this._directories[p] = new VirtualDirStats(p);
105106
p = dirname(p);
106107
}
108+
109+
this._changed = true;
107110
}
108111

109112
populateWebpackResolver(resolver: any) {
110113
const fs = resolver.fileSystem;
114+
if (!this._changed) {
115+
return;
116+
}
111117

112118
for (const fileName of Object.keys(this._files)) {
113119
const stats = this._files[fileName];
@@ -121,6 +127,8 @@ export class WebpackCompilerHost implements ts.CompilerHost {
121127
fs._statStorage.data[path] = [null, stats];
122128
fs._readdirStorage.data[path] = [null, files.concat(dirs)];
123129
}
130+
131+
this._changed = false;
124132
}
125133

126134
fileExists(fileName: string): boolean {

packages/webpack/src/plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class NgcWebpackPlugin {
119119

120120
// Virtual file system.
121121
compiler.resolvers.normal.plugin('resolve', (request: any, cb?: () => void) => {
122-
// populate the file system cache with the virtual module
122+
// Populate the file system cache with the virtual module.
123123
this.compilerHost.populateWebpackResolver(compiler.resolvers.normal);
124124
if (cb) {
125125
cb();

tests/e2e/tests/test/e2e.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ export default function() {
1717
return expectToFail(() => ng('e2e'))
1818
// These should work.
1919
.then(() => _runServeAndE2e())
20-
.then(() => _runServeAndE2e('--prod'));
20+
.then(() => _runServeAndE2e('--prod'))
21+
.then(() => _runServeAndE2e('--aot'))
22+
.then(() => _runServeAndE2e('--aot', '--prod'));
2123
}

0 commit comments

Comments
 (0)