Search code examples
angularpolyfills

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+

    Angular is currently implementing a new reactive system based on Signals. According to the Signals RFC, components will be able to switch to Signals change detections, which works without zone.js. Applications with only Signal-based components can go zoneless. Once the zoneless mode is activated with provideExperimentalZonelessChangeDetection(), the zone.js polyfill can be safely removed.

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