1.0.1 • Published 5 months ago

typescript-remove-decorators-transformer v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

TypeScript Transformer Library

build and test

Table of Contents

Getting Started

Installation

yarn add typescript-remove-decorators-transformer --dev

or

npm install typescript-remove-decorators-transformer --save-dev

Usage with TypeScript Transformers

To use a transformer from this library, you need to pass it to the TypeScript compiler during the compilation process. This can be done by using the customTransformers option of the TypeScript compiler API.

Here is an example of how to use a transformer:

import removeDecoratorsTransformer from 'typescript-remove-decorators-transformer';

const program = ts.createProgram(['./src/main.ts'], {});

const result = program.emit(
  undefined,
  undefined,
  undefined,
  false,
  {
    before: [removeDecoratorsTransformer([
      'Column',
      'Index',
      // decorators to remove
    ])]
  },
);

Usage with ts-loader

If you are using ts-loader, you can use the getCustomTransformers option to provide your custom transformers. Here is an example:

// webpack.config.js
const removeDecoratorsTransformer = require('typescript-remove-decorators-transformer').default;

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        options: {
          getCustomTransformers: program => ({
            before: [removeDecoratorsTransformer([
                'Column',
                // decorators to remove
            ])]
          })
        }
      }
    ]
  }
};

In this example, the removeDecoratorsTransformer is used to remove all decorators from the TypeScript code during the webpack build process.

References

License

MIT License