Skip to content

Commit

Permalink
fix(ivy): auto register NgModules with ID
Browse files Browse the repository at this point in the history
  • Loading branch information
atscott committed Nov 8, 2019
1 parent 8912b11 commit 7380be0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/linker/ng_module_factory_registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/


import {Type} from '../interface/type';
import {autoRegisterModuleById} from '../render3/definition';
import {NgModuleType} from '../render3/ng_module_ref';
import {stringify} from '../util/stringify';

Expand Down Expand Up @@ -68,5 +70,5 @@ export function restoreRegisteredModulesState(moduleMap: ModuleRegistrationMap)
}

export function getRegisteredNgModuleType(id: string) {
return modules.get(id);
return modules.get(id) || autoRegisterModuleById[id];
}
7 changes: 7 additions & 0 deletions packages/core/src/render3/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {TConstants} from './interfaces/node';
// while SelectorFlags is unused here, it's required so that types don't get resolved lazily
// see: https://github.com/Microsoft/web-build-tools/issues/1050
import {CssSelectorList, SelectorFlags} from './interfaces/projection';
import {NgModuleType} from './ng_module_ref';

let _renderCompCount = 0;

Expand Down Expand Up @@ -338,6 +339,8 @@ export function extractPipeDef(type: Type<any>): PipeDef<any> {
return def !;
}

export const autoRegisterModuleById: {[id: string]: NgModuleType} = {};

/**
* @codeGenApi
*/
Expand Down Expand Up @@ -376,6 +379,10 @@ export function ɵɵdefineNgModule<T>(def: {
schemas: def.schemas || null,
id: def.id || null,
};
if (def.id != null) {
noSideEffects(
() => { autoRegisterModuleById[def.id !] = def.type as unknown as NgModuleType; });
}
return res as never;
}

Expand Down

0 comments on commit 7380be0

Please sign in to comment.