admin管理员组文章数量:1418074
In the folder generated by ng build simple-lib
, I see a more plex structure than my other node modules. Instead of an index.js exporting and importing other members, I see a bundles
, esm2015
, esm5
, and public_api.d.ts
.
I see the piled versions of simple-lib in both the esm5 and esm2015 folders. I'm wondering how the esm .js files are used and when esm2015 would be used instead of esm5. From what I understand, esm2015 allows for smaller bundles and tree-shaking, but I'm not sure when the choice is made about which module to use. I'm hoping to generate a lib that I can use in a node project and any help to understand if and how that would be possible would be appreciated. Thanks.
$ tree simple-lib/
simple-lib/
├── bundles
│ ├── simple-lib.umd.js
│ ├── simple-lib.umd.js.map
│ ├── simple-lib.umd.min.js
│ └── simple-lib.umd.min.js.map
├── esm2015
│ ├── lib
│ │ ├── simple-libponent.js
│ │ ├── simple-lib.module.js
│ │ └── simple-lib.service.js
│ ├── public_api.js
│ └── simple-lib.js
├── esm5
│ ├── lib
│ │ ├── simple-libponent.js
│ │ ├── simple-lib.module.js
│ │ └── simple-lib.service.js
│ ├── public_api.js
│ └── simple-lib.js
├── fesm2015
│ ├── simple-lib.js
│ └── simple-lib.js.map
├── fesm5
│ ├── simple-lib.js
│ └── simple-lib.js.map
├── lib
│ ├── simple-libponent.d.ts
│ ├── simple-lib.module.d.ts
│ └── simple-lib.service.d.ts
├── package.json
├── public_api.d.ts
├── simple-lib.d.ts
└── simple-lib.metadata.json
In the folder generated by ng build simple-lib
, I see a more plex structure than my other node modules. Instead of an index.js exporting and importing other members, I see a bundles
, esm2015
, esm5
, and public_api.d.ts
.
I see the piled versions of simple-lib in both the esm5 and esm2015 folders. I'm wondering how the esm .js files are used and when esm2015 would be used instead of esm5. From what I understand, esm2015 allows for smaller bundles and tree-shaking, but I'm not sure when the choice is made about which module to use. I'm hoping to generate a lib that I can use in a node project and any help to understand if and how that would be possible would be appreciated. Thanks.
$ tree simple-lib/
simple-lib/
├── bundles
│ ├── simple-lib.umd.js
│ ├── simple-lib.umd.js.map
│ ├── simple-lib.umd.min.js
│ └── simple-lib.umd.min.js.map
├── esm2015
│ ├── lib
│ │ ├── simple-lib.ponent.js
│ │ ├── simple-lib.module.js
│ │ └── simple-lib.service.js
│ ├── public_api.js
│ └── simple-lib.js
├── esm5
│ ├── lib
│ │ ├── simple-lib.ponent.js
│ │ ├── simple-lib.module.js
│ │ └── simple-lib.service.js
│ ├── public_api.js
│ └── simple-lib.js
├── fesm2015
│ ├── simple-lib.js
│ └── simple-lib.js.map
├── fesm5
│ ├── simple-lib.js
│ └── simple-lib.js.map
├── lib
│ ├── simple-lib.ponent.d.ts
│ ├── simple-lib.module.d.ts
│ └── simple-lib.service.d.ts
├── package.json
├── public_api.d.ts
├── simple-lib.d.ts
└── simple-lib.metadata.json
Share
Improve this question
asked Dec 21, 2018 at 11:54
David StreidDavid Streid
7243 gold badges12 silver badges25 bronze badges
2 Answers
Reset to default 2While updating my angular version, I think I may have found the answer. The library that will be used is dependent on the browser requesting the application - The esm5 build will be used for older browsers that require more polyfills and the esm2015 libraries will be used for newer browsers that require fewer polyfills
"The CLI's build mand now automatically creates a modern ES2015 build with minimal polyfills and a patible ES5 build for older browsers, and loads the appropriate file based on the browser. You may opt-out of this change by setting your target back to es5 in your tsconfig.json. Learn more on angular.io."
From https://update.angular.io/#7.1:9.0
As per the "Angular Package Format" specs -
In today’s JavaScript landscape, developers will consume packages in many different ways. For example, some may use SystemJS, others could use Webpack. Still, others might consume packages in Node or maybe in the browser as a UMD bundle or through global variable access.
Read more from this link - https://docs.google./document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview
本文标签:
版权声明:本文标题:javascript - How and when are the esm5 and esm2015 directories of a "ng build"-generated lib folder used? - St 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745246672a2649584.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论