I'm experiencing an issue when trying to upgrade to newer Angular/Zone versions and just found out that #748 caused it. I will try to describe below with details as possible:
in my job, we have to shit apps wrapped by an internal platform that patches XMLHttpRequest before Zone.js is loaded. Such library is patching addEventListener and other methods and preventing delegation. So, that makes Zone break, as it relies on delegate to let XMLHttpRequest be patched via EventTarget.
That's not under my team's feasability to change, so, we solved that with this:
require('zone.js/lib/zone');
const patchEventTargetMethods = require('zone.js/lib/common/utils').patchEventTargetMethods;
patchEventTargetMethods(XMLHttpRequest.prototype);
require('zone.js/lib/browser/browser');
that means we patch XMLHttpRequest directly before browser is loaded, so when patchEventTargetMethods runs on EventTarget, it works as expected.
That used to work until 0.8.9.
Between 0.8.10 and 0.8.12, that's no longer possible, as zone.js/lib/zone.ts will complain that Promise is already patched:
Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Since 0.8.13, patchEventTargetMethods was moved into lib/common/events.ts, so I face importing errors, when executing require('zone.js/lib/zone’) - before my call on patchEventTargetMethods:
node_modules/zone.js/lib/common/events.ts:53:26
Cannot find name '_global'.
So, as I understand the main purpose of #748 was about making Zone more modular, I guess there might be another way to reach patchEventTargetMethods and call it directly for XMLHttpRequest before I run into that issue. Or maybe importing a couple of modules instead of just relying on dist/zone.js.
Is there any light that could help me solve this issue? Hopefully I’d like to stick to latest Zone versions, so I’m able to upgrade to Angular 5+.
Thanks.
I'm experiencing an issue when trying to upgrade to newer Angular/Zone versions and just found out that #748 caused it. I will try to describe below with details as possible:
in my job, we have to shit apps wrapped by an internal platform that patches
XMLHttpRequestbefore Zone.js is loaded. Such library is patchingaddEventListenerand other methods and preventing delegation. So, that makes Zone break, as it relies on delegate to letXMLHttpRequestbe patched viaEventTarget.That's not under my team's feasability to change, so, we solved that with this:
that means we patch
XMLHttpRequestdirectly beforebrowseris loaded, so whenpatchEventTargetMethodsruns onEventTarget, it works as expected.That used to work until 0.8.9.
Between 0.8.10 and 0.8.12, that's no longer possible, as
zone.js/lib/zone.tswill complain thatPromiseis already patched:Since 0.8.13,
patchEventTargetMethodswas moved intolib/common/events.ts, so I face importing errors, when executingrequire('zone.js/lib/zone’)- before my call onpatchEventTargetMethods:So, as I understand the main purpose of #748 was about making Zone more modular, I guess there might be another way to reach
patchEventTargetMethodsand call it directly forXMLHttpRequestbefore I run into that issue. Or maybe importing a couple of modules instead of just relying ondist/zone.js.Is there any light that could help me solve this issue? Hopefully I’d like to stick to latest Zone versions, so I’m able to upgrade to Angular 5+.
Thanks.