Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aot): do not populate the whole filesystem if nothing changed #2490

Merged
merged 2 commits into from
Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/angular-cli/models/webpack-build-typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export const getWebpackAotConfigPartial = function(projectRoot: string, appConfi
plugins: [
new NgcWebpackPlugin({
project: path.resolve(projectRoot, appConfig.root, appConfig.tsconfig),
baseDir: path.resolve(projectRoot, ''),
baseDir: path.resolve(projectRoot, appConfig.root),
main: path.join(projectRoot, appConfig.root, appConfig.main),
genDir: path.resolve(projectRoot, '')
genDir: path.resolve(projectRoot, appConfig.root)
}),
]
};
Expand Down
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
17 changes: 9 additions & 8 deletions packages/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ export class NgcWebpackPlugin {
return callback();
}

result.resource = this.genDir;
result.recursive = true;
result.dependencies.forEach((d: any) => d.critical = false);
result.resolveDependencies = createResolveDependenciesFromContextMap((_: any, cb: any) => {
return cb(null, this.lazyRoutes);
this.done.then(() => {
result.resource = this.genDir;
result.recursive = true;
result.dependencies.forEach((d: any) => d.critical = false);
result.resolveDependencies = createResolveDependenciesFromContextMap(
(_: any, cb: any) => cb(null, this.lazyRoutes));

return callback(null, result);
});

return callback(null, result);
});
});

Expand All @@ -119,7 +120,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'));
}