From 03d47d570167a5a70b17552ca2c8d531683d900f Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 5 Mar 2021 18:20:04 -0800 Subject: [PATCH] feat(core): manually annotate de-sugarred core tree-shakable providers with @pureOrBreakMyCode (#41096) This is necessary for closure compiler in order to support cross chunk code motion. I'm intentionally not annotating these call sites with @__PURE__ at the moment because build-optimizer does it within the Angular CLI build. In the future we might want to consider having both annotations here in case we change how build-optimizer works. PR Close #41096 --- packages/common/src/viewport_scroller.ts | 2 +- packages/core/src/change_detection/differs/iterable_differs.ts | 2 +- packages/core/src/change_detection/differs/keyvalue_differs.ts | 2 +- packages/core/src/di/injector.ts | 2 +- packages/core/src/sanitization/sanitizer.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/common/src/viewport_scroller.ts b/packages/common/src/viewport_scroller.ts index d74fdbe9d9..a8061f62d0 100644 --- a/packages/common/src/viewport_scroller.ts +++ b/packages/common/src/viewport_scroller.ts @@ -21,7 +21,7 @@ export abstract class ViewportScroller { // De-sugared tree-shakable injection // See #23917 /** @nocollapse */ - static ɵprov = ɵɵdefineInjectable({ + static ɵprov = /** @pureOrBreakMyCode */ ɵɵdefineInjectable({ token: ViewportScroller, providedIn: 'root', factory: () => new BrowserViewportScroller(ɵɵinject(DOCUMENT), window) diff --git a/packages/core/src/change_detection/differs/iterable_differs.ts b/packages/core/src/change_detection/differs/iterable_differs.ts index 69c2d80fb6..edb6b1e3b0 100644 --- a/packages/core/src/change_detection/differs/iterable_differs.ts +++ b/packages/core/src/change_detection/differs/iterable_differs.ts @@ -145,7 +145,7 @@ export function defaultIterableDiffersFactory() { */ export class IterableDiffers { /** @nocollapse */ - static ɵprov = ɵɵdefineInjectable( + static ɵprov = /** @pureOrBreakMyCode */ ɵɵdefineInjectable( {token: IterableDiffers, providedIn: 'root', factory: defaultIterableDiffersFactory}); /** diff --git a/packages/core/src/change_detection/differs/keyvalue_differs.ts b/packages/core/src/change_detection/differs/keyvalue_differs.ts index ac31aa0aab..e6e2698d9a 100644 --- a/packages/core/src/change_detection/differs/keyvalue_differs.ts +++ b/packages/core/src/change_detection/differs/keyvalue_differs.ts @@ -122,7 +122,7 @@ export function defaultKeyValueDiffersFactory() { */ export class KeyValueDiffers { /** @nocollapse */ - static ɵprov = ɵɵdefineInjectable( + static ɵprov = /** @pureOrBreakMyCode */ ɵɵdefineInjectable( {token: KeyValueDiffers, providedIn: 'root', factory: defaultKeyValueDiffersFactory}); /** diff --git a/packages/core/src/di/injector.ts b/packages/core/src/di/injector.ts index f4c5a37071..eff4badb3d 100644 --- a/packages/core/src/di/injector.ts +++ b/packages/core/src/di/injector.ts @@ -105,7 +105,7 @@ export abstract class Injector { } /** @nocollapse */ - static ɵprov = ɵɵdefineInjectable({ + static ɵprov = /** @pureOrBreakMyCode */ ɵɵdefineInjectable({ token: Injector, providedIn: 'any' as any, factory: () => ɵɵinject(INJECTOR), diff --git a/packages/core/src/sanitization/sanitizer.ts b/packages/core/src/sanitization/sanitizer.ts index 026813cb7c..adf9523725 100644 --- a/packages/core/src/sanitization/sanitizer.ts +++ b/packages/core/src/sanitization/sanitizer.ts @@ -17,7 +17,7 @@ import {SecurityContext} from './security'; export abstract class Sanitizer { abstract sanitize(context: SecurityContext, value: {}|string|null): string|null; /** @nocollapse */ - static ɵprov = ɵɵdefineInjectable({ + static ɵprov = /** @pureOrBreakMyCode */ ɵɵdefineInjectable({ token: Sanitizer, providedIn: 'root', factory: () => null,