1.2.0 • Published 3 years ago

module-interop v1.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Get underlying CommonJS/ES6 module with require()

Simple function to determine whether a require()'d object is an ES6 module, and return its .default implementation if so.

Written in Typescript.

How to use

Simply wrap any call to require to get the underlying module:

meaningOfLife.ts

const meaningOfLife = 42;

export default meaningOfLife;
import moduleInterop from "module-interop";

// Doesn't matter if `require` uses `module.exports` or ES6 exports
const meaningOfLife = moduleInterop(require("./meaningOfLife.ts")); // 42

License

MIT

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago