Search code examples
angularangular-clipolyfills

Can angular polyfills.ts file be safely removed


Now that angular is working with Ivy and decided to abandon internet explorer.

Shall we safely remove the polyfills.ts file in our Angular >= v13 project?


Solution

  • Angular <=14

    According to the docs, Angular has a mandatory polyfill for zone.js. Without this polyfill, your application may not work. So it is not safe to remove the polyfills.ts file.

    Angular 15+

    Apparently, in Angular v15 the polyfills.ts file is not anymore being added to new projects when using the ng new command, see the updated docs. So after updating to Angular 15, you may be able to remove the polyfills.ts file, if it only contains the zone.js import. However, in this case you will need to add the polyfill via angular.json:

    "polyfills": ["zone.js"]

    Angular 18+

    Since Angular 18, applications can go zoneless, which makes ZoneJS obsolete. Once the zoneless mode is activated with provideExperimentalZonelessChangeDetection(), the zone.js polyfill needs to be removed. In zoneless applications, no polyfills are necessary.

    Zoneless is in experimental stage and may change at any time before being advanced to stable. Use it with caution.