When I generate a project with Angular CLI (8.0.0), I run ng serve
, open the application up in Internet Explorer and I am presented with a blank screen.
I had a look at the polyfills.ts
files and I uncommented the following lines:
import 'classlist.js'; import 'web-animations-js';
I've also removed all core.js imports as Angular 8 supports core.js 3.0 directly.
I've also ran npm i
.
package.json:
"dependencies": { "@angular/animations": "~8.0.0", "@angular/common": "~8.0.0", "@angular/compiler": "~8.0.0", "@angular/core": "~8.0.0", "@angular/forms": "~8.0.0", "@angular/platform-browser": "~8.0.0", "@angular/platform-browser-dynamic": "~8.0.0", "@angular/router": "~8.0.0", "classlist.js": "^1.1.20150312", "rxjs": "~6.4.0", "tslib": "^1.9.0", "web-animations-js": "^2.3.1", "zone.js": "~0.9.1" }, "devDependencies": { "@angular-devkit/build-angular": "~0.800.0", "@angular/cli": "~8.0.0", "@angular/compiler-cli": "~8.0.0", "@angular/language-service": "~8.0.0", "@types/node": "~8.9.4", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "codelyzer": "^5.0.0", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.4.3" }
tsconfig.json:
{ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "module": "esnext", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, "target": "es2015", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2018", "dom" ] } }
EDIT:
browserlists:
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. # For additional information regarding the format and rule options, please see: # https://github.com/browserslist/browserslist#queries # You can see what browsers were selected by your queries by running: # npx browserslist > 0.5% last 2 versions Firefox ESR not dead IE 9-11 # For IE 9-11 support, remove 'not'.
EDIT 2:
The console in Internet Explorer (11) shows the following errors:
polyfills.js: Syntax error (3168, 5)
(line 3168 beginning) -> class Zone {
vendor.js: Syntax error (156, 1)
(line 156 beginning) -> class PlatformLocation {
main.ts: Syntax error (95, 20)
(points to the AppComponent)
What else do I need to do?
The Angular team is deprecating support for Internet Explorer 11 in Angular v12 (to be released in May 2021 and supported through November 2022), and plans to remove support for this browser in Angular v13 (late 2021).
Since Angular CLI 8, there is a new feature called Differential Loading. If you updated through the CLI, running ng serve will target ES2015 by default, which IE11 and older browsers do not support.
Google has removed IE11 support in Angular 13. In the company that I work for, we have to keep IE11 support for the next few months due to contractual obligations.
Internet Explorer 11 is a legacy browser and support for it in Angular 13 is being dropped officially. Sticking with Angular 12 is not a viable long term option. Here are ways to support your users when upgrading your Angular version.
Sticking with Angular 12 is not a viable long term option. Here are ways to support your users when upgrading your Angular version. As an Angular developer, you want to provide support for as many browsers as you can, but in the case of Internet Explorer 11, this is becoming increasingly difficult, and soon will no longer be possible.
First use Angular CLI to generate and serve a starter application: Point basically any browser except Internet Explorer at: http://localhost:4200 and you will see the basic Angular CLI application that we all know and love. In Firefox it looks like this: But, if we try to use Internet Explorer, we see something like this:
Current market share is likely less than 1% and will drop even more as Microsoft retires IE 11 in June 2022 . Even more challenging is that Angular 12 doesn't offer support for IE 11 by default, and Angular 13, coming out next week, is completely dropping support . Update tsconfig.json to use ES5 and update polyfills.ts for ES6/ES7
According to this issue reply
You need to follow the following steps
tsconfig.es5.json
next to tsconfig.json with the below contents{ "extends": "./tsconfig.json", "compilerOptions": { "target": "es5" } }
angular.json
Under projects:yourAppName:architect:build:configurations
, add"es5": { "tsConfig": "./tsconfig.es5.json" }
and projects:yourAppName:architect:serve:configurations
add
"es5": { "browserTarget": "yourAppName:build:es5" }
Remember to change yourAppName in app:build:es5 to yourAppName!
full path shown below
"build": { "builder": "@angular-devkit/build-angular:browser", "options": { ... }, "configurations": { "production": { ... }, "es5": { "tsConfig": "./tsconfig.es5.json" } } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { ... }, "configurations": { "production": { ... }, "es5": { "browserTarget": "yourAppName:build:es5" } } },
ng serve --configuration es5
Go to "tsconfig.json" and use target: "es5" instead of "target": "es2015",
target which is inside compileOnSave\compilerOptions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With