feat(ivy): do not emit empty providers/imports for defineInjector (#29598)
The defineInjector function specifies its providers and imports array to be optional, so if no providers/imports are present these keys may be omitted. This commit updates the compiler to only generate the keys when necessary. PR Close #29598
This commit is contained in:
@ -445,6 +445,10 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(jsContents).toContain('i0.ɵdefineNgModule({ type: TestModule, bootstrap: [TestCmp] });');
|
||||
expect(jsContents)
|
||||
.toContain('/*@__PURE__*/ i0.ɵsetNgModuleScope(TestModule, { declarations: [TestCmp] });');
|
||||
expect(jsContents)
|
||||
.toContain(
|
||||
'i0.defineInjector({ factory: ' +
|
||||
'function TestModule_Factory(t) { return new (t || TestModule)(); } });');
|
||||
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents)
|
||||
@ -528,8 +532,8 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(jsContents)
|
||||
.toContain(
|
||||
'i0.defineInjector({ factory: function TestModule_Factory(t) ' +
|
||||
'{ return new (t || TestModule)(); }, providers: [], ' +
|
||||
'imports: [[OtherModule, RouterModule.forRoot()],\n OtherModule,\n RouterModule] });');
|
||||
'{ return new (t || TestModule)(); }, imports: [[OtherModule, RouterModule.forRoot()],' +
|
||||
'\n OtherModule,\n RouterModule] });');
|
||||
});
|
||||
|
||||
it('should compile NgModules with services without errors', () => {
|
||||
|
Reference in New Issue
Block a user