@faasjs/ts-transform
v4.5.3
Published
Typescript transform based on [SWC](https://swc.rs/).
Downloads
1,740
Readme
@faasjs/ts-transform
Typescript transform based on SWC.
Install
npm install @faasjs/ts-transform
Usage
Use as a register
import { addHook } from 'pirates'
import { transform } from '@faasjs/ts-transform'
addHook((code, filename) => {
if (filename.endsWith('.d.ts')) return ''
return transform(code, { filename }).code
}, {
exts: [
'.jsx',
'.ts',
'.tsx'
]
})
Use as a rollup plugin
import { Plugin, rollup } from 'rollup'
import { bundle } from '@faasjs/ts-transform'
function tsTransform (): Plugin {
return {
name: 'tsTransform',
async transform (code, filename) {
return bundle({ filename })
}
}
}
export default {
input: 'index.ts',
output: {
dir: 'dist',
format: 'es',
},
plugins: [
tsTransform(),
],
}