angular-cli: ng serve/test/e2e does not work with Internet Explorer 11
🐞 Bug report
Command (mark with an x)
- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
Yes, the previous version in which this bug was not present was: 7.xDescription
A clear and concise description of the problem...Internet Explorer 11 does not load site when using ng serve.
Only errors in the dev console.
🔬 Minimal Reproduction
ng new ienotworking ng serve or ng serve --prod
🔥 Exception or Error
SCRIPT1002: Syntax error
polyfills.js (2891,5)
SCRIPT1002: Syntax error
vendor.js (156,1)
SCRIPT1002: Syntax error
main.js (87,24)
🌍 Your Environment
Angular CLI: 8.0.0-rc.4
Node: 10.15.3
OS: win32 x64
Angular: 8.0.0-rc.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.0-rc.4
@angular-devkit/build-angular 0.800.0-rc.4
@angular-devkit/build-optimizer 0.800.0-rc.4
@angular-devkit/build-webpack 0.800.0-rc.4
@angular-devkit/core 8.0.0-rc.4
@angular-devkit/schematics 8.0.0-rc.4
@angular/pwa 0.12.4
@ngtools/webpack 8.0.0-rc.4
@schematics/angular 7.2.4
@schematics/update 0.800.0-rc.4
rxjs 6.4.0
typescript 3.4.5
webpack 4.30.0
Anything else relevant?
IE11 only.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 20
- Comments: 30 (1 by maintainers)
Hi, thanks for reporting this. However this is now by design in version 8.
By default in version 8 we enable differential loading for
ng build. However forng testandng servewe only generate a single ES2015 build which cannot run in IE 11.There are a couple of options that you can do if you want to have ES5 code during serve.
1. Disable differential loading completely, (Not recommended) You can turn differential loading off by changing the
targetfromes2015toes5in yourtsconfig.json2. Have multiple configurations for serve.
Create a new tsconfig
tsconfig-es5.app.jsonnext totsconfig.app.jsonwith the below contentsIn your
angular.jsonadd two new configuration section under thebuildandservetarget to provide a new tsconfig.You can then run the serve with this configuration using the below command.
From what I can see of the new differential build, the process is effectively done twice. i.e. once for
es5and once fores6. I imagine it would significantly slow down the dev server reload time if differential loading was enabled by default. My project is already pretty slow so I if this was added to the dev server I would vote for it be opt-in. Personally, I think theng serve -c es5workaround is fine, but it would be great if it was documented on the main angular.io site.While that is a “workaround” for now, home come the CLI can’t do differential loading in serve mode also, so the application at least behaves the same for both prod and non-prod?
shouldn’t it read
src/tsconfig-es5.app.jsoninstead?tsconfig.app.jsonlives undersrc/and therefore I createdtsconfig-es5.app.jsonthere, next to it.and I think it is worth pointing out that in
“app” should be replaced by the actual app name (actual key value used under “project” key)
@alan-agius4 can we think about the possibility of adding an option in the cli menus? to ask if we want IE support for
ng serveand auto generatetsconfig.es5.jsonand the needed updates inpackage.json/angular.jsonif the dev answersYes.For me it makes it boring and it’s waste! to do this manually each time i create a project : ) and also you forced [by design] the creation of this -> https://github.com/ChrisMeeusen/ng-ie-serve
Hope you do something (lean) about it, Angular Team.
Try
ng serve --configuration es5, I think the previous mentioned solution was not working causeconfigdoes not exist as an option or alias OOTB@ciesielskico You are mixing up the
serveandbuildsections. Take a closer look at the example above.If this can be usefull to someone else, my coworker was able to figure it out. It was something missing interacting with bootstrap that he fixed with something like this:
Some more testing required but it seem to be fine now.
Hello,
We had the issue too while migrating as we have to support IE10-IE11. I have followed the instructions here and read other related threads and that helped fixing the script issues and supporting IE for local dev testing (ng serve) but there is still a issues in rendering. Could be related to flex / break-points calculations . We use Material with Bootstrap grid for layout (only grid, not full Bootstrap) and nothing really special aside of that.
Is there a way to find what polyfill where removed that could affect css and such?
I will try to compare the runtime of our older 7.x build where everything worked just fine (without anything extra in the polyfill file) but I would gladly take any hint.
Using localhost, I see that style.js have no es5 variant (like we can see in this work in progress document update : https://pr31262-14beff1.ngbuilds.io/guide/deployment), could be a hint?
@sandipsrane, have you tried just using this :
https://github.com/ChrisMeeusen/ng-ie-serve
It should just make all the changes for you. Install it, run it, and move on.
@sandipsrane, did you enable ie mode in the browserlist file
IE 9-11?Why not just add the start:es5 to the angular.json and package.json file and then a user could choose run it or not
Coming from #14656 here 😄, I have one last question:
Why differential loading has only been implemented for
ng build? Why can’t we have anangularCompileroption or anangular.jsonflag to simply activate it no matter what inserve/test/e2e. It could even have a default value to turn it off (ie the new default behaviour)For now and for me the only viable option is to switch from
ng servetong build --watchin combination withnpx serve --single -l 4200. I will then just loose the live reload.EDIT: crap even that is not working, as
ng build --watchalso switch back magically to the same behaviour asng serve→ one single build 😢Workaround not working for me when running
ng serve --config es5. The CLI returnsUnknown option: '--config'andUnknown option: 'es5'I ran
ng s -c=es5which worked for me