ncc vs Terser
ncc
github.comTerser
terser.orgSide by side
| Figure | ncc | Terser |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | — |
| Web | — | Yes |
| Windows | — | Yes |
| macOS | — | Yes |
| Linux | Yes | Yes |
| API | — | Yes |
| Plans published | 1 | 1 |
| Spec score · JavaScript Build Tools | 8.2 (#5) | 7.7 (#13) |
| Integrations | The package support guide gives configuration examples for Sequelize with MariaDB and for `@google-cloud/vision` with `google-proto-files`. | The project documentation describes using Terser with Acorn-produced SpiderMonkey AST input and replacing nested `uglify-es` dependencies with a Yarn resolution alias. |
| Purpose | ncc is a CLI that compiles a Node.js module and its dependencies into a single file. | Terser is an industry-standard JavaScript minifier that shrinks variable names, removes whitespace and comments, and drops unused code. |
Plans
In their own words
ncc
ncc is a free, MIT-licensed command-line tool for compiling a Node.js module and its dependencies into one file. It is distributed through npm as `@vercel/ncc`, with `npm i -g @vercel/ncc` given as the global installation command. The project targets publishing minimal npm packages and sending only relevant application code to serverless environments. Its design goals include zero configuration, built-in TypeScript support, and handling Node.js programs and npm modules. Inputs can include TypeScript, binary addons, and dynamic requires. Build options cover minification, source maps, watched builds, external modules, and ECMAScript target selection. Node.js programs can call ncc programmatically with options for caching, externals, minification, source maps, and asset builds. `.ts` and `.tsx` inputs require a `tsconfig.json`. Module-format behavior includes automatic ES module output for `.mjs` files and `.js` files inside a `type: module` package boundary. Support examples cover Sequelize with MariaDB and `@google-cloud/vision` with `google-proto-files`. Dynamically loaded assets that static analysis cannot identify may not work correctly. It runs on Linux.
Terser
Terser is a free, open-source JavaScript minifier that reduces code by shortening variable names, removing whitespace and comments, and dropping unused code. It can be used through a command-line interface or Node.js API; browser loading is supported and exposes a global `Terser` variable with a `.minify` property. The API’s `minify()` enables compression and mangling by default, and both settings can be changed or turned off. The API can return a source map, while the CLI can generate source maps for compressed JavaScript. The CLI accepts multiple input files and parses them in sequence in one global scope, or reads from standard input when no input file is specified. Compatibility options include an ECMAScript target; `ecma` defaults to 5 for compression and output formatting. Property-name mangling can break code, so the documentation says to use it only when its behavior is understood. Built-in DOM property mangling is disabled by default and is not recommended for enabling. Terser also supports Acorn-produced SpiderMonkey AST input and a Yarn resolution alias for nested `uglify-es` dependencies.