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

0.0.3-beta.74 • Public • Published

@faasjs/ts-transform

License: MIT NPM Stable Version NPM Beta Version

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

Modules

Variables

Functions

Variables

NodeBuiltinModules

Const NodeBuiltinModules: string[]

Functions

bundle

bundle(options): Promise<Output>

Parameters

Name Type Description
options Object -
options.externalModules? string[] has excluded node builtin modules
options.filename string -
options.jscTarget? JscTarget default: es2019
options.root? string default: process.cwd()

Returns

Promise<Output>


transform

transform(code, options?): Output

Parameters

Name Type Description
code string -
options? Object -
options.filename? string -
options.jsc? JscConfig swc compilation See https://swc.rs/docs/configuration/compilation
options.root? string default: process.cwd()
options.target? JscTarget default: es2019

Returns

Output

Keywords

none

Install

npm i @faasjs/ts-transform

DownloadsWeekly Downloads

976

Version

0.0.3-beta.74

License

MIT

Unpacked Size

12.8 kB

Total Files

6

Last publish

Collaborators

  • zfben