patriksimek / vm2

Advanced vm/sandbox for Node.js
MIT License
3.86k stars 293 forks source link

CustomRequire and other options are not taken from NodeVM instance options #490

Closed akcyp closed 1 year ago

akcyp commented 1 year ago

In the Typescript definitions we can see that NodeVm.prototype.run accepts only 3 options image

But inside source code of this method we have: https://github.com/patriksimek/vm2/blob/ffa93989fbafb43b7a83633d1665c251eba6f8fb/lib/nodevm.js#L380-L386

This is definitely something wrong with configuration, probably some options like CustomRequire should be taken from this.options. My suggestion is to use merged options object (this.options with options) when it comes to strict and wrapper. Also probably dirname is missing in typescript def.

XmiliaH commented 1 year ago

These undocumented options are currently experimental and therefore not documented. They are used for the NodeVM Resolver functionality, but I have not decided yet to make them official.