Node.js require() vs RequireJS?

夙愿已清 提交于 2019-12-03 01:40:54
--alias, -a    Register an alias with a colon separator: "to:from"
             Example: --alias 'jquery:jquery-browserify'   

You can register aliases with browserify, so that covers your renaming.

As for your rooted absolute paths, that can't really be done. As mentioned modul8 has a namespacing mechanism to solve this.

I would recommend you pong SubStack in #stackvm on freenode and ask him directly.

It may or may not help you, but I believe the Dojo Frameworks AMD Loader is API compatible with RequireJS and providing you are using a new microkernel does not pollute the global namespace.

I believe it only has require() and define() in the global namespace now.

Anyway their method of dealing with this is to do something like:

require(["dojo/node!util"], function(util){
    // Module available as util
});

The documentation is at http://dojotoolkit.org/reference-guide/1.8/dojo/node.html

Use uRequire which provides a 'bridge' between nodejs require and AMD define modules, without reinventing the wheel (it is build on top of the two standards). It basically converts modules from AMD or commonJS format to the other format or UMD that runs smoothly on both nodejs & the browser.

It is also translating dependency paths with flexible path conventions, so you can have either '../../foo' or 'bar/foo' depending on which makes more sense at the point you are at.

Your AMD or UMD modules are loaded asynchronously on browser (using AMD/requireJs or other AMD loader) and on node the asynchronous require(['dep1', 'dep2'], function(dep1,dep2){...}) is also simulated.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!