{"id":22263,"library":"rollup-plugin-ts-treeshaking","title":"rollup-plugin-ts-treeshaking","description":"Rollup plugin that improves TypeScript tree-shaking by replacing `/** @class */` annotations (generated by TypeScript) with `/*@__PURE__*/` comments, enabling UglifyJS/Terser dead code elimination. Version 1.0.2, minimal release cadence. Differentiator: simple transformation approach vs. full AST manipulation.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/ex-machine/rollup-plugin-ts-treeshaking","tags":["javascript","rollup","typescript","treeshaking","tree-shaking","uglify","minify"],"install":[{"cmd":"npm install rollup-plugin-ts-treeshaking","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-ts-treeshaking","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-ts-treeshaking","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"used for createFilter and other utilities","package":"rollup-pluginutils","optional":false},{"reason":"plugin for Rollup bundler (peer dependency)","package":"rollup","optional":false}],"imports":[{"note":"ESM-only; package does not export CommonJS.","wrong":"const tsTreeshaking = require('rollup-plugin-ts-treeshaking')","symbol":"default","correct":"import tsTreeshaking from 'rollup-plugin-ts-treeshaking'"},{"note":"No named export; use default import.","wrong":"import { tsTreeshaking } from 'rollup-plugin-ts-treeshaking'","symbol":"tsTreeshaking","correct":"import tsTreeshaking from 'rollup-plugin-ts-treeshaking'"},{"note":"Options is a type export, should be used with 'import type'.","wrong":"import { Options } from 'rollup-plugin-ts-treeshaking'","symbol":"Options","correct":"import type { Options } from 'rollup-plugin-ts-treeshaking'"}],"quickstart":{"code":"import typescript from 'rollup-plugin-typescript2';\nimport tsTreeshaking from 'rollup-plugin-ts-treeshaking';\n\nexport default {\n  input: 'src/index.ts',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife',\n  },\n  plugins: [\n    typescript({ useTsconfigDeclarationDir: true }),\n    tsTreeshaking(),\n  ],\n};","lang":"typescript","description":"Configure Rollup with typescript2 plugin and ts-treeshaking to enable Terser dead code elimination via @__PURE__ annotations."},"warnings":[{"fix":"Upgrade Rollup to version 1.0.0 or higher.","message":"Requires Rollup 1.x or higher; not compatible with Rollup 0.x.","severity":"breaking","affected_versions":">=1.0.0"},{"message":"rollup-plugin-typescript2 is unmaintained; consider alternatives.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure tsTreeshaking() appears before minify plugin in the plugins array.","message":"Only works if minify plugin (UglifyJS or Terser) runs AFTER this plugin in the Rollup build pipeline.","severity":"gotcha","affected_versions":">=1.0.0"},{"message":"Plugin transforms all .ts and .tsx files by default; set `js: true` option to also process .js/.jsx.","severity":"gotcha","affected_versions":">=1.0.0"},{"message":"May not work with TypeScript 4+ if class annotations are emitted differently.","severity":"gotcha","affected_versions":">=1.0.0"},{"message":"Does not handle async functions or other patterns that generate `@class` annotations.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Upgrade Rollup to version 1.0.0 or higher (npm install rollup@latest).","cause":"Plugin requires Rollup 1.x or higher due to plugin API changes.","error":"Error: The 'rollup-plugin-ts-treeshaking' plugin is not compatible with Rollup 0.x"},{"fix":"Use default import: import tsTreeshaking from 'rollup-plugin-ts-treeshaking'","cause":"Using named import instead of default import.","error":"TypeError: tsTreeshaking is not a function"},{"fix":"Install the package normally; it ships its own types. Ensure tsconfig.json includes 'types': ['rollup-plugin-ts-treeshaking'] or uses node module resolution.","cause":"Missing @types/rollup-plugin-ts-treeshaking or TypeScript not resolving types.","error":"Cannot find module 'rollup-plugin-ts-treeshaking' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}