tinybundle
tinybundle is a minimalist command-line module bundler, currently at version 2.0.0, designed for simple bundling tasks without the complexity of modern bundlers like Webpack or Rollup. It distinguishes itself by eschewing a JavaScript API, relying solely on CLI arguments and a `tbdeps.json` configuration file. This file specifies a list of npm packages and local JavaScript files (prefixed with `!`), optionally allowing for pre-processing commands (prefixed with `?`) to be executed via `system` calls before bundling. The tool does not support traditional loaders, opting instead for this external command execution model. Its release cadence is not specified, but it targets users looking for an extremely lightweight, no-frills bundling solution where custom pre-processing can be scripted externally. It consolidates dependencies and local code into a single, minified output file.
Common errors
-
Error: Cannot find module 'some-package'
cause An npm package listed in `tbdeps.json` was not found in the `node_modules` directory.fixEnsure all required npm packages are installed via `npm install <package-name>` in your project. -
command not found: tinybundle
cause The `tinybundle` executable is not in your system's PATH or not globally installed.fixInstall tinybundle globally using `npm install -g tinybundle` or run it via `npx tinybundle`. -
SyntaxError: Unexpected token '<' (for JSX) or 'SyntaxError: Cannot use import statement outside a module' (for ESM in CJS context)
cause tinybundle does not inherently understand non-standard JavaScript syntax (like JSX) or different module systems (ESM vs. CJS) without pre-processing.fixAdd a pre-processing step using the `?` prefix in `tbdeps.json` to transpile your code (e.g., `?npx buble input.jsx -o output.js`) before including the output with `!`.
Warnings
- gotcha tinybundle is exclusively a CLI tool and offers no programmatic JavaScript API. It cannot be imported or used directly within Node.js applications.
- gotcha The bundler does not support built-in loaders for languages like TypeScript, JSX, or CSS. All non-standard JavaScript must be pre-processed using external commands.
- gotcha Commands prefixed with `?` in `tbdeps.json` are executed as `system()` calls, which can have security implications or unexpected behavior depending on the execution environment and the commands used.
- gotcha tinybundle outputs a single, minified JavaScript file and does not support advanced bundling features like code splitting, tree shaking, or separate asset handling.
- gotcha All npm packages specified in `tbdeps.json` must be pre-installed in your project's `node_modules` directory before running tinybundle.
Install
-
npm install tinybundle -
yarn add tinybundle -
pnpm add tinybundle
Imports
- tinybundle (default import)
import tinybundle from 'tinybundle';
N/A - tinybundle is a CLI-only tool.
- tinybundle (named import)
import { bundle } from 'tinybundle';N/A - tinybundle is a CLI-only tool.
- tinybundle (CommonJS require)
const tinybundle = require('tinybundle');N/A - tinybundle is a CLI-only tool.
Quickstart
mkdir my-bundle-project
cd my-bundle-project
npm init -y
npm install jquery
echo '["jquery", "!index.js"]' > tbdeps.json
echo 'console.log("Hello from index.js!");' > index.js
npx tinybundle ./dist/bundle.js
cat ./dist/bundle.js