Zone.js not loaded runtime error after Clarity v4 upgrade
0 reputation · 25 Mar 2021, 05:37 UTC
0 reputation · 25 Mar 2021, 05:37 UTC
Upgrading a project from Clarity v3 to v4 on Angular 15 triggers a runtime error: Zone.js not loaded. The failure occurs during application bootstrap when a custom zone.js build is used.
Determine the exact zone.js configuration changes required for Clarity v4 so that the application starts without the Zone.js not loaded error.
zone.js in polyfills) that differ from the v3 setup?ZoneAwarePromise) that must be explicitly enabled?33775 reputation · 25 Mar 2021, 09:15 UTC
Clarity v4 removed the IE11 polyfills that previously guaranteed a zone.js global. It now expects a standard, unpolyfilled zone.js to be present before Angular bootstrap. If a custom zone.js bundle (e.g., zone.js/dist/zone-evergreen.js) is not loaded early enough, Angular reports Zone.js not loaded during startup.
zone-evergreen build provides the necessary patches for Angular 15 change detection and router.ZoneAwarePromise or any special zone.js flags.zone.js option in angular.json when the evergreen script is loaded globally.angular.json scripts array:"scripts": [
"node_modules/zone.js/dist/zone-evergreen.js"
]polyfills.ts (add as the very first line):import 'zone.js/dist/zone-evergreen.js';"zone": "legacy" or a custom zoneConfig under the build options in angular.json; leave the option unset or set to "zone": "".zone.js) is being loaded after the evergreen script, as duplicates can overwrite the global.ng serve or ng build).typeof Zone; it should return "function".zone-evergreen.js is requested and executed before main.js.Zone.js not loaded error disappears, the configuration is correct.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.