Registry / devops / rollup-plugin-ts-treeshaking

rollup-plugin-ts-treeshaking

JSON →
library1.0.2jsnpmunverified

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.

npm install rollup-plugin-ts-treeshaking
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-TS-T
R
rollup-plugin-ts-treeshaking
devopsjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import tsTreeshaking from 'rollup-plugin-ts-treeshaking'
const tsTreeshaking = require('rollup-plugin-ts-treeshaking')
ESM-only; package does not export CommonJS.
tsTreeshaking
import tsTreeshaking from 'rollup-plugin-ts-treeshaking'
import { tsTreeshaking } from 'rollup-plugin-ts-treeshaking'
No named export; use default import.
Options
import type { Options } from 'rollup-plugin-ts-treeshaking'
import { Options } from 'rollup-plugin-ts-treeshaking'
Options is a type export, should be used with 'import type'.

Configure Rollup with typescript2 plugin and ts-treeshaking to enable Terser dead code elimination via @__PURE__ annotations.

import typescript from 'rollup-plugin-typescript2'; import tsTreeshaking from 'rollup-plugin-ts-treeshaking'; export default { input: 'src/index.ts', output: { file: 'dist/bundle.js', format: 'iife', }, plugins: [ typescript({ useTsconfigDeclarationDir: true }), tsTreeshaking(), ], };
Debug
Known issues
breakingRequires Rollup 1.x or higher; not compatible with Rollup 0.x.
fix
Upgrade Rollup to version 1.0.0 or higher.
affects: >=1.0.0
deprecatedrollup-plugin-typescript2 is unmaintained; consider alternatives.
affects: >=1.0.0
gotchaOnly works if minify plugin (UglifyJS or Terser) runs AFTER this plugin in the Rollup build pipeline.
fix
Ensure tsTreeshaking() appears before minify plugin in the plugins array.
affects: >=1.0.0
gotchaPlugin transforms all .ts and .tsx files by default; set `js: true` option to also process .js/.jsx.
affects: >=1.0.0
gotchaMay not work with TypeScript 4+ if class annotations are emitted differently.
affects: >=1.0.0
gotchaDoes not handle async functions or other patterns that generate `@class` annotations.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The 'rollup-plugin-ts-treeshaking' plugin is not compatible with Rollup 0.x
Plugin requires Rollup 1.x or higher due to plugin API changes.
fix
Upgrade Rollup to version 1.0.0 or higher (npm install rollup@latest).
TypeError: tsTreeshaking is not a function
Using named import instead of default import.
fix
Use default import: import tsTreeshaking from 'rollup-plugin-ts-treeshaking'
Cannot find module 'rollup-plugin-ts-treeshaking' or its corresponding type declarations.
Missing @types/rollup-plugin-ts-treeshaking or TypeScript not resolving types.
fix
Install the package normally; it ships its own types. Ensure tsconfig.json includes 'types': ['rollup-plugin-ts-treeshaking'] or uses node module resolution.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
rollup-pluginutilsrequiredused for createFilter and other utilities
rolluprequiredplugin for Rollup bundler (peer dependency)
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-ts-treeshaking — npm install rollup-plugin-ts-treeshaking · libregistry