Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-cli 8 - Is it possible to build only on es2015?

In version 8 of angular-cli, the build is done 2x. One in es5 and one in es2015.

Is it possible to build only on es2015?

Changing the target to es5, it is done only in es5 .. But I have not found a way to do it only in es2015.

like image 676
Willian Oliveira Avatar asked Jun 07 '19 13:06

Willian Oliveira


People also ask

Why does angular build create files with ES5 and ES2015?

Answer. Angular doesn't bundle the JavaScript files into a single file. You can add a build step to concat the files together. Don't get confused by the ES5 and ES2015 builds, because the Angular team split the bundles depending upon how modules are loaded (not specifically on the JavaScript version).

Is ES5 and ES2015 same?

ES2015 is a huge leap forward from ES5. It adds a tremendous amount of functionality to JavaScript. These features address some of the issues that made ES5 programming challenging. They are optional, as we can still use valid ES5 (including functions) in ES2015.

What build system does angular use?

Angular CLI includes a first-party build system for Angular applications distributed as @angular-devkit/build-angular . This build system is responsible for creating a standalone single-page application (SPA) from user source files and third-party dependencies.


Video Answer


1 Answers

If you update your browserslist accordingly (.browserlistrc-file or browserlist-Array in package.json) and only add browsers which are capable of ES2015, only one build should be created.

For example, when using

"browserslist": [
  "> 5%"
]

I only get one build instead of two builds for es5 and es2015. (Okay, to be fair, only chrome makes it into the list with > 5%...)

(You can also check with npx browserslist for a list of browsers that would currently be supported with your project setup. Also, see the "Differential Loading"-part here for a detailed explanation.)

like image 95
adrianus Avatar answered Oct 09 '22 01:10

adrianus