I am working on a large project consisting of many modules. I implemented my module using Angular 2 rc.3 . I also use webpack to bind the module. Web package output - 3 files: app.js, polyfills.js and vendor.js. app.js contains application code, vendors.js contains imported angular 2 modules and rxjs operators, and polyfills.js contains reflection metadata and zone.js. polyfills.js is compiled from polyfill.ts, which contains:
import 'reflect-metadata'; require('zone.js/dist/zone');
My module is then used as part of a large one-page application. My huge problem is the zone.js dependency. It fixes functions globally. Including this library in my module affects the modules of other commands. And that is unacceptable. There was a problem with zone.js when converting jquery jqXHR to ES2016 Promise. The jqXHR object can be used when it is rejected. Because of this, the resolPromise zone.js function goes into an infinite loop trying to resolve it thenable. And this leads to the browser hanging. I solved this problem, but the main problem is that this problem was not even in my module, but in the module of another command.
So, you see how adding zone.js to my module can lead to errors in other modules. And I cannot allow this.
My question is: how can I use sandbox zone.js only for my module so that it does not affect other modules? This is a peat team, if the angular team did not think about it, because I believe that it will be blocking not only for me, but also for other developers and companies.
source share