Skip to content

Commit 8d82e98

Browse files
filipesilvamgechev
authored andcommitted
refactor(@ngtools/webpack): simplify a call using await
1 parent 55a86c9 commit 8d82e98

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -760,39 +760,36 @@ export class AngularCompilerPlugin {
760760
return result;
761761
}
762762

763-
return this.done.then(
764-
() => {
765-
// This folder does not exist, but we need to give webpack a resource.
766-
// TODO: check if we can't just leave it as is (angularCoreModuleDir).
767-
result.resource = path.join(this._basePath, '$$_lazy_route_resource');
768-
// tslint:disable-next-line:no-any
769-
result.dependencies.forEach((d: any) => d.critical = false);
770-
// tslint:disable-next-line:no-any
771-
result.resolveDependencies = (_fs: any, options: any, callback: Callback) => {
772-
const dependencies = Object.keys(this._lazyRoutes)
773-
.map((key) => {
774-
const modulePath = this._lazyRoutes[key];
775-
if (modulePath !== null) {
776-
const name = key.split('#')[0];
777-
778-
return new this._contextElementDependencyConstructor(modulePath, name);
779-
} else {
780-
return null;
781-
}
782-
})
783-
.filter(x => !!x);
784-
785-
if (this._options.nameLazyFiles) {
786-
options.chunkName = '[request]';
763+
await this.done;
764+
765+
// This folder does not exist, but we need to give webpack a resource.
766+
// TODO: check if we can't just leave it as is (angularCoreModuleDir).
767+
result.resource = path.join(this._basePath, '$$_lazy_route_resource');
768+
// tslint:disable-next-line:no-any
769+
result.dependencies.forEach((d: any) => d.critical = false);
770+
// tslint:disable-next-line:no-any
771+
result.resolveDependencies = (_fs: any, options: any, callback: Callback) => {
772+
const dependencies = Object.keys(this._lazyRoutes)
773+
.map((key) => {
774+
const modulePath = this._lazyRoutes[key];
775+
if (modulePath !== null) {
776+
const name = key.split('#')[0];
777+
778+
return new this._contextElementDependencyConstructor(modulePath, name);
779+
} else {
780+
return null;
787781
}
782+
})
783+
.filter(x => !!x);
788784

789-
callback(null, dependencies);
790-
};
785+
if (this._options.nameLazyFiles) {
786+
options.chunkName = '[request]';
787+
}
791788

792-
return result;
793-
},
794-
() => undefined,
795-
);
789+
callback(null, dependencies);
790+
};
791+
792+
return result;
796793
});
797794
});
798795
}

0 commit comments

Comments
 (0)