Say I have a file :
//nonModuled.js
//A non moduled file , let's say I can't "module" it
console.log('0');
function go(a)
{
console.log('go:' + a);
}
And I have another file which I want to get the go function :
//1.js
require('./nonModuled.js');
When I run the html file , I do see the console.log , But I get an error for the go function :
I do understand why it's happening. Also - I know that I can do this patch :
//nonModuled.js
//A non moduled file , let's say I can't touch it
console.log('hello');
window.go = function go(a)
{
console.log('go:' + a);
}
And then in the 1.js file , access window.go but that seems clumsy.
And so I ask :
Question:
How can I get the go function properly ?
It would be nice if I could do something like :
var a= require('./nonModuled.js');
a.go()
Any help ?
