Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(common): make NgLocalization token tree-shakable #45118

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions goldens/public-api/common/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ export class NgLocaleLocalization extends NgLocalization {
export abstract class NgLocalization {
// (undocumented)
abstract getPluralCategory(value: any, locale?: string): string;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<NgLocalization, never>;
// (undocumented)
static ɵprov: i0.ɵɵInjectableDeclaration<NgLocalization>;
}

// @public
Expand Down
2 changes: 1 addition & 1 deletion goldens/size-tracking/aio-payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"master": {
"uncompressed": {
"runtime": 4343,
"main": 450179,
"main": 449672,
"polyfills": 33869,
"styles": 70416,
"light-theme": 77582,
Expand Down
8 changes: 4 additions & 4 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": 126218,
"main": 124515,
"polyfills": 33824
}
}
Expand Down Expand Up @@ -42,7 +42,7 @@
"master": {
"uncompressed": {
"runtime": 2835,
"main": 233348,
"main": 232814,
"polyfills": 33842,
"src_app_lazy_lazy_module_ts": 795
}
Expand All @@ -52,7 +52,7 @@
"master": {
"uncompressed": {
"runtime": 1063,
"main": 158556,
"main": 156042,
"polyfills": 33804
}
}
Expand All @@ -61,7 +61,7 @@
"master": {
"uncompressed": {
"runtime": 1070,
"main": 158300,
"main": 155753,
"polyfills": 33814
}
}
Expand Down
6 changes: 2 additions & 4 deletions packages/common/src/common_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
*/

import {NgModule} from '@angular/core';

import {COMMON_DIRECTIVES} from './directives/index';
import {NgLocaleLocalization, NgLocalization} from './i18n/localization';
import {COMMON_PIPES} from './pipes/index';



// Note: This does not contain the location providers,
// as they need some platform specific implementations to work.
/**
Expand All @@ -30,9 +31,6 @@ import {COMMON_PIPES} from './pipes/index';
@NgModule({
declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
exports: [COMMON_DIRECTIVES, COMMON_PIPES],
providers: [
{provide: NgLocalization, useClass: NgLocaleLocalization},
],
})
export class CommonModule {
}
7 changes: 5 additions & 2 deletions packages/common/src/i18n/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import {Inject, Injectable, LOCALE_ID} from '@angular/core';

import {getLocalePluralCase, Plural} from './locale_data_api';


/**
* @publicApi
*/
@Injectable({
providedIn: 'root',
useFactory: (locale: string) => new NgLocaleLocalization(locale),
deps: [LOCALE_ID],
})
export abstract class NgLocalization {
abstract getPluralCategory(value: any, locale?: string): string;
}


/**
* Returns the plural category for a given value.
* - "=value" when the case exists,
Expand Down
24 changes: 0 additions & 24 deletions packages/core/test/bundling/animations/bundle.golden_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,12 @@
{
"name": "LEAVE_TOKEN_REGEX"
},
{
"name": "LOCALE_DATA"
},
{
"name": "LOCALE_ID2"
},
{
"name": "LifecycleHooksFeature"
},
{
"name": "LocaleDataIndex"
},
{
"name": "MODIFIER_KEYS"
},
Expand Down Expand Up @@ -323,12 +317,6 @@
{
"name": "NULL_REMOVED_QUERIED_STATE"
},
{
"name": "NgLocaleLocalization"
},
{
"name": "NgLocalization"
},
{
"name": "NgModuleRef"
},
Expand Down Expand Up @@ -371,9 +359,6 @@
{
"name": "PlatformRef"
},
{
"name": "Plural"
},
{
"name": "R3Injector"
},
Expand Down Expand Up @@ -851,9 +836,6 @@
{
"name": "getLViewParent"
},
{
"name": "getLocaleData"
},
{
"name": "getNativeByTNode"
},
Expand Down Expand Up @@ -1082,9 +1064,6 @@
{
"name": "listenOnPlayer"
},
{
"name": "locale_en_default"
},
{
"name": "lookupTokenUsingModuleInjector"
},
Expand Down Expand Up @@ -1349,9 +1328,6 @@
{
"name": "transition"
},
{
"name": "u"
},
{
"name": "uniqueIdCounter"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,12 @@
{
"name": "KeyEventsPlugin"
},
{
"name": "LOCALE_DATA"
},
{
"name": "LOCALE_ID2"
},
{
"name": "LifecycleHooksFeature"
},
{
"name": "LocaleDataIndex"
},
{
"name": "MODIFIER_KEYS"
},
Expand Down Expand Up @@ -326,12 +320,6 @@
{
"name": "NgForOf"
},
{
"name": "NgLocaleLocalization"
},
{
"name": "NgLocalization"
},
{
"name": "NgModuleFactory2"
},
Expand Down Expand Up @@ -374,9 +362,6 @@
{
"name": "PlatformRef"
},
{
"name": "Plural"
},
{
"name": "R3Injector"
},
Expand Down Expand Up @@ -905,9 +890,6 @@
{
"name": "getLViewParent"
},
{
"name": "getLocaleData"
},
{
"name": "getNativeByTNode"
},
Expand Down Expand Up @@ -1202,9 +1184,6 @@
{
"name": "leaveViewLight"
},
{
"name": "locale_en_default"
},
{
"name": "lookupTokenUsingModuleInjector"
},
Expand Down Expand Up @@ -1514,9 +1493,6 @@
{
"name": "trackByIdentity"
},
{
"name": "u"
},
{
"name": "uniqueIdCounter"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,12 @@
{
"name": "KeyEventsPlugin"
},
{
"name": "LOCALE_DATA"
},
{
"name": "LOCALE_ID2"
},
{
"name": "LifecycleHooksFeature"
},
{
"name": "LocaleDataIndex"
},
{
"name": "MODIFIER_KEYS"
},
Expand Down Expand Up @@ -314,12 +308,6 @@
{
"name": "NgForm"
},
{
"name": "NgLocaleLocalization"
},
{
"name": "NgLocalization"
},
{
"name": "NgModel"
},
Expand Down Expand Up @@ -368,9 +356,6 @@
{
"name": "PlatformRef"
},
{
"name": "Plural"
},
{
"name": "R3Injector"
},
Expand Down Expand Up @@ -869,9 +854,6 @@
{
"name": "getLViewParent"
},
{
"name": "getLocaleData"
},
{
"name": "getNativeByTNode"
},
Expand Down Expand Up @@ -1163,9 +1145,6 @@
{
"name": "leaveViewLight"
},
{
"name": "locale_en_default"
},
{
"name": "lookupTokenUsingModuleInjector"
},
Expand Down Expand Up @@ -1493,9 +1472,6 @@
{
"name": "trackByIdentity"
},
{
"name": "u"
},
{
"name": "uniqueIdCounter"
},
Expand Down
24 changes: 0 additions & 24 deletions packages/core/test/bundling/router/bundle.golden_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@
{
"name": "KeyEventsPlugin"
},
{
"name": "LOCALE_DATA"
},
{
"name": "LOCALE_ID2"
},
Expand All @@ -275,9 +272,6 @@
{
"name": "LoadedRouterConfig"
},
{
"name": "LocaleDataIndex"
},
{
"name": "Location"
},
Expand Down Expand Up @@ -371,12 +365,6 @@
{
"name": "NavigationStart"
},
{
"name": "NgLocaleLocalization"
},
{
"name": "NgLocalization"
},
{
"name": "NgModuleFactory"
},
Expand Down Expand Up @@ -443,9 +431,6 @@
{
"name": "PlatformRef"
},
{
"name": "Plural"
},
{
"name": "Position"
},
Expand Down Expand Up @@ -1220,9 +1205,6 @@
{
"name": "getLViewParent"
},
{
"name": "getLocaleData"
},
{
"name": "getNativeByTNode"
},
Expand Down Expand Up @@ -1517,9 +1499,6 @@
{
"name": "leaveViewLight"
},
{
"name": "locale_en_default"
},
{
"name": "locateDirectiveOrProvider"
},
Expand Down Expand Up @@ -1892,9 +1871,6 @@
{
"name": "tree"
},
{
"name": "u"
},
{
"name": "uniqueIdCounter"
},
Expand Down