virtual-module
Evaluate a module in sandbox. This package is extracted and modified from vue-server-renderer.
Install
yarn add virtual-module
Usage
const { 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 })
evaluate('is-three.js')(4)
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.
Authored and maintained by EGOIST with help from contributors (list).
egoist.sh · GitHub @EGOIST · Twitter @_egoistlily
Type aliases
EvaluateModule
EvaluateModule: function
Type declaration
-
- <TModuleExports, TFile>(file: TFile): TModuleExports
-
Type parameters
-
TModuleExports: any
-
TFile: string
Parameters
Returns TModuleExports
Functions
createModule
-
Parameters
-
-
Default value options: Options = {}