fix: consistently rewrite Injector to INJECTOR (#23008)

In Ivy mode we rewrite references to Injector to INJECTOR in ngInjectableDef, to fix tree-shaking.

This changes the rewrite to happen always, even in non-Ivy mode, and makes Angular understand
INJECTOR across the board at runtime.

PR Close #23008
This commit is contained in:
Alex Rickabaugh
2018-03-26 16:22:46 -07:00
parent 0b348c8ffe
commit 884bf0ef09
5 changed files with 33 additions and 4 deletions

View File

@ -63,7 +63,7 @@ export class InjectableCompiler {
let tokenExpr: o.Expression;
if (typeof token === 'string') {
tokenExpr = o.literal(token);
} else if (token === this.tokenInjector && this.alwaysGenerateDef) {
} else if (token === this.tokenInjector) {
tokenExpr = o.importExpr(Identifiers.INJECTOR);
} else {
tokenExpr = ctx.importExpr(token);