1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00
execjs/lib
John Hawthorn 06bfd33f7b Use node's vm module to run in clean context
As suggested by Joshua Peek in a previous issue. Node's vm module gives
us full control over the globals passed to the context the code is run
in.

In order to do this we store our code as a JS string, wrap it in an IFFE
(to support the `return` symantics we use for all runtimes)

vm.runInNewContext is called with {filename: "(execjs)"} in order to
have the proper filename appear in backtraces. Normally this string is
inserted into backtraces via a gsub in external_runtime.rb which
replaces the filename.

See https://nodejs.org/api/vm.html
2016-10-10 04:26:31 -07:00
..
execjs Use node's vm module to run in clean context 2016-10-10 04:26:31 -07:00
execjs.rb Explicitly require execjs/module 2011-06-01 21:29:47 -05:00