Registry / serialization / glia-babel-standalone

glia-babel-standalone

JSON →
library6.26.0jsnpmunverified

babel-standalone provides a standalone, browser-ready build of Babel (v6.26.0) with all standard plugins and presets bundled, enabling ES2015+ transpilation in non-Node.js environments like browsers, REPLs, and embedded JavaScript engines. It is a maintained fork of the deprecated babel-browser package, offering similar functionality with automated updates to align with Babel releases. Key differentiators include automatic compilation of <script type='text/babel'> tags, support for custom plugins/presets, and optional integration with babili-minify. It does not support .babelrc due to lack of file system access, and is not a replacement for build-tool integration in Node-based workflows.

npm install glia-babel-standalone
INSTALL
IMPORT
SIG · GLIA-BABEL-STANDAL
G
glia-babel-standalone
serializationjavascriptv6.26.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Babel
import Babel from 'babel-standalone'
const Babel = require('babel-standalone');
ESM default import works in Node when using ESM; in browsers, use the global `Babel` object via script tag.
Babel.transform
Babel.transform(code, options)
Babel.transform(code, opts, callback)
This method is synchronous in standalone; no callback version exists.
Babel.registerPlugin
Babel.registerPlugin('name', pluginFunction)
Babel.plugins.register('name', pluginFunction)
Method is directly on the Babel global, not nested.

Shows in-browser usage: load babel-standalone via unpkg, then transform ES6 arrow function with es2015 preset.

// browser: HTML with script tags // Load standalone Babel from CDN // <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script> // Inline script using text/babel type // <script type="text/babel"> const code = 'const square = n => n * n;'; const result = Babel.transform(code, { presets: ['es2015'] }); console.log(result.code); // ES5 output // </script>
Debug
Known issues
breakingbabel-standalone v7 is not released; v6 is the latest stable. Migration path from babel-browser is breaking due to API changes (no more Babel global in some contexts).
fix
Upgrade to v6 and use Babel.transform instead of older babel-browser API.
affects: <=5
gotcha.babelrc is not supported because no file system is available. All configuration must be passed programmatically or via data-presets/data-plugins attributes.
fix
Always specify presets/plugins explicitly in options or data attributes.
affects: >=6
gotchaAutomatic script tag compilation only works for <script type='text/babel'> or <script type='text/jsx'>. Other types (e.g., 'text/ecmascript-6') are ignored.
fix
Ensure your script tags use the correct type attribute.
affects: >=6
deprecatedThe 'es2015' preset is deprecated in favor of 'env'. Future versions may remove it.
fix
Use presets: ['env'] instead of presets: ['es2015'].
affects: >=6
gotchaBabel version is pinned to 6.26.0; alpha releases of v7 are available but not stable. Do not use v7 alpha in production.
fix
Stick to 6.x for production use.
affects: >=7.0.0-alpha
gotchaWhen using npm package in Node.js, it is not optimized for Node and may contain browser-specific polyfills. Use @babel/core for Node projects.
fix
Use @babel/core in Node environments.
affects: >=6
Errors
Common errors & fixes
Uncaught ReferenceError: Babel is not defined
babel.min.js script not loaded before using Babel in inline script.
fix
Ensure the <script src='https://unpkg.com/babel-standalone@6/babel.min.js'> tag appears before any script that references Babel.
Error: Module not found: Can't resolve 'babel-standalone'
Attempting to import babel-standalone in a bundler without proper configuration.
fix
Use a CDN script tag for browsers, or configure Webpack to resolve browser field. Not recommended for bundling.
Cannot find preset 'env' relative to directory
Trying to use 'env' preset but no preset registered; standalone only includes 'es2015', 'react', 'stage-0' etc., not @babel/preset-env.
fix
Use Babel.registerPreset('env', ...) to register a custom preset or use a bundled preset like 'es2015'.
Upgrade
Version history
6.26.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
glia-babel-standalone — npm install glia-babel-standalone · libregistry