Evaluate a module in sandbox. This package is extracted and modified from vue-server-renderer.
yarn add virtual-moduleconst { createModule } = require('virtual-module')
const evaluate = createModule({
  'entry.js': `
    const isThree = require('is-three.js')
    module.exports = context => isThree(context.a + context.b)
  `,
  'is-three.js': `
    module.exports = input => input === 3
  `
})
evaluate('entry.js')({ a: 1, b: 2 })
//=> true
evaluate('is-three.js')(4)
//=> falsehttps://virtual-module.egoist.sh
- Fork it!
 - Create your feature branch: 
git checkout -b my-new-feature - Commit your changes: 
git commit -am 'Add some feature' - Push to the branch: 
git push origin my-new-feature - Submit a pull request :D
 
virtual-module © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).
egoist.sh · GitHub @EGOIST · Twitter @_egoistlily