Registry / devops / minify-ts

minify-ts

JSON →
library1.3.1jsnpmunverified

A TypeScript code minifier leveraging the TypeScript compiler (v1.3.1, stable, quarterly releases) to safely rename variables, classes, functions, properties, and methods to short forms. Unlike general minifiers (e.g., terser), it fully understands TypeScript semantics and respects type safety, preserving exports and type declarations while achieving maximum compression. Key differentiators: AST-based renaming with no risk of breaking type inference, compatible with any TypeScript project, and produces valid JavaScript/TypeScript output.

npm install minify-ts
INSTALL
IMPORT
SIG · MINIFY-TS
M
minify-ts
devopsjavascriptv1.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import minifyTS from 'minify-ts'
const minifyTS = require('minify-ts')
Package is ESM-only. CJS require will fail.
MinifyOptions
import type { MinifyOptions } from 'minify-ts'
import { MinifyOptions } from 'minify-ts'
Type-only import for TypeScript.
minify
import { minify } from 'minify-ts'
import minify from 'minify-ts'
Named export for the minify function.

Minifies a TypeScript string with mangling enabled, outputting as JavaScript. Writes result to file and prints size.

import { minify } from 'minify-ts'; import { writeFileSync } from 'fs'; const code = ` interface User { name: string; age: number; } const user: User = { name: 'Alice', age: 30 }; function greet(user: User): string { return `Hello, ${user.name}!`; } console.log(greet(user)); `; const result = minify(code, { mangle: true, compress: false, output: 'js', }); writeFileSync('output.js', result.code); console.log('Minified size:', result.map ? 'N/A' : result.code.length);
Debug
Known issues
breakingRemoved support for Node 12 in v1.3.0
fix
Use Node 14+ or stay on v1.2.x
affects: >=1.3.0
deprecatedOptions 'compress' and 'sourcemap' deprecated in favor of 'minify' and 'map'
fix
Replace 'compress: true' with 'mangle: true' and use 'map: true' instead of 'sourcemap: true'
affects: >=1.3.0
gotchaInput must be valid TypeScript; invalid syntax causes silent failure
fix
Run tsc --noEmit before minifying to catch syntax errors
affects: *
Errors
Common errors & fixes
TypeError: minify_ts_1.default is not a function
Using CommonJS require with ESM-only package
fix
Switch to ES import: import minifyTS from 'minify-ts'
Error: Cannot find module 'minify-ts'
Package not installed or path incorrect
fix
Run npm install minify-ts
SyntaxError: Unexpected token : (or other TS-specific syntax)
Input contains TypeScript syntax but output is set to 'js' without proper handling
fix
Ensure all TypeScript syntax is valid and set output to 'ts' if preserving types
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
minify-ts — npm install minify-ts · libregistry