Naka Bundler
The `naka-bundler` package (current version 0.0.7) provides a specialized command-line interface (CLI) for bundling and transpiling JavaScript and TypeScript files. It acts as a lightweight wrapper around Bun, leveraging Bun's performance characteristics to achieve fast compilation times. Developed as an integral part of the `naka` project, it specifically targets browser automation workflows, optimizing file transformations for that context. A key design principle is its performance, achieved by compiling itself into an executable binary using Bun. This allows for rapid execution without reliance on a globally installed `bun` runtime for the end-user. The bundler offers a "batteries-included" experience with no configuration options, making it ideal for straightforward bundling tasks where customization is not required. For advanced or custom configurations, users are advised to interact with Bun directly rather than through `naka-bundler`. As an early-stage project (v0.0.7), its release cadence is likely tied to the development of the broader `naka` ecosystem.
Common errors
-
Error: Cannot find module 'naka-bundler' or TypeError: naka_bundler_1.default is not a function
cause Attempting to `import` or `require` `naka-bundler` as a library module.fixThis package is a CLI. Do not import it; instead, run it directly from your terminal using `npx naka-bundler entry.ts output_dir`. -
naka-bundler: command not found
cause `naka-bundler` is not installed globally, or `npx` cannot locate it in the current environment's `PATH`.fixEnsure `npm` is installed and updated. Use `npx naka-bundler ...` to execute, which handles on-demand installation, or install globally with `npm install -g naka-bundler` for frequent direct invocation. -
Error: Input file 'path/to/entry.ts' does not exist
cause The provided entry file path in the CLI command is incorrect, or the specified file does not exist at that location.fixVerify the absolute or relative path to your entry TypeScript/JavaScript file. Ensure the file specified actually exists at the provided location.
Warnings
- breaking As `naka-bundler` is in early development (v0.0.7), expect frequent and unannounced breaking changes in its CLI arguments, behavior, and underlying Bun integration. Pinning exact versions is highly recommended.
- gotcha The `naka-bundler` is explicitly designed with *no configuration options*. Any bundling requirements beyond its opinionated defaults (e.g., custom plugins, different loaders, advanced optimizations) are not supported.
- gotcha This package is a pure CLI tool and does not expose any programmatic API for use within JavaScript or TypeScript code. Attempting to `import` or `require` it will lead to errors.
Install
-
npm install naka-bundler -
yarn add naka-bundler -
pnpm add naka-bundler
Imports
- nakaBundler
import nakaBundler from 'naka-bundler'
(N/A - CLI tool)
- bundle
import { bundle } from 'naka-bundler'(N/A - CLI tool)
- nakaBundler (CommonJS)
const nakaBundler = require('naka-bundler')(N/A - CLI tool)
Quickstart
npx naka-bundler src/index.ts dist/out # Example with more files or different extensions: npx naka-bundler frontend/main.tsx dist/bundle npx naka-bundler backend/api.js build/server