how to turn off differential loading in Angular v8

2020-02-08 07:40发布

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.

标签: angular
9条回答
Luminary・发光体
2楼-- · 2020-02-08 08:27

Fastest solution: Switch back to es5 as compilation target in your tsconfig.json.

"compilerOptions": {
        ...
        "target": "es5"
        ...
}

As mentioned on Angular official documentation (https://angular.io/guide/deployment#differential-loading):

To explicitly disable differential loading:

  • Enable the dead or IE browsers in the browserslist config file by removing the not keyword in front of them.
  • Set the target in the compilerOptions to es5.
查看更多
Deceive 欺骗
3楼-- · 2020-02-08 08:35

try changing the tsconfig.json target from es2015back down to es5, this disables differential loading.

查看更多
小情绪 Triste *
4楼-- · 2020-02-08 08:39

in tsconfig.json set target to es2015 if you want to compile for new version first or set it to es5 to disable diffrential loading

"compilerOptions": {
    ...
    "target": "es2015",
    ...
}

and in angular.json change es5BrowserSupport to false

project => app => architect => build => 
"options": {
    ...
    "es5BrowserSupport": false
    ...
}
查看更多
登录 后发表回答