Small library and CLI tool to strip decorators and unused imports from a TypeScript project. Using the TypeScript compiler API.
Install the CLI version globally:
npm i -g strip-decorators
Usage: strip-decorators <entrypoint> <path to tsconfig>
Example: strip-decorators ./src/index.ts ./tsconfig.json
Install the dev dependency locally:
npm i -D strip-decorators
Usage:
import { compileFromOptions } = from 'strip-decorators';
import * as tsconfig from './tsconfig.json';
(() => {
const entrypoints = ['./src/index.ts'];
compileFromOptions(entrypoints, tsconfig.compilerOptions);
})();
See the example for more details.
$ git clone https://github.com/jfrazier-eth/strip-decorators.git && cd strip-decorators
$ npm install
$ npm run build
elide-imports.ts
is copied from the angular CLI