BDR Bundler

1.7.0 · abandoned · verified Sun Apr 19

BDR (BunDleR) is a JavaScript/TypeScript bundler inspired by `bili` and `poi`, originally designed for bundling, transforming, and developing JavaScript projects. It aimed to provide a lightweight alternative for building modern applications, leveraging TypeScript. Originally released with features for source code transformation and development server capabilities, its latest version is 1.7.0, released in September 2019. The project is currently abandoned, with its GitHub repository archived, indicating no further development or maintenance. Users should be aware that it lacks support for newer JavaScript features, security updates, and compatibility with recent Node.js and TypeScript versions, making it unsuitable for new projects or active development.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to programmatically use BDR's `build` function to bundle a simple JavaScript file, including temporary file setup and cleanup for execution.

import { build } from 'bdr';
import path from 'path';
import fs from 'fs';

// Create a dummy source file for demonstration
const entryContent = `
console.log('Hello from BDR!');
export const greeting = 'BDR says hi!';
`;
const srcDir = path.resolve(__dirname, 'temp_bdr_src');
const entryPath = path.resolve(srcDir, 'main.js');
const distPath = path.resolve(__dirname, 'temp_bdr_dist');

fs.mkdirSync(path.dirname(entryPath), { recursive: true });
fs.writeFileSync(entryPath, entryContent);

async function runBuild() {
  try {
    console.log('Starting BDR build...');
    await build({
      entry: entryPath,
      output: {
        dir: distPath,
        format: 'cjs', // 'cjs' or 'esm'
        fileName: 'bundle.js'
      }
    });
    console.log(`Build complete! Output in ${distPath}`);
    const bundleContent = fs.readFileSync(path.join(distPath, 'bundle.js'), 'utf-8');
    console.log('Bundle content preview:\n', bundleContent.substring(0, Math.min(bundleContent.length, 150)) + (bundleContent.length > 150 ? '...' : ''));
  } catch (error) {
    console.error('BDR build failed:', error);
  } finally {
    // Clean up temporary files
    fs.rmSync(srcDir, { recursive: true, force: true });
    fs.rmSync(distPath, { recursive: true, force: true });
    console.log('Cleaned up temporary files.');
  }
}

runBuild();

view raw JSON →