1.0.2 • Published 5 years ago

require-from-memory v1.0.2

Weekly downloads
1,309
License
CC0-1.0
Repository
-
Last release
5 years ago

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Description

Cross platform NodeJs require with mock content and file name and support babel, pirates, etc

import {requireFromString} from 'require-from-memory'

const myModule = requireFromString(
    'export default { ... }', 
    'fake/path/my-module.js',
    options, // optional
) 

/*
options: {
    logFilter(logEvent): boolean // return false to prevent show log
}

logEvent: {
    level: 'INFO' | 'WARNING' | 'ERROR',
    type: 'FindPath',
    message,
    filename,
    code,
    vars: {
        // additional info
    },
    exception,
}
*/

License

CC0-1.0