是否可以将requirejs模块转换为commonjs? [英] Is it possible to convert requirejs modules to commonjs?

查看:89
本文介绍了是否可以将requirejs模块转换为commonjs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经可以将commonjs模块转换为requirejs ,但我仍然想知道是否有可能做相反的事情。有什么方法可以将requireJS模块转换为commonJS,而不是相反?

It's already possible to convert commonjs modules to requirejs, but I still want to know whether it's possible to do the reverse. Is there any way to convert requireJS modules to commonJS, instead of vice versa?

推荐答案

是的,有可能。包括Sound Cloud在内的许多站点都开发了自己的转换工具。

Yes, it is possible. Many sites including Sound Cloud have developed their own conversion tool.

Mozilla开发了一个很好的小模块,名为SweetJS。基本上,您可以在JavaScript中定义宏。要在Node.js中使用,您需要使用二进制文件才能实际使用宏,因为在运行时无法使用。

Mozilla has developed a nice little module called SweetJS. Basically allows you to define macros in JavaScript. To use in Node.js, you'll need to use it's binary to actually use the macros, as it's not available through runtime.

http://sweetjs.org/

编辑:

Yehuda,Ember.js的开发者之一已发布了Transpiler模块。

Yehuda, one of the developers of Ember.js has released a transpiler module.

它是用Ruby编写的,而不是JavaScript,但也许有人会转换过来。尽管如此,您仍可以通过派生一个ruby进程在Node.js中使用它。

It is written in Ruby, and not JavaScript, but perhaps someone will convert it over. Nonetheless, you can use it within Node.js by forking a ruby process.

这篇关于是否可以将requirejs模块转换为commonjs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆