Closed GoogleCodeExporter closed 9 years ago
I cannot confirm this. What I tested:
x.js:
=====
exports.x = function () {
y();
}
var y = function () {
system.stdout("y called \n");
}
main.js
=======
var x = require("./x").x;
x();
output:
=======
y called
This is obviously a correct behavior. If you are still having troubles using
require,
it is necessary to post the files which demonstrate your issues.
Original comment by ondrej.zara
on 3 Nov 2009 at 7:20
To provide some more assistance, I just created a wikipage describing how
modules
work and how to use them: http://code.google.com/p/v8cgi/wiki/Modules
Original comment by ondrej.zara
on 3 Nov 2009 at 1:15
ondrey, sorry for the delay. ok, ich have the problem in the weblib. tryied
also with
the var n = require('n').n the effect is the same like require('n')?
i reconstruct the test. require opens the function (works also with three
files).
Original comment by bienmano...@googlemail.com
on 9 Nov 2009 at 12:51
No, those are of course different things! It looks like you still do not get how
require works. By doing "var x = require('somestuff')", you assign the
*exports* of
somestuff to variable x. By doing "var y = require('somestuff').z", you assign
one
concrete part of exports (named "z") to variable y.
Using names mentioned above, one can achieve the same with
var x = require('somestuff');
var y = x.z;
Original comment by ondrej.zara
on 9 Nov 2009 at 7:16
Problem solved.
Original comment by ondrej.zara
on 10 Nov 2009 at 8:48
Original issue reported on code.google.com by
bienmano...@googlemail.com
on 3 Nov 2009 at 12:23