Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/egoist/virtual-module
Run code in sandbox with in-memory module resolution
https://github.com/egoist/virtual-module
evaluate module require-from-string sandbox
Last synced: 2 days ago
JSON representation
Run code in sandbox with in-memory module resolution
- Host: GitHub
- URL: https://github.com/egoist/virtual-module
- Owner: egoist
- License: mit
- Created: 2019-04-24T16:08:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-05T04:01:37.000Z (almost 2 years ago)
- Last Synced: 2024-10-23T07:37:59.051Z (12 days ago)
- Topics: evaluate, module, require-from-string, sandbox
- Language: TypeScript
- Homepage: https://virtual-module.egoist.sh
- Size: 418 KB
- Stars: 62
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-list - virtual-module - memory module resolution | egoist | 64 | (TypeScript)
README
# virtual-module
[![NPM version](https://badgen.net/npm/v/virtual-module)](https://npmjs.com/package/virtual-module) [![NPM downloads](https://badgen.net/npm/dm/virtual-module)](https://npmjs.com/package/virtual-module) [![CircleCI](https://badgen.net/circleci/github/egoist/virtual-module/master)](https://circleci.com/gh/egoist/virtual-module/tree/master) [![chat](https://badgen.net/badge/chat%20on/discord/7289DA)](https://chat.egoist.sh)
**Evaluate a module in sandbox.** This package is extracted and modified from vue-server-renderer.
## Install
```bash
yarn add virtual-module
```## Usage
```js
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 })
//=> trueevaluate('is-three.js')(4)
//=> false
```## API
https://virtual-module.egoist.sh
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## Author
**virtual-module** © [EGOIST](https://github.com/egoist), Released under the [MIT](./LICENSE) License.
Authored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/virtual-module/contributors)).> [egoist.sh](https://egoist.sh) · GitHub [@EGOIST](https://github.com/egoist) · Twitter [@\_egoistlily](https://twitter.com/_egoistlily)