Angular CLI based projects support polyfills. Here are the steps required to set them up on a newly created project which does not contain them so far:
Create
src/polyfills.tsfile (file name can be choosen freely)Include the file in the
tsconfig.app.tsandtsconfig.spec.tsconfigs, e.g.1{ 2 "compilerOptions": { 3 }, 4 "files": [ 5 "src/polyfills.ts", 6 "src/main.ts" 7 ], 8}Make Angular include the file as a ployfill by adding it to the
polyfillssection in theangular.jsonfile, e.g.1{ 2 "projects": { 3 "architect": { 4 "build": { 5 "options": { 6 "polyfills": [ 7 "src/polyfills.ts", 8 "zone.js" 9 ], 10 } 11 }, 12 "test": { 13 "options": { 14 "polyfills": [ 15 "src/polyfills.ts", 16 "zone.js", 17 "zone.js/testing" 18 ], 19 } 20 } 21 } 22 } 23}
Those changes did the trick for me. Any code located in the polyfills.ts file was included in the transpiled code and added prior to any other application code.