fix(language-service): Lazily instantiate MetadataResolver (#32631)
The instantiation of the resolver also requires instantiation of the StaticReflector, and the latter requires resolution of core Angular symbols. Module resolution should not be done during instantiation to avoid potential cyclic dependency between the plugin and the containing Project, so the Singleton pattern is used to create the resolver. PR Close #32631
This commit is contained in:

committed by
Kara Erickson

parent
7a569a7c52
commit
1771d6ff25
@ -51,13 +51,11 @@ describe('reflector_host_spec', () => {
|
||||
|
||||
const tsLS = ts.createLanguageService(mockHost);
|
||||
|
||||
// First count is due to the instantiation of StaticReflector, which
|
||||
// performs resolutions of core Angular symbols, like `NgModule`.
|
||||
// TODO: Reduce this count to zero doing lazy instantiation.
|
||||
// First count is zero due to lazy instantiation of the StaticReflector
|
||||
// and MetadataResolver.
|
||||
const ngLSHost = new TypeScriptServiceHost(mockHost, tsLS);
|
||||
const firstCount = spy.calls.count();
|
||||
expect(firstCount).toBeGreaterThan(20);
|
||||
expect(firstCount).toBeLessThan(50);
|
||||
expect(firstCount).toBe(0);
|
||||
spy.calls.reset();
|
||||
|
||||
// Second count is due to resolution of the Tour of Heroes (toh) project.
|
||||
|
Reference in New Issue
Block a user