]>
Commit | Line | Data |
---|---|---|
f0cfe83e AD |
1 | define("dojo/node", ["dojo/has"], function(has){ |
2 | if(! 0 ){ | |
3 | throw new Error("node plugin failed to load because environment is not Node.js"); | |
4 | } | |
5 | ||
6 | return { | |
7 | // summary: | |
8 | // This AMD plugin module allows native Node.js modules to be loaded by AMD modules using the Dojo | |
9 | // loader. Note that this plugin will not work with AMD loaders other than the Dojo loader. | |
10 | // example: | |
11 | // | require(["dojo/node!fs"], function(fs){ | |
12 | // | var fileData = fs.readFileSync("foo.txt", "utf-8"); | |
13 | // | }); | |
14 | ||
15 | load: function(/*string*/ id, /*Function*/ require, /*Function*/ load){ | |
16 | // summary: | |
17 | // Standard AMD plugin interface. See https://github.com/amdjs/amdjs-api/wiki/Loader-Plugins | |
18 | // for information. | |
19 | ||
20 | if(!require.nodeRequire){ | |
21 | throw new Error("Cannot find native require function"); | |
22 | } | |
23 | ||
24 | load(require.nodeRequire(id)); | |
25 | } | |
26 | }; | |
27 | }); |