Bundle.js

Bundle.js Documentation

Comprehensive guides and API references for modern JavaScript bundling.

On This Page

Getting Started

Create your first Bundle.js project with a simple configuration script and instant hot module reloading out of the box.

npm init

npm create -i
# or install globally
npm install -g bundle.js

Core Concepts

Tree Shaking

Automatically removes unused code to minimize your final bundle size.

Code Splitting

Split your bundle into multiple files for better performance and load times.

Example Configuration File

// bundle.config.js
export default {
  input: './src/index.js',
  output: {
    file: 'bundle.js',
    format: 'esm'
  }
}

API Reference

bundle.config

Primary configuration object

  • input: string
  • output: object
  • plugins: array
  • watch: boolean

build()

Bundles files and outputs to file system

  • src: string
  • dest: string
  • env: 'dev' | 'prod' | 'test'

watch()

Watches file changes and rebundles

  • src: string
  • watcher: function
  • delay: number

Advanced Usage

TypeScript Configuration

// bundle.config.ts
import { config } from 'bundle.js';

const config: BundleConfig = {
  input: './src/index.ts',
  output: {
    dir: './dist',
    format: 'esm',
    sourcemap: true
  },
  plugins: [typescript()],
  watch: {
    enabled: true,
    delay: 300
  }
};