A component I'm using in Angular overwrites window.Promise when loaded and causes a Zone.js error. To fix this, I've moved import 'zone.js/dist/zone';
from polyfills.ts and adding it to main.ts so that it gets loaded after the component. This isn't ideal, but I can't easily fix this component and it solves the issue when not using ahead-of-time compilation.
When I use ng serve --aot
, however, window.Promise gets overwritten again and the error re-appears. I'm not sure why, but I'm guessing either the compiler is ignoring the import or it's no longer being imported after the component.
I've been through the Angular docs and tried setting various compiler options on/off, but I can't find anything related to this. How can I make sure this import appears in the AoT build and/or that things get loaded in the right order?
I've created an example of the problem here: https://github.com/DrRelling/jubilant-octo-sniffle. Using ng-serve
, it works fine and just displays a list of dates; using ng serve --aot
it doesn't display anything and shows the error in the console.