I am using Nodejs for writing some sample programs, which should also be callable from a browser. I am facing an issue with calling JavaScript files from within Nodejs, in a way that would be compatible with browser JS semantics as well (so require, which is Node specific, won't do the job).
Suppose I have three .js files: "A.js", "B.js" and "C.js". "A.js" is written in Node. "B.js" and "C.js" are written in pure JavaScript (that is, they should be callable from a browser).
I need to call a function b() present in "B.js" from "A.js". So I eval() "B.js" exporting the method b(). This works properly. The problem occurs when my function b() in "B.js" calls a function c() in "C.js".
B.js:
function b()
{
console.log('In function b');
c();
}
C.js:
function c()
{
console.log('In function c');
}
How do i make sure the dependancy is resolved? Any help would be appreciated. Thanks!!!