Virtual module
Run code in sandbox with in-memory module resolution
**Evaluate a module in sandbox.** This package is extracted and modified from vue-server-renderer. The project is written primarily in TypeScript, distributed under the MIT License license, first published in 2019. Key topics include: evaluate, module, require-from-string, sandbox.
Latest release: v0.4.0
February 24, 2020View Changelog →
virtual-module
Evaluate a module in sandbox. This package is extracted and modified from vue-server-renderer.
Install
bashyarn add virtual-module
Usage
jsconst { 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) //=> false
API
https://virtual-module.egoist.sh
Contributing
- 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
Author
virtual-module © EGOIST, Released under the MIT License.<br>
Authored and maintained by EGOIST with help from contributors (list).
egoist.sh · GitHub @EGOIST · Twitter @_egoistlily
Contributors
Showing top 2 contributors by commit count.
This article is auto-generated from egoist/virtual-module via the GitHub API.Last fetched: 6/26/2026
