ts-require

1.0.11 • Public • Published

ts-require

require a ts file in js file Build Status

usage

for example: we have a ts file like this

// demo.ts
export const word = 'hello world!'
export function say() {
    return word
}

in our js file we can require use resolve path

const tsRequire = require('ts-require')();

// this will generate tmp dir in your project
cosnt data = tsRequire(path.resolve(__dirname, './demo.ts'))
// then we can use this module
data.say();
data.word;// hello world

// if you want to del it you can pass delTmp true to it
const tsRequireWithDel = require('ts-require')({
    delTemp: true
})
cosnt data = tsRequire(path.resolve(__dirname, './demo.ts'))
// then we can use this module
data.say();
data.word;// hello world

Readme

Keywords

Package Sidebar

Install

npm i ts-require

Weekly Downloads

28

Version

1.0.11

License

MIT

Unpacked Size

11 kB

Total Files

15

Last publish

Collaborators

  • zhoushaotian