refactor(core): enabled using deps tracker in JIT compilation (#51293)

This change simply flip the flag which enables using the deps tracker in JIT compilation (the logic is already implemented in a previous PR). Some tests which depend on the old JIT implementation (e.g., patching the scope info into the type) are modified accordingly.

PR Close #51293
This commit is contained in:
Payam Valadkhan 2023-08-07 18:15:58 -04:00 committed by Pawel Kozlowski
parent a9f609e75c
commit bc55d82eb9
2 changed files with 18 additions and 7 deletions

View file

@ -24,7 +24,7 @@ import {ComponentDependencies, DepsTrackerApi, NgModuleScope, StandaloneComponen
*
* @deprecated For migration purposes only, to be removed soon.
*/
export const USE_RUNTIME_DEPS_TRACKER_FOR_JIT = false;
export const USE_RUNTIME_DEPS_TRACKER_FOR_JIT = true;
/**
* An implementation of DepsTrackerApi which will be used for JIT and local compilation.

View file

@ -11,6 +11,8 @@ import {TestBed, TestBedImpl} from '@angular/core/testing/src/test_bed';
import {By} from '@angular/platform-browser';
import {expect} from '@angular/platform-browser/testing/src/matchers';
import {NgModuleType} from '../src/render3';
import {depsTracker} from '../src/render3/deps_tracker/deps_tracker';
import {TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT, THROW_ON_UNKNOWN_ELEMENTS_DEFAULT, THROW_ON_UNKNOWN_PROPERTIES_DEFAULT} from '../testing/src/test_bed_common';
const NAME = new InjectionToken<string>('name');
@ -1628,10 +1630,9 @@ describe('TestBed', () => {
expect(cmpDefBeforeReset.pipeDefs().length).toEqual(1);
expect(cmpDefBeforeReset.directiveDefs().length).toEqual(2); // directive + component
const modDefBeforeReset = (SomeModule as any).ɵmod;
const transitiveScope = modDefBeforeReset.transitiveCompileScopes.compilation;
expect(transitiveScope.pipes.size).toEqual(1);
expect(transitiveScope.directives.size).toEqual(2);
const scopeBeforeReset = depsTracker.getNgModuleScope(SomeModule as NgModuleType);
expect(scopeBeforeReset.compilation.pipes.size).toEqual(1);
expect(scopeBeforeReset.compilation.directives.size).toEqual(2);
TestBed.resetTestingModule();
@ -1639,8 +1640,18 @@ describe('TestBed', () => {
expect(cmpDefAfterReset.pipeDefs).toBe(null);
expect(cmpDefAfterReset.directiveDefs).toBe(null);
const modDefAfterReset = (SomeModule as any).ɵmod;
expect(modDefAfterReset.transitiveCompileScopes).toBe(null);
const scopeAfterReset = depsTracker.getNgModuleScope(SomeModule as NgModuleType);
expect(scopeAfterReset).toEqual({
compilation: {
pipes: new Set(),
directives: new Set([SomeComponent]),
},
exported: {
pipes: new Set(),
directives: new Set(),
}
});
});
it('should cleanup ng defs for classes with no ng annotations (in case of inheritance)', () => {