diff --git a/packages/core/src/linker/ng_module_factory_loader.ts b/packages/core/src/linker/ng_module_factory_loader.ts index 13e57d8fd3..c4660f71f8 100644 --- a/packages/core/src/linker/ng_module_factory_loader.ts +++ b/packages/core/src/linker/ng_module_factory_loader.ts @@ -35,12 +35,12 @@ const modules = new Map|NgModuleType>(); */ export function registerModuleFactory(id: string, factory: NgModuleFactory) { const existing = modules.get(id) as NgModuleFactory; - assertNotExisting(id, existing && existing.moduleType); + assertSameOrNotExisting(id, existing && existing.moduleType, factory.moduleType); modules.set(id, factory); } -function assertNotExisting(id: string, type: Type| null): void { - if (type) { +function assertSameOrNotExisting(id: string, type: Type| null, incoming: Type): void { + if (type && type !== incoming) { throw new Error( `Duplicate module registered for ${id} - ${stringify(type)} vs ${stringify(type.name)}`); } @@ -48,7 +48,7 @@ function assertNotExisting(id: string, type: Type| null): void { export function registerNgModuleType(id: string, ngModuleType: NgModuleType) { const existing = modules.get(id) as NgModuleType | null; - assertNotExisting(id, existing); + assertSameOrNotExisting(id, existing, ngModuleType); modules.set(id, ngModuleType); }