I have this polyfill.ts file in my app that have these import statements:
import 'zone.js/dist/zone';
import 'core.js';
import 'core-js/modules/es6.map';
import 'regenerator-runtime/runtime';
import 'core-js/es6/reflect';
But upon checking on the console log, it has an Uncaught TypeError in the polyfill.js file (note: error on polyfill.js file, not on the polyfill.ts file)
Is there a way to not load these polyfill files? Is it also possible to delete this polyfill.ts file even though it is auto-created?
I have this polyfill.ts file in my app that have these import statements:
import 'zone.js/dist/zone';
import 'core.js';
import 'core-js/modules/es6.map';
import 'regenerator-runtime/runtime';
import 'core-js/es6/reflect';
But upon checking on the console log, it has an Uncaught TypeError in the polyfill.js file (note: error on polyfill.js file, not on the polyfill.ts file)
Is there a way to not load these polyfill files? Is it also possible to delete this polyfill.ts file even though it is auto-created?
Share Improve this question asked Jan 12, 2022 at 6:49 user8080user8080 752 silver badges5 bronze badges 2- 1 What is the error? – Nalin Ranjan Commented Jan 12, 2022 at 7:09
- @NalinRanjan I am receiving this error in the console --> Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node' – user8080 Commented Jan 12, 2022 at 9:01
3 Answers
Reset to default 10Since Angular 15, the polyfill file is not required anymore.
You can pass zone.js
directly in angular.json
"polyfills": [
"zone.js"
]
See "CLI Improvements" section in the Angular 15 release blog post.
When building the project,polyfill.ts
is used to create polyfill.js
build artifact which contains all the polyfills required to support a missing functionality in older browsers.
Is it also possible to delete this polyfill.ts
Try to avoid deleting this file because polyfill.ts contains zone.js
polyfill. Your app may produce errors when running on older browsers. You can however remove the ones not required by your project.
Here is the summary of what these polyfills do:
import 'zone.js/dist/zone'; : Internally required by angular to create a wrapper around async tasks for change detection & angular renderer to work properly on older browsers.
import 'core.js'; import 'core-js/es6/reflect'; import 'core-js/modules/es6.map'; : Useful for IE support which misses many of the modern ES6 functionalities. You can remove these if you don't support IE.
import 'regenerator-runtime/runtime'; : Adds polyfill for generator/yield functions.
I was able to delete the polyfills.ts file from my project pletely by following Matthieu Riegler's solution and then removing the "polyfills.ts"
from the "files"
area of my "src/tsconfig.*.json" files.