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:
Alex Rickabaugh
2018-02-22 10:29:01 -08:00
committed by Alex Eagle
parent 8bb2f5c71d
commit dd534471ec
3 changed files with 52 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import {DepAppModuleNgFactory} from 'app_built/src/dep.ngfactory';
import {HierarchyAppModuleNgFactory} from 'app_built/src/hierarchy.ngfactory';
import {RootAppModuleNgFactory} from 'app_built/src/root.ngfactory';
import {SelfAppModuleNgFactory} from 'app_built/src/self.ngfactory';
import {StringAppModuleNgFactory} from 'app_built/src/string.ngfactory';
import {TokenAppModuleNgFactory} from 'app_built/src/token.ngfactory';
enableProdMode();
@ -77,4 +78,14 @@ describe('ngInjectableDef Bazel Integration', () => {
done();
});
});
it('string tokens work', done => {
renderModuleFactory(StringAppModuleNgFactory, {
document: '<string-app></string-app>',
url: '/',
}).then(html => {
expect(html).toMatch(/>works<\//);
done();
});
});
});