Node.js require() vs RequireJS?

前端 未结 3 891
北海茫月
北海茫月 2021-02-04 19:38

Hello with RequireJS I can set a base path like this: base : \'./app/\' so when I am in ./app/foo/bar/ for example and I have a script where I use

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 20:06

    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

提交回复
热议问题