Bublé
raw JSON → 0.20.0 verified Fri May 01 auth: no javascript maintenance
Bublé is a fast ES2015+ to ES5 compiler that requires zero configuration. Version 0.20.0 is current but in maintenance mode. It was designed before modern browsers supported ES2015, and now only recommended for IE11 compatibility. Unlike Babel, Bublé does not require plugins or presets, making it simpler but less extensible. It supports ES2015 features like arrow functions, template literals, destructuring, and let/const, plus some ES2016/ES2017 features (exponentiation, async/await). No new features will be added; only bugfixes.
Common errors
error Error: Cannot find module 'acorn' ↓
cause Missing acorn dependency (Bublé uses it internally).
fix
Run
npm install buble which includes acorn as a dependency. error TypeError: buble.transform is not a function ↓
cause Invalid import: trying to use ES import syntax on CJS module.
fix
Use
const buble = require('buble'); instead of import buble from 'buble';. error SyntaxError: Unexpected token (1:6): import statement ↓
cause Bublé does not support transforming import/export statements by default.
fix
Add option
transforms: { modules: false } or use Babel for ES modules. Warnings
deprecated Bublé is in maintenance mode; no new features will be added. ↓
fix Consider Babel or SWC for modern needs unless IE11 support is required.
breaking In v0.17+, the 'acorn' dependency changed; custom acorn plugins may break. ↓
fix Update userland plugins to be compatible with acorn 5+.
gotcha Bublé does not support dynamic import() or optional chaining. ↓
fix Use Babel or TypeScript for those features.
gotcha Source maps require magic-string; ensure it is installed. ↓
fix npm install magic-string@^0.25.0 as a dependency.
Install
npm install buble yarn add buble pnpm add buble Imports
- default (transform) wrong
import buble from 'buble';correctconst buble = require('buble'); buble.transform(source); - transform wrong
import { transform } from 'buble';correctconst { transform } = require('buble'); - buble (CLI) wrong
import buble from 'buble';correctconst exec = require('child_process').execSync('buble input.js');
Quickstart
const buble = require('buble');
const result = buble.transform('const x = () => 1;', {
transforms: { modules: false },
source: 'input.js'
});
console.log(result.code); // 'var x = function () { return 1; };'