fix(ivy): avoid exposing `ng` with Closure Compiler enhanced optimizations (#33010)
Prior to this commit, the `ng` was exposed in global namespace, which turned out to be problematic when minifying code with Closure, since it sometimes clobber our `ng` global. This commit aligns Ivy debugging tools behavior with existing logic in "platform-browser" package (packages/platform-browser/src/dom/util.ts#L31) by avoiding `ng` in global namespace when Closure Compiler is used. PR Close #33010
This commit is contained in:
parent
0119f46daf
commit
bad3434337
|
@ -61,6 +61,11 @@ export declare type GlobalDevModeContainer = {
|
||||||
* used from the browser console when an application is not in production.
|
* used from the browser console when an application is not in production.
|
||||||
*/
|
*/
|
||||||
export function publishGlobalUtil(name: string, fn: Function): void {
|
export function publishGlobalUtil(name: string, fn: Function): void {
|
||||||
|
if (typeof COMPILED === 'undefined' || !COMPILED) {
|
||||||
|
// Note: we can't export `ng` when using closure enhanced optimization as:
|
||||||
|
// - closure declares globals itself for minified names, which sometimes clobber our `ng` global
|
||||||
|
// - we can't declare a closure extern as the namespace `ng` is already used within Google
|
||||||
|
// for typings for AngularJS (via `goog.provide('ng....')`).
|
||||||
const w = global as any as GlobalDevModeContainer;
|
const w = global as any as GlobalDevModeContainer;
|
||||||
ngDevMode && assertDefined(fn, 'function not defined');
|
ngDevMode && assertDefined(fn, 'function not defined');
|
||||||
if (w) {
|
if (w) {
|
||||||
|
@ -70,4 +75,5 @@ export function publishGlobalUtil(name: string, fn: Function): void {
|
||||||
}
|
}
|
||||||
container[name] = fn;
|
container[name] = fn;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue