Skip to content

Commit

Permalink
refactor(core): enabled using deps tracker in JIT
Browse files Browse the repository at this point in the history
  • Loading branch information
pmvald committed Jul 21, 2023
1 parent 7954c90 commit 53af81a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/render3/deps_tracker/deps_tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {ComponentDependencies, DepsTrackerApi, NgModuleScope, StandaloneComponen
*
* @deprecated For migration purposes only, to be removed soon.
*/
export const USE_RDT_FOR_JIT = false;
export const USE_RDT_FOR_JIT = true;

/**
* An implementation of DepsTrackerApi which will be used for JIT and local compilation.
Expand Down
23 changes: 17 additions & 6 deletions packages/core/test/test_bed_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -1628,19 +1630,28 @@ 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();

const cmpDefAfterReset = (SomeComponent as any).ɵcmp;
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)', () => {
Expand Down

0 comments on commit 53af81a

Please sign in to comment.