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

1.0.0 • Public • Published

@emnapi/ts-transform-macro

Example: see https://github.com/toyobayashi/emnapi/blob/main/packages/emnapi/src/macro.ts

// webpack.config.js
const { createTransformerFactory } = require('@emnapi/ts-transform-macro')

module.exports = {
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [
          {
            loader: 'ts-loader',
            options: {
              getCustomTransformers (program) {
                return {
                  before: [
                    createTransformerFactory(program)
                  ]
                }
              }
            }
          }
        ]
      }
    ]
  }
}
// rollup.config.mjs
import { defineConfig } from 'rollup'
import rollupTypescript from '@rollup/plugin-typescript'
import { createTransformerFactory } from '@emnapi/ts-transform-macro'

export default defineConfig({
  plugins: [
    rollupTypescript({
      transformers: {
        before: [
          {
            type: 'program',
            factory: (program) => {
              return createTransformerFactory(program)
            }
          }
        ]
      }
    })
  ]
})

Readme

Keywords

none

Package Sidebar

Install

npm i @emnapi/ts-transform-macro

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

23.3 kB

Total Files

4

Last publish

Collaborators

  • toyobayashi