{"id":12931,"library":"build-ts","title":"TypeScript Project Builder","description":"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.","status":"active","version":"17.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/WillBooster/build-ts","tags":["javascript"],"install":[{"cmd":"npm install build-ts","lang":"bash","label":"npm"},{"cmd":"yarn add build-ts","lang":"bash","label":"yarn"},{"cmd":"pnpm add build-ts","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const { buildApp } = require('build-ts');","symbol":"buildApp","correct":"import { buildApp } from 'build-ts';"},{"note":"Use named import for `buildLib` to programmatically build Node.js or browser libraries from TypeScript sources.","wrong":"import buildLib from 'build-ts';","symbol":"buildLib","correct":"import { buildLib } from 'build-ts';"},{"note":"`run` allows programmatic execution of TypeScript files, similar to its CLI counterpart `build-ts run`. Ensure proper argument passing when using programmatically.","wrong":"const run = require('build-ts').run;","symbol":"run","correct":"import { run } from 'build-ts';"}],"quickstart":{"code":"mkdir my-ts-app\ncd my-ts-app\nnpm init -y\nnpm install typescript build-ts\nmkdir src\necho \"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\n\n# Build the application\nnpx build-ts app\n\n# Run the built application\nnode dist/index.js\n\n# Run the TypeScript file directly using build-ts run\nnpx build-ts run src/index.ts","lang":"typescript","description":"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`."},"warnings":[{"fix":"Upgrade your Node.js environment to version 24 or higher. Use `nvm` or your preferred Node.js version manager.","message":"The 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.","severity":"breaking","affected_versions":"<17.0.0"},{"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.","message":"By 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"`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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Major 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.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Update your Node.js environment to version 24 or higher. Use `nvm install 24 && nvm use 24` or similar version management tools.","cause":"Attempting to run `build-ts` with a Node.js version older than the minimum required (v24).","error":"Error: The 'engines' field in package.json specifies '{\"node\": \">=24\"}'. You are running Node.js 20.x.x."},{"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.","cause":"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.","error":"Error: Cannot find module '...' or 'Could not resolve '...' from '...'"},{"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`).","cause":"A common misconfiguration when adding custom Rollup plugins, where `commonjs` is placed incorrectly in the plugin order.","error":"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"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"build-ts"}