admin管理员组文章数量:1313177
RollupJS module bundler provides a list of possible outputs
- AMD
- CommonJS
- ES Module
- IIFE
- UMD
- SystemJS
Is there a rule of thumb which format should be chosen under a certain circumstance?
amd – Asynchronous Module Definition, used with module loaders like RequireJS
cjs – CommonJS, suitable for Node and Browserify/Webpack
es – Keep the bundle as an ES module file
iife – A self-executing function, suitable for inclusion as a <script> tag. (If you want to create a bundle for your application, you probably want to use this, because it leads to smaller file sizes.)
umd – Universal Module Definition, works as amd, cjs and iife all in one
system – Native format of the SystemJS
RollupJS module bundler provides a list of possible outputs
- AMD
- CommonJS
- ES Module
- IIFE
- UMD
- SystemJS
Is there a rule of thumb which format should be chosen under a certain circumstance?
amd – Asynchronous Module Definition, used with module loaders like RequireJS
cjs – CommonJS, suitable for Node and Browserify/Webpack
es – Keep the bundle as an ES module file
iife – A self-executing function, suitable for inclusion as a <script> tag. (If you want to create a bundle for your application, you probably want to use this, because it leads to smaller file sizes.)
umd – Universal Module Definition, works as amd, cjs and iife all in one
system – Native format of the SystemJS
Share
Improve this question
edited Jul 26, 2018 at 5:01
XYZ
asked Jul 26, 2018 at 4:50
XYZXYZ
27.4k15 gold badges93 silver badges167 bronze badges
1
- 3 "IIFE" <- one of these things is not like the others – Phil Commented Jul 26, 2018 at 4:58
1 Answer
Reset to default 7Building modules and handling dependencies was cumbersome in the past. Newer solutions, in the form of libraries or ES2015 modules, have taken most of the pain away. If you are looking at starting a new module or project, ES2015 is the right way to go. It will always be supported and current support using transpilers and polyfills is excellent. On the other hand, if you prefer to stick to plain ES5 code, the usual split between AMD for the client and CommonJS/Node for the server remains the usual choice.
I remend the lecture of this article, where you will find all the details, pros and cons for each module system :
https://auth0./blog/javascript-module-systems-showdown/
本文标签:
版权声明:本文标题:javascript - Which bundle system should be used AMD, CommonJS, ES Module, IIFE, UMD and SystemJS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741921247a2405018.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论