Skip to content

Commit

Permalink
refactor(core): enabled using deps tracker in JIT compilation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pmvald committed Aug 29, 2023
1 parent 16b29c7 commit d3b4cde
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_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.
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 {setClassMetadataAsync} from '../src/render3/metadata';
import {TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT, THROW_ON_UNKNOWN_ELEMENTS_DEFAULT, THROW_ON_UNKNOWN_PROPERTIES_DEFAULT} from '../testing/src/test_bed_common';

Expand Down Expand Up @@ -1750,19 +1752,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 d3b4cde

Please sign in to comment.