async-module-require
v0.0.4
Published
Load typescript or ecmascript from filepath in Node
Downloads
8
Maintainers
Readme
Load typescript or ecmascript from filepath in Node
Install
npm install --save async-module-require
Usage
const moduleRequire = require('async-module-require');
(async () => {
// path/file.ts
// export default function test() {
// console.log('hello!');
// }
const fileModule = await moduleRequire('/path/file.ts');
fileModule.default();
// -> hello!
})()
API
moduleRequire(filepath, [options])
filepath
Required Type: string
options.extensions
Type: string[]
options.swcConfig
Type: object
swc options