ts-optimizer
Set of TypeScript transformers that optimize your code before compilation
⚠️ !!! This module is on Proof of Concept stage, please, be careful using it in production !!!
How to use
Installation
npm i -D ts-optimizer
Webpack integration
const path = ; // Your webpack config... test: /\.tsx?$/ use: loader: 'ts-loader' // or 'awesome-typescript-loader' options: getCustomTransformers: path
or you can create your own transformers list:
// your-transformers.jsmodule { return before: attributesWithTemplateLiterals: 'className' 'class' ;};
and pass it to options
test: /\.tsx?$/ use: loader: 'ts-loader' // or 'awesome-typescript-loader' options: getCustomTransformers: path
Transformers
Template Literals in JSX attributes
This transformer removes unnecessary spaces in template literals in JSX attributes.
By default it processes className
and class
attributes.
Input:
Output:
Arrow functions as class properties
This transformer converts arrow functions from class properties to bound class methods.
Input:
Output: