fix(compiler): allow tree-shakeable injectables to depend on string tokens (#22376)
Previously the injectable compiler assumed all tree-shakeable injectables would have dependencies that were injectables or InjectionTokens. However old code still uses string tokens (e.g. NgUpgrade and '$injector'). Using such tokens would cause the injectable compiler to crash. Now, the injectable compiler can properly generate a dependency on such a string token. PR Close #22376
This commit is contained in:

committed by
Alex Eagle

parent
8bb2f5c71d
commit
dd534471ec
@ -55,10 +55,11 @@ export class InjectableCompiler {
|
||||
}
|
||||
}
|
||||
}
|
||||
const tokenExpr = typeof token === 'string' ? o.literal(token) : ctx.importExpr(token);
|
||||
if (flags !== InjectFlags.Default || defaultValue !== undefined) {
|
||||
args = [ctx.importExpr(token), o.literal(defaultValue), o.literal(flags)];
|
||||
args = [tokenExpr, o.literal(defaultValue), o.literal(flags)];
|
||||
} else {
|
||||
args = [ctx.importExpr(token)];
|
||||
args = [tokenExpr];
|
||||
}
|
||||
return o.importExpr(Identifiers.inject).callFn(args);
|
||||
});
|
||||
|
Reference in New Issue
Block a user