Skip to content

Commit 38fff6a

Browse files
committed
refactor(@ngtools/webpack): simplify a call using await
1 parent 080d9b5 commit 38fff6a

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

+27-30
Original file line numberDiff line numberDiff line change
@@ -756,39 +756,36 @@ export class AngularCompilerPlugin {
756756
return result;
757757
}
758758

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

785-
callback(null, dependencies);
786-
};
781+
if (this._options.nameLazyFiles) {
782+
options.chunkName = '[request]';
783+
}
787784

788-
return result;
789-
},
790-
() => undefined,
791-
);
785+
callback(null, dependencies);
786+
};
787+
788+
return result;
792789
});
793790
});
794791
}

0 commit comments

Comments
 (0)