Tripack Minimal JavaScript Bundler

0.1.1 · active · verified Tue Apr 21

Tripack is a minimal JavaScript bundler, version 0.1.1, specifically designed for educational purposes rather than production use. It aims to demystify the core concepts behind modern bundlers like webpack and Rollup by implementing fundamental features from scratch. These features include AST parsing using `acorn`, building a comprehensive dependency graph, performing ESM to runtime-compatible transformations, and optionally executing export-level tree-shaking. The package emphasizes readability and simplicity in its codebase structure (e.g., `parser.ts`, `resolver.ts`, `treeshaker.ts`). While there's no explicit release cadence, its low version number suggests ad-hoc updates focused on clarity and concept demonstration. Its key differentiator is its role as a learning tool, providing a transparent view into bundling mechanics, unlike complex production-grade alternatives.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install `tripack` globally and use its command-line interface to bundle a JavaScript entry file with optional tree-shaking into a single output file.

npm install -g tripack

# Assuming you have a project structure like:
# my-project/
#   src/index.js
#     console.log('Hello from index!');
#     import { foo } from './foo';
#     console.log(foo);
#   src/foo.js
#     export const foo = 'bar';

# Navigate to your project directory
# cd my-project

# Run tripack to bundle your entry file
tripack --entry src/index.js --out dist/bundle.js --tree-shake

# Verify the bundled output
node dist/bundle.js

# Expected output for the example above:
# Hello from index!
# bar

view raw JSON →