Skip to content

Commit

Permalink
perf(core): make IterableDiffers and KeyValueDiffers tree-shakable (
Browse files Browse the repository at this point in the history
#45094)

This commit removed references to the `IterableDiffers` and `KeyValueDiffers` classes from the `ApplicationModule`, which effectively make them tree-shakable. Both classes have `prov` static field with the right setup, so they'll be properly initialized when referenced.

PR Close #45094
  • Loading branch information
AndrewKushnir authored and alxhub committed Feb 16, 2022
1 parent f1d10ba commit 45d98e7
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 184 deletions.
10 changes: 5 additions & 5 deletions goldens/size-tracking/integration-payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"master": {
"uncompressed": {
"runtime": 1083,
"main": 139416,
"main": 127944,
"polyfills": 37226
}
}
Expand All @@ -24,7 +24,7 @@
"master": {
"uncompressed": {
"runtime": 1105,
"main": 145132,
"main": 133608,
"polyfills": 37248
}
}
Expand All @@ -33,7 +33,7 @@
"master": {
"uncompressed": {
"runtime": 929,
"main": 137712,
"main": 126275,
"polyfills": 37933
}
}
Expand All @@ -52,7 +52,7 @@
"master": {
"uncompressed": {
"runtime": 1063,
"main": 163160,
"main": 159637,
"polyfills": 36975
}
}
Expand All @@ -61,7 +61,7 @@
"master": {
"uncompressed": {
"runtime": 1070,
"main": 171374,
"main": 159755,
"polyfills": 37242
}
}
Expand Down
11 changes: 0 additions & 11 deletions packages/core/src/application_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
import {ApplicationRef} from './application_ref';
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
import {defaultIterableDiffers, defaultKeyValueDiffers, IterableDiffers, KeyValueDiffers} from './change_detection/change_detection';
import {Injector, StaticProvider} from './di';
import {Inject, Optional, SkipSelf} from './di/metadata';
import {ErrorHandler} from './error_handler';
Expand All @@ -23,14 +22,6 @@ import {NgZone} from './zone';

declare const $localize: {locale?: string};

export function _iterableDiffersFactory() {
return defaultIterableDiffers;
}

export function _keyValueDiffersFactory() {
return defaultKeyValueDiffers;
}

export function _localeFactory(locale?: string): string {
return locale || getGlobalLocale();
}
Expand Down Expand Up @@ -79,8 +70,6 @@ export const APPLICATION_MODULE_PROVIDERS: StaticProvider[] = [
},
{provide: Compiler, useClass: Compiler, deps: []},
APP_ID_RANDOM_PROVIDER,
{provide: IterableDiffers, useFactory: _iterableDiffersFactory, deps: []},
{provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory, deps: []},
{
provide: LOCALE_ID,
useFactory: _localeFactory,
Expand Down
60 changes: 0 additions & 60 deletions packages/core/test/bundling/animations/bundle.golden_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,6 @@
{
"name": "DefaultDomRenderer2"
},
{
"name": "DefaultIterableDiffer"
},
{
"name": "DefaultIterableDifferFactory"
},
{
"name": "DefaultKeyValueDiffer"
},
{
"name": "DefaultKeyValueDifferFactory"
},
{
"name": "DomEventsPlugin"
},
Expand Down Expand Up @@ -260,21 +248,9 @@
{
"name": "Injector"
},
{
"name": "IterableChangeRecord_"
},
{
"name": "IterableDiffers"
},
{
"name": "KeyEventsPlugin"
},
{
"name": "KeyValueChangeRecord_"
},
{
"name": "KeyValueDiffers"
},
{
"name": "LEAVE_TOKEN_REGEX"
},
Expand Down Expand Up @@ -545,9 +521,6 @@
{
"name": "_DOM"
},
{
"name": "_DuplicateMap"
},
{
"name": "_IS_WEBKIT"
},
Expand Down Expand Up @@ -608,9 +581,6 @@
{
"name": "_renderCompCount"
},
{
"name": "_symbolIterator"
},
{
"name": "_testabilityGetter"
},
Expand Down Expand Up @@ -779,18 +749,6 @@
{
"name": "defaultErrorLogger"
},
{
"name": "defaultIterableDiffers"
},
{
"name": "defaultIterableDiffersFactory"
},
{
"name": "defaultKeyValueDiffers"
},
{
"name": "defaultKeyValueDiffersFactory"
},
{
"name": "defaultScheduler"
},
Expand Down Expand Up @@ -965,9 +923,6 @@
{
"name": "getPlatform"
},
{
"name": "getPreviousIndex"
},
{
"name": "getProjectionNodes"
},
Expand All @@ -980,9 +935,6 @@
{
"name": "getStyleAttributeString"
},
{
"name": "getSymbolIterator"
},
{
"name": "getSymbolIterator2"
},
Expand Down Expand Up @@ -1088,18 +1040,12 @@
{
"name": "isInlineTemplate"
},
{
"name": "isJsObject"
},
{
"name": "isLContainer"
},
{
"name": "isLView"
},
{
"name": "isListLikeIterable"
},
{
"name": "isNode"
},
Expand Down Expand Up @@ -1139,9 +1085,6 @@
{
"name": "iteratorToArray"
},
{
"name": "keyValDiff"
},
{
"name": "leaveDI"
},
Expand Down Expand Up @@ -1421,9 +1364,6 @@
{
"name": "toRefArray"
},
{
"name": "trackByIdentity"
},
{
"name": "transition"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@
{
"name": "DefaultIterableDifferFactory"
},
{
"name": "DefaultKeyValueDiffer"
},
{
"name": "DefaultKeyValueDifferFactory"
},
{
"name": "DefaultValueAccessor"
},
Expand Down Expand Up @@ -242,12 +236,6 @@
{
"name": "KeyEventsPlugin"
},
{
"name": "KeyValueChangeRecord_"
},
{
"name": "KeyValueDiffers"
},
{
"name": "LOCALE_DATA"
},
Expand Down Expand Up @@ -767,18 +755,9 @@
{
"name": "defaultErrorLogger"
},
{
"name": "defaultIterableDiffers"
},
{
"name": "defaultIterableDiffersFactory"
},
{
"name": "defaultKeyValueDiffers"
},
{
"name": "defaultKeyValueDiffersFactory"
},
{
"name": "defaultScheduler"
},
Expand Down Expand Up @@ -1169,9 +1148,6 @@
{
"name": "isInlineTemplate"
},
{
"name": "isJsObject"
},
{
"name": "isLContainer"
},
Expand Down Expand Up @@ -1226,9 +1202,6 @@
{
"name": "iterator"
},
{
"name": "keyValDiff"
},
{
"name": "keyValueArrayGet"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@
{
"name": "DefaultIterableDifferFactory"
},
{
"name": "DefaultKeyValueDiffer"
},
{
"name": "DefaultKeyValueDifferFactory"
},
{
"name": "DefaultValueAccessor"
},
Expand Down Expand Up @@ -233,12 +227,6 @@
{
"name": "KeyEventsPlugin"
},
{
"name": "KeyValueChangeRecord_"
},
{
"name": "KeyValueDiffers"
},
{
"name": "LOCALE_DATA"
},
Expand Down Expand Up @@ -749,18 +737,9 @@
{
"name": "defaultErrorLogger"
},
{
"name": "defaultIterableDiffers"
},
{
"name": "defaultIterableDiffersFactory"
},
{
"name": "defaultKeyValueDiffers"
},
{
"name": "defaultKeyValueDiffersFactory"
},
{
"name": "defaultScheduler"
},
Expand Down Expand Up @@ -1136,9 +1115,6 @@
{
"name": "isInlineTemplate"
},
{
"name": "isJsObject"
},
{
"name": "isLContainer"
},
Expand Down Expand Up @@ -1193,9 +1169,6 @@
{
"name": "iterator"
},
{
"name": "keyValDiff"
},
{
"name": "keyValueArrayGet"
},
Expand Down

0 comments on commit 45d98e7

Please sign in to comment.