Skip to content

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

License

Notifications You must be signed in to change notification settings

NikolayMakhonin/require-from-memory

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published