feat(ivy): support bootstrap in ngModuleDef (#25775)
The bootstrap property of @NgModule was not previously compiled by the compiler in AOT or JIT modes (in Ivy). This commit adds support for bootstrap. PR Close #25775
This commit is contained in:

committed by
Igor Minar

parent
a0c4b2d8f0
commit
13ccdfd89d
@ -87,6 +87,12 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
ref => this._extractModuleFromModuleWithProvidersFn(ref.node));
|
||||
exports = this.resolveTypeList(expr, exportsMeta, 'exports');
|
||||
}
|
||||
let bootstrap: Reference[] = [];
|
||||
if (ngModule.has('bootstrap')) {
|
||||
const expr = ngModule.get('bootstrap') !;
|
||||
const bootstrapMeta = staticallyResolve(expr, this.reflector, this.checker);
|
||||
bootstrap = this.resolveTypeList(expr, bootstrapMeta, 'bootstrap');
|
||||
}
|
||||
|
||||
// Register this module's information with the SelectorScopeRegistry. This ensures that during
|
||||
// the compile() phase, the module's metadata is available for selector scope computation.
|
||||
@ -96,7 +102,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
|
||||
const ngModuleDef: R3NgModuleMetadata = {
|
||||
type: new WrappedNodeExpr(node.name !),
|
||||
bootstrap: [],
|
||||
bootstrap: bootstrap.map(bootstrap => toR3Reference(bootstrap, context)),
|
||||
declarations: declarations.map(decl => toR3Reference(decl, context)),
|
||||
exports: exports.map(exp => toR3Reference(exp, context)),
|
||||
imports: imports.map(imp => toR3Reference(imp, context)),
|
||||
|
@ -182,6 +182,7 @@ describe('ngtsc behavioral tests', () => {
|
||||
|
||||
@NgModule({
|
||||
declarations: [TestCmp],
|
||||
bootstrap: [TestCmp],
|
||||
})
|
||||
export class TestModule {}
|
||||
`);
|
||||
@ -193,7 +194,7 @@ describe('ngtsc behavioral tests', () => {
|
||||
const jsContents = getContents('test.js');
|
||||
expect(jsContents)
|
||||
.toContain(
|
||||
'i0.ɵdefineNgModule({ type: TestModule, bootstrap: [], ' +
|
||||
'i0.ɵdefineNgModule({ type: TestModule, bootstrap: [TestCmp], ' +
|
||||
'declarations: [TestCmp], imports: [], exports: [] })');
|
||||
|
||||
const dtsContents = getContents('test.d.ts');
|
||||
|
Reference in New Issue
Block a user