tstc wraps TypeScript compiler to allow transformer plugins.
tstc does its best to keep up with TypeScript releases. We do this by keeping the wrapper shallow and small.
Install using npm
npm i -g typescript-transformer
Then use it just like tsc:
tstc my-file.ts
Every command line flag that's supported by tsc is supported by `tst.
Install plugins from npm and add it under tstPlugins under compilerOptions.
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "dist",
"tstcPlugins": [
{ "name": "sample-tstc-plugin" }
]
}
}Pulgins are applied with the same order of tstcPlugins array.
- CSS Modules plugin
A tstc plugin exports a function that conforms to TSTCPlugin interface as default exports.
import { TSTCPlugin } from 'tstc';
export default const plugin: TSTCPlugin = (transform) => {
// Code here
transform((node) => {
return node;
});
}The "main" field of your plugin package.json should point to JavaScript file that exports the plugin function using CommonJS module.exports.