TypeScript-Bundle

raw JSON →
1.0.18 verified Sat May 09 auth: no javascript maintenance

A zero-configuration CLI tool for bundling TypeScript source code into a single JavaScript file for browser consumption. Version 1.0.18 supports bundling from .ts, .tsx, or tsconfig.json, with features like asset embedding (text, JSON, base64, buffer, CSS), custom transform pipelines, and global export/injection. It differs from webpack/rollup by focusing solely on TypeScript bundling without configuration, and can work with TypeScript compiler versions as low as 1.8.0. The project appears to be in maintenance mode with no recent releases.

error Cannot find module 'text!./file.txt'
cause TypeScript doesn't understand the 'text!' prefix without a declaration file.
fix
Add a declaration file (e.g., globals.d.ts) with: declare module '*.txt' { const content: string; export default content; }
error error TS2304: Cannot find name 'require'
cause Using Node.js require() in a browser bundle.
fix
Use ES module import/export syntax instead of CommonJS.
error ENOENT: no such file or directory, open './script.ts'
cause The specified input file does not exist or path is incorrect.
fix
Double-check the file path; use absolute path or correct relative path.
gotcha Asset imports (text!, json!, etc.) require TypeScript compiler version 2.2.0 or higher.
fix Upgrade TypeScript to >=2.2.0 or avoid asset imports.
gotcha The bundle output is not minified; you must use a separate minifier for production.
fix Run output through terser or uglify-js.
breaking CLI options are case-sensitive and must be in proper order.
fix Use options as documented: --outFile, --target, etc.
gotcha When using tsconfig.json, the files array must include all entry points.
fix Add all entry .ts files to the files array in tsconfig.json.
npm install typescript-bundle
yarn add typescript-bundle
pnpm add typescript-bundle

Bundle a simple TypeScript module with tsc-bundle into a single JavaScript file.

// Hello.ts
export function hello(name: string): string {
  return `Hello, ${name}!`;
}

// index.ts
import { hello } from './Hello';
const msg = hello('world');
console.log(msg);

// Command line:
// npx typescript-bundle index.ts --outFile bundle.js
// Bundle to bundle.js, then run in browser or Node.