Open
Description
I saw modules are exposed directly into global vars in all cocos-js examples. This won't do any good when project become complex.
Is there a way to simulate a module require in JSB (like Node.JS or require.js)?
I've tried:
file: test.js
(function() {
var a;
cc.log("test executed");
a = {
name: "hahah",
age: 25
};
return a;
}).call(this);
file: main.js
xx = require("src/test.js");
cc.log("xx:" + xx);
I suppose xx
would be a referece to [Object a], but got following instead:
JS: test executed
JS: xx:function require() {
[native code]
}