From 8d82e9812d3fa9908a2f686d0b4ff8e56aae3d0f Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Tue, 26 Mar 2019 15:55:41 +0000 Subject: [PATCH] refactor(@ngtools/webpack): simplify a call using await --- .../webpack/src/angular_compiler_plugin.ts | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/packages/ngtools/webpack/src/angular_compiler_plugin.ts b/packages/ngtools/webpack/src/angular_compiler_plugin.ts index 5f079af2ab..b9393a9a75 100644 --- a/packages/ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/ngtools/webpack/src/angular_compiler_plugin.ts @@ -760,39 +760,36 @@ export class AngularCompilerPlugin { return result; } - return this.done.then( - () => { - // This folder does not exist, but we need to give webpack a resource. - // TODO: check if we can't just leave it as is (angularCoreModuleDir). - result.resource = path.join(this._basePath, '$$_lazy_route_resource'); - // tslint:disable-next-line:no-any - result.dependencies.forEach((d: any) => d.critical = false); - // tslint:disable-next-line:no-any - result.resolveDependencies = (_fs: any, options: any, callback: Callback) => { - const dependencies = Object.keys(this._lazyRoutes) - .map((key) => { - const modulePath = this._lazyRoutes[key]; - if (modulePath !== null) { - const name = key.split('#')[0]; + await this.done; - return new this._contextElementDependencyConstructor(modulePath, name); - } else { - return null; - } - }) - .filter(x => !!x); + // This folder does not exist, but we need to give webpack a resource. + // TODO: check if we can't just leave it as is (angularCoreModuleDir). + result.resource = path.join(this._basePath, '$$_lazy_route_resource'); + // tslint:disable-next-line:no-any + result.dependencies.forEach((d: any) => d.critical = false); + // tslint:disable-next-line:no-any + result.resolveDependencies = (_fs: any, options: any, callback: Callback) => { + const dependencies = Object.keys(this._lazyRoutes) + .map((key) => { + const modulePath = this._lazyRoutes[key]; + if (modulePath !== null) { + const name = key.split('#')[0]; - if (this._options.nameLazyFiles) { - options.chunkName = '[request]'; + return new this._contextElementDependencyConstructor(modulePath, name); + } else { + return null; } + }) + .filter(x => !!x); - callback(null, dependencies); - }; + if (this._options.nameLazyFiles) { + options.chunkName = '[request]'; + } - return result; - }, - () => undefined, - ); + callback(null, dependencies); + }; + + return result; }); }); }