https://github.com/esbenp/babel-standalone-bower
Standalone build of Babel for use in non-Node.js environments, including browsers. Similar to the (now deprecated) babel-browser.
https://github.com/esbenp/babel-standalone-bower
Last synced: 5 months ago
JSON representation
Standalone build of Babel for use in non-Node.js environments, including browsers. Similar to the (now deprecated) babel-browser.
- Host: GitHub
- URL: https://github.com/esbenp/babel-standalone-bower
- Owner: esbenp
- License: mit
- Fork: true (babel/babel-standalone)
- Created: 2015-12-07T11:57:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-07T12:24:11.000Z (over 9 years ago)
- Last Synced: 2025-01-15T14:02:03.376Z (5 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
babel-standalone
================babel-standalone is a standalone build of Babel for use in non-Node.js environments, including browsers. It's bundled with all the standard Babel plugins and presets.
But why?!
---------It's true that using Babel through Webpack, Browserify or Gulp should be sufficient for most use cases. However, there are some valid use cases for babel-standalone:
- Sites like [JSFiddle](https://jsfiddle.net/), [JS Bin](https://jsbin.com/), the [REPL on the Babel site](http://babeljs.io/repl/), etc. These sites compile user-provided JavaScript in real-time.
- Apps that embed a JavaScript engine such as V8 directly, and want to use Babel for compilation
- Apps that want to use JavaScript as a scripting language for extending the app itself, including all the goodies that ES2015 provides.
- Integration of Babel into a non-Node.js environment ([ReactJS.NET](http://reactjs.net/), [ruby-babel-transpiler](https://github.com/babel/ruby-babel-transpiler), [php-babel-transpiler](https://github.com/talyssonoc/php-babel-transpiler), etc).Installation
------------babel-standalone can be installed via NPM:
```
npm install --save babel-standalone
```Or grab `babel.js` and/or `babel.min.js` from the [GitHub releases page](https://github.com/Daniel15/babel-standalone/releases)
Usage
-----Load `babel.js` or `babel.min.js` in your environment. This will expose [Babel's API](http://babeljs.io/docs/usage/api/) in a `Babel` object:
```js
var input = 'const getMessage = () => "Hello World";';
var output = Babel.transform(input, { presets: ['es2015'] }).code;
```Note that `.babelrc` doesn't work in babel-standalone, as no file system access is available. The presets and/or plugins to use **must** be specified in the options passed to `Babel.transform`.