@faasjs/ts-transform
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

@faasjs/ts-transform

Typescript transform based on SWC.

License: MIT NPM Version

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(),
  ],
}

Variables

Functions

Versions

Current Tags

Version History

Package Sidebar

Install

npm i @faasjs/ts-transform

Weekly Downloads

74

Version

2.2.0

License

MIT

Unpacked Size

11.8 kB

Total Files

7

Last publish

Collaborators

  • zfben