0.0.4 • Published 3 months ago

async-module-require v0.0.4

Weekly downloads
-
License
Apache License
Repository
github
Last release
3 months ago

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