UltraBundle
UltraBundle is an efficient and aggressive JavaScript/TypeScript bundler built upon Rollup, designed for projects requiring optimized output with minimal configuration. Currently at version 1.0.2, it appears to be under active development, though a specific release cadence is not explicitly stated. Its key differentiators include first-class TypeScript support, a comprehensive suite of out-of-the-box optimizations, and a straightforward single JSON file (`bundles.json`) configuration approach. Unlike more complex bundlers, it aims to simplify the bundling process by abstracting away much of the underlying Rollup configuration, providing presets for development, watching, and production builds with optimizations. This tool is intended for bundling application code, not libraries.
Common errors
-
Error: No bundles.json file found in the root directory.
cause The `bundles.json` configuration file is missing or not located in the project's root directory (where `package.json` resides).fixCreate a `bundles.json` file in your project's root directory, ensuring it contains a valid JSON array of bundle configurations. -
Error: Could not resolve 'path/to/module' from 'path/to/source.ts'
cause A module import path could not be resolved by the bundler, typically due to incorrect relative paths, missing `node_modules` installations, or incorrect `baseUrl`/`paths` configuration in `tsconfig.json`.fixDouble-check import paths in your source code. Ensure all dependencies are correctly installed (`npm install`). Verify `tsconfig.json`'s `compilerOptions.paths` and `compilerOptions.baseUrl` are set up correctly if using path aliases. -
TypeError: Cannot read properties of undefined (reading 'value') during build.
cause This generic error often indicates an issue within the Rollup configuration or a plugin, potentially caused by an invalid or unexpected input, or a problem with a specific optimization pass.fixReview your `bundles.json` configuration for any typos or invalid properties. Try a simpler configuration first to isolate the problem. Check for recent changes in UltraBundle or Rollup that might affect your setup. Temporarily disable `--optimize` to see if the issue is related to aggressive optimizations.
Warnings
- breaking As a relatively new project (v1.0.2), UltraBundle's configuration schema (`bundles.json`) or CLI options might undergo breaking changes in future major versions. Users should review release notes carefully when upgrading to new major versions.
- gotcha UltraBundle's 'aggressive' optimizations, powered by Rollup, may unexpectedly remove code or side effects that are crucial for certain libraries or frameworks. This is common with strict tree-shaking.
- gotcha UltraBundle relies on a `bundles.json` file in the project root. If this file is missing, malformed, or located elsewhere, the bundling process will fail or produce an empty output.
- gotcha While UltraBundle ships with TypeScript support, misconfigured `tsconfig.json` or incompatible TypeScript versions can lead to compilation errors during bundling.
Install
-
npm install ultrabundle -
yarn add ultrabundle -
pnpm add ultrabundle
Imports
- ultrabundle CLI (Development)
import { ultrabundle } from 'ultrabundle'"dev": "ultrabundle"
- ultrabundle CLI (Watch Mode)
require('ultrabundle').watch()"watch": "ultrabundle --watch"
- ultrabundle CLI (Production Optimize)
ultrabundle.optimize({ ... })"prod": "ultrabundle --optimize"
Quickstart
{
"name": "my-app",
"version": "1.0.0",
"description": "My UltraBundled application",
"main": "dist/output.js",
"scripts": {
"dev": "ultrabundle",
"watch": "ultrabundle --watch",
"prod": "ultrabundle --optimize"
},
"devDependencies": {
"ultrabundle": "^1.0.0"
}
}
// -- In bundles.json --
[
{
"input": "src/index.ts",
"output": "dist/output.js"
}
]
// -- In src/index.ts --
console.log("Hello from UltraBundle!");
// To run:
// 1. npm install
// 2. npm run dev (for development build)
// 3. npm run watch (for continuous watching and rebuilding)
// 4. npm run prod (for optimized production build)