browserify / requirejs模块和ES6模块有什么区别?

编程入门 行业动态 更新时间:2024-10-15 02:32:36
本文介绍了browserify / requirejs模块和ES6模块有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我仍然是ES6和模块加载程序的新手,我目前正在考虑将browserify设置与ES6相结合。我想知道如果我正在使用ES6模块,是否仍然需要browserify / requirejs。看起来好像都允许你定义模块并导出它们? browserify / requirejs模块和ES6模块有什么区别?

解决方案

玩了一段时间后,我得到了更好的理解的事情,还要感谢@Andy for 由Addy Osmani博客。

$有不同的模块系统:AMD(RequireJS),CommonJS(Node)和新ES6模块语法(当然是旧的ES5全球系统)。 / p>

但是,如果要使用浏览器中的那些,您仍然需要使用某些模块加载程序库加载并连接这些模块,因为浏览器仍然不支持。为此,您可以使用模块加载器,如 RequireJS , Browserify , SystemJS 或 es6-module-loader 。

SystemJS是我个人最喜爱的,因为它允许您加载任何模块系统(AMD,CommonJS,ES6),甚至可以在1个应用中互换使用。

更新:同时 Webpack 已成为可用,也应该被视为模块加载程序。

I'm still new to ES6 and module loaders and I'm currently looking at combining a browserify setup with ES6. I was wondering if I would still need browserify/requirejs if I'm using ES6 modules. Seems like both allow you to define modules and export them? What is the difference between browserify/requirejs modules and ES6 modules?

解决方案

After playing around for a while I did get a better understanding of things, also thanks to @Andy for the blog by Addy Osmani.

There are different module systems: AMD (RequireJS), CommonJS (Node) and the new ES6 module syntax (and the old ES5 Global system of course).

However if you want to use those in your browser you still need to load and wire those modules with some module loader library because browsers still do not support that. For that you could use a module loader like RequireJS, Browserify, SystemJS or es6-module-loader.

SystemJS is my personal favorite because it allows you to load any module system (AMD, CommonJS, ES6) and even use them interchangably in 1 app.

Update: In the mean time Webpack has become available and should be considered as a module loader as well.

更多推荐

browserify / requirejs模块和ES6模块有什么区别?

本文发布于:2023-07-16 02:02:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1116650.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   有什么区别   browserify   requirejs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!