Skip to content

Commit bc55d82

Browse files
pmvaldpkozlowski-opensource
authored andcommitted
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
1 parent a9f609e commit bc55d82

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

packages/core/src/render3/deps_tracker/deps_tracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {ComponentDependencies, DepsTrackerApi, NgModuleScope, StandaloneComponen
2424
*
2525
* @deprecated For migration purposes only, to be removed soon.
2626
*/
27-
export const USE_RUNTIME_DEPS_TRACKER_FOR_JIT = false;
27+
export const USE_RUNTIME_DEPS_TRACKER_FOR_JIT = true;
2828

2929
/**
3030
* An implementation of DepsTrackerApi which will be used for JIT and local compilation.

packages/core/test/test_bed_spec.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {TestBed, TestBedImpl} from '@angular/core/testing/src/test_bed';
1111
import {By} from '@angular/platform-browser';
1212
import {expect} from '@angular/platform-browser/testing/src/matchers';
1313

14+
import {NgModuleType} from '../src/render3';
15+
import {depsTracker} from '../src/render3/deps_tracker/deps_tracker';
1416
import {TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT, THROW_ON_UNKNOWN_ELEMENTS_DEFAULT, THROW_ON_UNKNOWN_PROPERTIES_DEFAULT} from '../testing/src/test_bed_common';
1517

1618
const NAME = new InjectionToken<string>('name');
@@ -1628,19 +1630,28 @@ describe('TestBed', () => {
16281630
expect(cmpDefBeforeReset.pipeDefs().length).toEqual(1);
16291631
expect(cmpDefBeforeReset.directiveDefs().length).toEqual(2); // directive + component
16301632

1631-
const modDefBeforeReset = (SomeModule as any).ɵmod;
1632-
const transitiveScope = modDefBeforeReset.transitiveCompileScopes.compilation;
1633-
expect(transitiveScope.pipes.size).toEqual(1);
1634-
expect(transitiveScope.directives.size).toEqual(2);
1633+
const scopeBeforeReset = depsTracker.getNgModuleScope(SomeModule as NgModuleType);
1634+
expect(scopeBeforeReset.compilation.pipes.size).toEqual(1);
1635+
expect(scopeBeforeReset.compilation.directives.size).toEqual(2);
16351636

16361637
TestBed.resetTestingModule();
16371638

16381639
const cmpDefAfterReset = (SomeComponent as any).ɵcmp;
16391640
expect(cmpDefAfterReset.pipeDefs).toBe(null);
16401641
expect(cmpDefAfterReset.directiveDefs).toBe(null);
16411642

1642-
const modDefAfterReset = (SomeModule as any).ɵmod;
1643-
expect(modDefAfterReset.transitiveCompileScopes).toBe(null);
1643+
const scopeAfterReset = depsTracker.getNgModuleScope(SomeModule as NgModuleType);
1644+
1645+
expect(scopeAfterReset).toEqual({
1646+
compilation: {
1647+
pipes: new Set(),
1648+
directives: new Set([SomeComponent]),
1649+
},
1650+
exported: {
1651+
pipes: new Set(),
1652+
directives: new Set(),
1653+
}
1654+
});
16441655
});
16451656

16461657
it('should cleanup ng defs for classes with no ng annotations (in case of inheritance)', () => {

0 commit comments

Comments
 (0)