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.

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.
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.
npm install babili-standalone
yarn add babili-standalone
pnpm add babili-standalone

Shows how to include Babel and Babili scripts from CDN, then run synchronous minification on a simple ES6 class.

<!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>