how to turn off differential loading in Angular v8?

后端 未结 10 1908
暖寄归人
暖寄归人 2020-12-05 02:47

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 f

相关标签:
10条回答
  • 2020-12-05 02:56

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

    0 讨论(0)
  • 2020-12-05 02:58

    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
        ...
    }
    
    0 讨论(0)
  • 2020-12-05 02:59

    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",

    0 讨论(0)
  • 2020-12-05 03:04

    None of these answers worked for me on @angular/cli 8.3.8. Using the npx 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 your browserslist to use just 1 older (but still es6/es2015 compliant) browser version

    # we only want es2015 compliant browsers https://caniuse.com/#feat=es6
    # just use one as representative for all
    Chrome >= 61 
    
    0 讨论(0)
  • 2020-12-05 03:04

    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.)

     "browserslist": [
        "last 2 Chrome versions"
      ]
    

    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

    0 讨论(0)
  • 2020-12-05 03:14

    In Angular 8 the file browserlist have to be in project root folder. Following entries were needed on my project to disable differential loading:

    > 0.5%
    last 2 versions
    Firefox ESR
    not dead
    not IE 9-11
    not samsung 4
    not android 4.4.3-4.4.4
    not last 2 ie_mob versions
    not last 2 op_mini versions
    not last 2 op_mob versions
    not last 2 baidu versions
    not last 2 kaios versions
    not last 2 and_uc versions
    not last 2 and_qq versions
    not last 2 edge versions
    not chrome 49
    
    0 讨论(0)
提交回复
热议问题