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
This commit is contained in:
Alex Rickabaugh 2019-04-12 12:39:40 -07:00
parent d6b474f2f8
commit f6ee1c2219
2 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,7 @@ ts_library(
],
),
deps = [
"//packages:types",
"//packages/core/src/interface",
"@npm//rxjs",
],

View File

@ -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';
}