Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ES2015 vs ESM2015

I want to understand the difference between ES2015 and ESM2015. I know that ES2015 is the ES^ standards but recently while compiling my Angular application using ng build I got the following : Compiling @angular/core : es2015 as esm2015

I want to know why ESM2015? Is it minified ES2015 files?

like image 992
Bhumi Singhal Avatar asked May 03 '20 09:05

Bhumi Singhal


People also ask

What is difference between ES2015 and ESM2015?

In case you are wondering about terminology, ESM2015 is a pure ES2015 (ES6) distribution of Angular. ESM5 is a hybrid format consisting mostly of regular ES5 JavaScript, but with import/export statements added as the only ES2015 feature.

What is FESM2015?

The shortened name "FESM" (pronounced "phesom") can have a number after it such as "FESM5" or "FESM2015". The number refers to the language level of the JavaScript inside the module. So a FESM5 file would be ESM+ES5 (import/export statements and ES5 source code).


2 Answers

According to the documentation for Angular Package Format:

Short for ECMAScript Modules. A file containing statements that import and export symbols. This is identical to the definition of modules in the ECMAScript spec.

like image 151
Bhumi Singhal Avatar answered Oct 14 '22 18:10

Bhumi Singhal


When a project is compiled from es2015 to esm2015, like Compiling @angular/core : es2015 as esm2015

Basically it is still EcmaScript, but esm is based on modules "or packages", this allows to make some parts of the code independent from others.

Other differences between modules and standard scripts:

  • modules use strict mode automatically.
  • modules are deferred automatically (when are loading).
  • Modules are only executed once, even if they have been referenced in multiple tags.
  • Modules features are imported into the scope of a single script — they aren't available in the global scope.

more info here

like image 34
Shoniisra Avatar answered Oct 14 '22 18:10

Shoniisra