From f6ee1c22194fb7aa6e5662aee82f291785436b55 Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Fri, 12 Apr 2019 12:39:40 -0700 Subject: [PATCH] fix(ivy): use existing 'goog' declaration for goog.getMsg check (#29873) Previously, this check was done with bracket property access on the global object: global['goog'] This will not be minified when Closure compiles this code, which: 1) breaks, because 'goog' will have been minified but the check won't have taken that into consideration 2) causes build failures in g3, because the actual property 'goog' is forbidden in some published JS code (to ensure obfuscation). A TODO is added to validate that this logic is correct, as it's difficult to test within the Angular repo. PR Close #29873 --- packages/core/src/util/BUILD.bazel | 1 + packages/core/src/util/ng_i18n_closure_mode.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/util/BUILD.bazel b/packages/core/src/util/BUILD.bazel index 982244b765..3ea2b343c1 100644 --- a/packages/core/src/util/BUILD.bazel +++ b/packages/core/src/util/BUILD.bazel @@ -13,6 +13,7 @@ ts_library( ], ), deps = [ + "//packages:types", "//packages/core/src/interface", "@npm//rxjs", ], diff --git a/packages/core/src/util/ng_i18n_closure_mode.ts b/packages/core/src/util/ng_i18n_closure_mode.ts index 8defa1ce58..7ee5abc919 100644 --- a/packages/core/src/util/ng_i18n_closure_mode.ts +++ b/packages/core/src/util/ng_i18n_closure_mode.ts @@ -15,5 +15,6 @@ declare global { if (typeof global['ngI18nClosureMode'] === 'undefined') { // Make sure to refer to ngI18nClosureMode as ['ngI18nClosureMode'] for closure. global['ngI18nClosureMode'] = - typeof global['goog'] !== 'undefined' && typeof global['goog'].getMsg === 'function'; + // TODO(FW-1250): validate that this actually, you know, works. + typeof goog !== 'undefined' && typeof goog.getMsg === 'function'; }