Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler-cli): don't emit empty providers array (#46301)
Saves us some bytes by not emitting `providers` in `defineInjector`. While the amount of bytes isn't huge, I think that this change is worthwhile, because `ng generate` currently generates `providers: []` with every `NgModule` which users can forget to remove. PR Close #46301
- Loading branch information
1 parent
c2ba7c4
commit 8ecfd71
Showing
8 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/empty_fields.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export class FooModule {} | ||
FooModule.ɵfac = …; | ||
FooModule.ɵmod = …; | ||
FooModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); |
9 changes: 9 additions & 0 deletions
9
...compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/empty_fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {NgModule} from '@angular/core'; | ||
|
||
@NgModule({ | ||
providers: [], | ||
declarations: [], | ||
imports: [], | ||
}) | ||
export class FooModule { | ||
} |
5 changes: 5 additions & 0 deletions
5
...er-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/variable_providers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const PROVIDERS = [{provide: new InjectionToken('token'), useValue: 1}]; | ||
export class FooModule {} | ||
FooModule.ɵfac = …; | ||
FooModule.ɵmod = …; | ||
FooModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({providers: PROVIDERS}); |
7 changes: 7 additions & 0 deletions
7
...er-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/variable_providers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {InjectionToken, NgModule} from '@angular/core'; | ||
|
||
const PROVIDERS = [{provide: new InjectionToken('token'), useValue: 1}]; | ||
|
||
@NgModule({providers: PROVIDERS}) | ||
export class FooModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters