Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 8, ng build compile twice and duplicate files

Tags:

angular-cli

I have started a new project in Angular 8 and when executing ng build angular compiles twice, I would like to know why

the problem

enter image description here

package-json:

{
  "name": "portability",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.1.0",
    "@angular/cdk": "^8.0.2",
    "@angular/cli": "^8.1.0",
    "@angular/common": "~8.1.0",
    "@angular/compiler": "~8.1.0",
    "@angular/core": "~8.1.0",
    "@angular/flex-layout": "^8.0.0-beta.26",
    "@angular/forms": "~8.1.0",
    "@angular/material": "^8.0.2",
    "@angular/platform-browser": "~8.1.0",
    "@angular/platform-browser-dynamic": "~8.1.0",
    "@angular/router": "~8.1.0",
    "@ngx-translate/core": "^11.0.1",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "rxjs": "~6.5.2",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.801.0",
    "@angular/compiler-cli": "~8.1.0",
    "@angular/language-service": "~8.1.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.4.5"
  }
}

node version: v10.16.0

npm version: 6.10.0

like image 950
Daniel Avatar asked Jul 10 '19 12:07

Daniel


1 Answers

This is a new feature of Angular 8, and it's called Differential Loading.

The two seperate builds you are seeing are for different browser targets - the browser the user uses determines what files angular will serve.

New browsers will get code with modern language features, while older browsers will get stable legacy code.

like image 92
skolldev Avatar answered Nov 02 '22 10:11

skolldev