patriksimek / vm2

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

Use external modules without filesystem access #529

Open code4break opened 1 year ago

code4break commented 1 year ago

Hello,

I use vm2 with externals modules. This works fine on my developer machine within VS Code.

For production I use pm2 on Windows machine, which has no file access at runtime.

Is it possible to include the files from node_modules to vm2 before runtime?

Thanks

CheerlessCloud commented 1 year ago

If I understood your question correctly, you want to put all the code together with dependencies into one file which you can then read and run on vm2 without the need to pass require/dependencies into context manually. I think @vercel/ncc might work for you. Under the hood is a webpack with additional plugins that help you to properly build a script for nodejs into single file bundle with all the dependencies.