Registry / devops / build-ts

build-ts

JSON →
library17.1.6jsnpmunverified

build-ts is an opinionated command-line interface (CLI) tool designed to streamline the building of Node.js applications, libraries (including React), and serverless functions (GCP/Firebase) written in TypeScript. It wraps popular tools like Rollup and ts-node, providing simplified commands for common build tasks. The current stable version is 17.1.6, with a rapid release cadence, often featuring daily patch updates to address dependencies and minor bug fixes. Key differentiators include automatic `console.log` removal during builds, optimized `package.json` generation for serverless functions, and distinct commands for different project types (`app`, `lib`, `functions`). While primarily a CLI, it also exposes a programmatic API for advanced usage within larger build systems, making it a versatile choice for TypeScript-centric projects seeking a consistent and opinionated build workflow.

npm install build-ts
INSTALL
IMPORT
SIG · BUILD-TS
B
build-ts
devopsjavascriptv17.1.6
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

buildApp
import { buildApp } from 'build-ts';
const { buildApp } = require('build-ts');
While primarily a CLI tool, `buildApp` can be imported and used programmatically for building Node.js applications. The package is ESM-first, though CommonJS usage is possible.
buildLib
import { buildLib } from 'build-ts';
import buildLib from 'build-ts';
Use named import for `buildLib` to programmatically build Node.js or browser libraries from TypeScript sources.
run
import { run } from 'build-ts';
const run = require('build-ts').run;
`run` allows programmatic execution of TypeScript files, similar to its CLI counterpart `build-ts run`. Ensure proper argument passing when using programmatically.

Demonstrates initializing a TypeScript project, creating a simple function, building it into a Node.js application, and running both the built output and the raw TypeScript file directly using `build-ts`.

mkdir my-ts-app cd my-ts-app npm init -y npm install typescript build-ts mkdir src echo "import { run } from 'node:test';\nimport assert from 'node:assert';\n\nexport function greet(name: string) {\n return `Hello, ${name}!`;\n}\n\nconsole.log(greet('World'));\n\nif (process.env.NODE_ENV === 'test') {\n run('greet function', () => {\n assert.strictEqual(greet('Test'), 'Hello, Test!');\n console.log('Test passed!');\n });\n}" > src/index.ts # Build the application npx build-ts app # Run the built application node dist/index.js # Run the TypeScript file directly using build-ts run npx build-ts run src/index.ts
build-ts --version
Debug
Known issues
breakingThe package requires Node.js version 24 or newer. Running with older Node.js versions will result in an error or unexpected behavior due to engine constraints.
fix
Upgrade your Node.js environment to version 24 or higher. Use `nvm` or your preferred Node.js version manager.
affects: <17.0.0
gotchaBy default, `build-ts` automatically removes `console.log` statements from your code during the build process, which is often desirable for production builds but can be a footgun if debugging or logging is intended to remain.
fix
Review the `build-ts` configuration options for disabling `console.log` removal if your application requires it. For debugging, consider using alternative logging mechanisms or conditional logging based on environment variables.
affects: >=1.0.0
gotcha`build-ts` is an opinionated tool, and its default configurations for Rollup and TypeScript might not align with highly customized project setups. Overriding these defaults can sometimes lead to unexpected build issues.
fix
Carefully read the documentation for configuration options to customize `build-ts` behavior. If issues arise, try to simplify your project's build setup or adapt to the recommended `build-ts` structure before extensive customization.
affects: >=1.0.0
breakingMajor versions of `build-ts` can introduce breaking changes, particularly in how it handles underlying dependencies like Rollup, TypeScript, or specific plugin configurations. Always review release notes for new major versions.
fix
When upgrading to a new major version, thoroughly test your build process and review the official release notes for any migration guides or breaking changes. Pinning minor versions (`~`) in your `package.json` can reduce unexpected build failures, but regular updates are recommended.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The 'engines' field in package.json specifies '{"node": ">=24"}'. You are running Node.js 20.x.x.
Attempting to run `build-ts` with a Node.js version older than the minimum required (v24).
fix
Update your Node.js environment to version 24 or higher. Use `nvm install 24 && nvm use 24` or similar version management tools.
Error: Cannot find module '...' or 'Could not resolve '...' from '...'
This usually indicates an issue with module resolution during the Rollup bundling process, potentially due to incorrect `tsconfig.json` paths, missing dependencies, or incompatible Rollup plugins.
fix
Verify all dependencies are installed, check your `tsconfig.json` for correct `paths` and `baseUrl` settings, and ensure that any custom Rollup plugins are compatible with `build-ts`'s internal Rollup version and configuration.
Error: An @rollup/plugin-commonjs plugin must be configured after other plugins. See https://github.com/rollup/plugins/tree/master/packages/commonjs#usage for more details
A common misconfiguration when adding custom Rollup plugins, where `commonjs` is placed incorrectly in the plugin order.
fix
If you are customizing Rollup plugins via `build-ts` configuration, ensure that `@rollup/plugin-commonjs` is placed *after* other transformation plugins (like `@rollup/plugin-typescript` or `@rollup/plugin-babel`).
Upgrade
Version history
17.1.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources