Package Exports
- vm-worker
- vm-worker/dist/vm-worker.cjs.js
- vm-worker/dist/vm-worker.esm.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vm-worker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
VM Worker
Tiny VM for browser to execute commonjs modules in Web Worker.
Usage
App.js
import VM from 'vm-worker'
const vm = VM({
timeout: 100000 // default 100000ms
})
await vm.require([
{
path: '/dirA/a.js',
url: 'https://xxx.com/a.js',
},
{
path: '/dirB/b.js',
src: 'module.exports = require("../dirA/a")',
},
])
await vm.exec('b.js', 1, 2) // => 3
vm.terminate()
a.js
module.exports = (a, b) => (a + b)
Installation
npm i vm-worker