ClosestStorm / v8cgi

Automatically exported from code.google.com/p/v8cgi
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Executing arbitrary javascript #59

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
i was thinking of creating a module/function that works like include but
doesnt use exports and executes the code in the same context.

More of like reading the contents of the file and eval'ing it.

can this be part of the API or does this contradict with the module loading
model?

Cause i think there are quite a few use cases of a function like this.

Original issue reported on code.google.com by hle...@gmail.com on 19 Feb 2010 at 3:49

GoogleCodeExporter commented 9 years ago
You are, of course, free to create a function with described behavior. However, 
such
function is very orthogonal to the CommonJS module system (as you already 
mentioned),
as it pollutes the global context and reduces code maintability.

If you care to share your code and intentions, I might be able to give you some 
hints
regarding refactoring to take advantage of require+exports system.

Original comment by ondrej.zara on 19 Feb 2010 at 6:52

GoogleCodeExporter commented 9 years ago
I figured the require+exports system was sufficient for what i needed.

It was just an initial reaction because i was used to includes like those in 
php. I
realized using exports results in much better code.

Thanks anyway :)

Original comment by hle...@gmail.com on 19 Feb 2010 at 8:37

GoogleCodeExporter commented 9 years ago
Glad to be of help :)

Original comment by ondrej.zara on 19 Feb 2010 at 10:34