Angular-CLI v8 implemented differential loading. But I don't need files built by es5. I want to decrease deploy quantity.
I tried below. But CLI has generated es5 files.
- set
es5browsersupport: false
in angular.json, and got error. - exclude Chrome 41, IE 9-11 and ie_mob 11 from browserList.
None of these answers worked for me on
@angular/cli 8.3.8
. Using thenpx browserslist
I could see that there were more browsers in the list than these StackOverflow answers were up-to-date for.To keep it simple and ensure differential loading doesn't try to build for
es5
, you can set yourbrowserslist
to use just 1 older (but stilles6/es2015
compliant) browser versionIn Angular 8 the file browserlist have to be in project root folder. Following entries were needed on my project to disable differential loading:
Can add below env variables to disable differential loading features. The below works for Windows
"build:prod": "set NG_BUILD_DIFFERENTIAL_FULL=true && ng build --prod",
For Mac
"build:prod": "NG_BUILD_DIFFERENTIAL_FULL=true; ng build --prod",
I succeeded to build without es5 files in Angular v8-rc4.
set like below in browserList to make
isEs5SupportNeeded
false in build-angular.refer to this list. https://caniuse.com/#feat=es6-module
At the moment many people have es5 bundle generated because @angular/cli does not consider latest Edge (i.e., Edge 18) to be es2015-modules compliant: https://github.com/angular/angular-cli/issues/14580.
A dirty fix is to exclude Edge from the list of browsers you support (in theThis problem should be fixed if you upgrade to @angular/cli 8.1.0.browserslist
file).I was able to solve for my project using Angular 8.1.1 by adding the "browserslist" key in
package.json
. (Placed at top level, same as "name", "dependencies", etc.)This case works in specific cases where you only need the app to work in Chrome. If you need more browser compatibility check out other options in the implementation docs here: https://www.npmjs.com/package/browserslist