包详细信息

require-from-memory

nikolay_makhonin2.5kCC0-1.01.0.2

NodeJs "require" with mock content and file name and supports babel, pirates, etc

require, mock, string, memory

自述文件

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