Closed dvkch closed 10 months ago
ExecJS
is a compatibility layer to allow switching between multiple backends, as such it limits the capability to the common denominator of all possible backends. That only make sense for libraries that need to execute some JS code but don't want to force a specific backend on their users.
In your case it seems you don't need this switching capability anyway, and you require specific features. So you might as well use MiniRacer
directly without the ExecJS
layer.
Fair enough, I'll look into that, thank you for your answer :)
I'm currently using ExecJS to allow mini scripts to be written in a backoffice, to create small functions that can convert an input value into another.
While using Duktape worked wonders, it doesn't support recent JS syntax (like string interpolation, String.prototype.padStart, etc), I switched to MiniRacer to avoid using an external runtime.
I am now facing the following error :
JS script
Ruby code
Exception
This seems linked to the fact that input values are sent as JSON in MiniRacerRuntime, see https://github.com/rails/execjs/blob/5f78865d36976f85b42e8529dec272285d8f3b85/lib/execjs/mini_racer_runtime.rb#L33.
Would there be any other way to improve the situation ? I'm open to using another interpreter, but keeping a recent enough dialect of JS + disallowing external runtime seems to limit the choices only to MiniRacer (unless you are running ruby truffle)
Thanks!