Closed GoogleCodeExporter closed 9 years ago
Please read https://wiki.mozilla.org/ServerJS/Modules/SecurableModules to
understand
how Securable modules work.
First, include "1.js" searches in global module directory, while system.getcwd()
searches in an absolute path.
Second, include() behaves exactly as require(), but populates global object with
resulting "exports" object. Therefore, in order to have _something_ added to
global
scope, your module needs to add this to "exports" object. See built-in
libraries for
further reference.
Original comment by ondrej.zara
on 12 Jul 2009 at 9:59
> First, include "1.js" searches in global module directory, while
system.getcwd()
searches in an absolute path.
But in http://code.google.com/p/v8cgi/wiki/API#Global_functions :
{{{
# include() - include other file. Four locations are searched for this:
1. current directory for requested file;
What is it "current directory"?
}}}
> Second, include() behaves exactly as require(), but populates global object
with
resulting "exports" object.
Ok, i got it. Maybe in http://code.google.com/p/v8cgi/wiki/API#Global_functions
write
about it like about require()?
Original comment by mr.ve...@gmail.com
on 12 Jul 2009 at 10:13
Exist any way for loading file with modification global without use "exports" in
module? I have some "old-school modules" and i wanna keep it without
modifications.
Original comment by mr.ve...@gmail.com
on 12 Jul 2009 at 10:39
Yes, the documentation was obsolete. I updated it.
Since v8cgi aims for ServerJS compatibility, there are no mechanisms for
including a
file by simply executing it and polluting the global scope.
On the other hand, there is nothing easier than:
var myInclude = function(file) {
var code = new File(file).open("r").read();
eval.call(global, code)
}
Original comment by ondrej.zara
on 13 Jul 2009 at 4:58
Original comment by ondrej.zara
on 29 Jul 2009 at 12:00
Original issue reported on code.google.com by
mr.ve...@gmail.com
on 12 Jul 2009 at 9:43