开发者

How can I bootstrap Dojo 1.7 in Node.js?

开发者 https://www.devze.com 2023-03-15 01:46 出处:网络
I\'ve looked at the dojo-node module (https://github.com/agebrock/dojo-node) and the author says that Dojo 1.7 wi开发者_运维百科ll support Node.js natively.

I've looked at the dojo-node module (https://github.com/agebrock/dojo-node) and the author says that Dojo 1.7 wi开发者_运维百科ll support Node.js natively.

There is a configNode.js file in Dojo 1.7, but I'm not sure how to use it to have Dojo up and running.

http://download.dojotoolkit.org/release-1.7.0b1/dojo-release-1.7.0b1/dojo/_base/

Can somebody point me into the right direction? Perhaps show me a small example also?

Appreciate any help I can get.


Here's my solution, although it may look tricky since I can't search out any official examples, I have to read the source and work it out:

  1. Assume dojo is under /home/root/dojoroot/dojo/dojo.js

  2. Create /home/root/mynode/test.js with content:

    dojoConfig = {packages:[{name: 'test', location: '../../mynode'}]};
    require('../dojoroot/dojo/dojo');
    
  3. Create /home/root/mynode/main.js with content:

    define(['dojo/date'], function(date){
        console.log('Hi ' + date.getTimezoneName(new Date()) + ', welcome to NodeJS!');
    });
    
  4. $> node /home/root/mynode/test.js load=test

0

精彩评论

暂无评论...
验证码 换一张
取 消