babili-standalone
raw JSON → 0.0.10 verified Fri May 01 auth: no javascript deprecated
Standalone build of Babili (babel-minify) for use in non-Node.js environments including browsers. Version 0.0.10 is the latest stable release. This package is deprecated in favor of babel-standalone's minify preset. It provides a browser-friendly API (Babili.transform) and can be loaded via CDN, Bower, or npm. Key differentiator: It allows client-side ES6+ minification without Node.js setup, but requires Babel-standalone to be loaded first.
Common errors
error ReferenceError: Babili is not defined ↓
cause Babili script loaded before Babel script, or not loaded at all.
fix
Ensure babel.min.js is loaded before babili.min.js and both scripts are in the page.
error Babili.transform is not a function ↓
cause Babili object is undefined or incorrect library version.
fix
Check that you are using the correct CDN URL: https://cdnjs.cloudflare.com/ajax/libs/babili-standalone/0.0.10/babili.min.js
error Cannot find module 'babili-standalone' (when using require) ↓
cause Node.js environment is not supported; this is browser-only.
fix
Use babel-standalone with @babel/preset-minify for Node.js usage.
Warnings
deprecated babili-standalone is deprecated in favor of @babel/preset-minify in babel-standalone. ↓
fix Use babel-standalone with @babel/preset-minify instead.
gotcha Babili.transform requires Babel-standalone to be loaded first. ↓
fix Load babel.min.js before babili.min.js in your HTML.
gotcha Only synchronous transform; no support for asynchronous or streaming transformations. ↓
fix If you need async, switch to babel-standalone with minify preset and use Babel.transformAsync.
Install
npm install babili-standalone yarn add babili-standalone pnpm add babili-standalone Imports
- default (Babili) wrong
import Babili from 'babili-standalone';correct// UMD - loaded via <script> tag const Babili = window.Babili; - transform wrong
Babili.transformAsync(source, options);correctBabili.transform(source, options); - version wrong
Babili.VERSION;correctBabili.version;
Quickstart
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Babili-standalone example</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babili-standalone/0.0.10/babili.min.js"></script>
<script>
var input = 'class Foo { constructor(bar) { this.bar = bar; } }; new Foo();';
var output = Babili.transform(input).code;
console.log(output);
</script>
</body>
</html>