What is the purpose of esm directories in Angular 2 modules?

I am working with Angular2 RC4:

    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.2",
    "@angular/upgrade": "2.0.0-rc.4",

and I am using JetBrains IntelliJ IDEA 2016.2. When I refer to Angular2 directives, the IDE helps suggest importing a package in which the directive is defined. Unfortunately, the IDE finds several directive definitions, which means that I have to choose the right one from the list that is provided. Sometimes I choose the wrong one, and in the end I will have a large number of compilation errors. As I understand it, the wrong package is always / usually located in the Angular2 distribution directory containing the subfolder esm.

When checking any folder, esmthis content closely simulates the folder from the sibling folder src(for example):

@angular
  common
  + esm
    + src
      + directives
      + facade
      + form-deprecated
      + location
      + pipes
        common_directives.d.ts
        common_directives.js
        common_directives.js.map
        common_directives.metadata.json
        directives.d.ts
        ...
        pipes.js
        pipes.js.map
  + src
    + directives
    + facade
    + form-deprecated
    + location
    + pipes
      common_directives.d.ts
      common_directives.js
      common_directives.js.map
      common_directives.metadata.json
      directives.d.ts
      ...
      pipes.js
      pipes.js.map

1: esm ?

2: Angular2 ?

3: "" 2 / IntelliJ IDEA 2016.2 ?

+4
1

1: esm , ES2015 ( ES6) . , JavaScript-: AMD CommonJS, ES2015 - , . , ES6, : , , , . ES2015 , , , , . , ES2015. , rollup.js JavaScript, .

, Angular esm? , ES2015, , rollup.js, ES2015 - .

2: , ( ) esm , , rollup.js.

3: . esm - , .

- rollup.js. .

Building and Angular 2 Application for Production, , rollup.js .

** **: package.json , , ES2015. jsnext:main. - jsnext: main.

+9

Source: https://habr.com/ru/post/1650564/


All Articles