https://github.com/jstransformers/jstransformer-babel
Babel support for JSTransformers.
https://github.com/jstransformers/jstransformer-babel
Last synced: 11 months ago
JSON representation
Babel support for JSTransformers.
- Host: GitHub
- URL: https://github.com/jstransformers/jstransformer-babel
- Owner: jstransformers
- License: mit
- Created: 2015-02-24T04:03:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T22:55:45.000Z (about 6 years ago)
- Last Synced: 2024-11-09T19:02:32.012Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://npm.im/jstransformer-babel
- Size: 70.3 KB
- Stars: 4
- Watchers: 6
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.md
Awesome Lists containing this project
README
# jstransformer-babel
[Babel](http://babeljs.io) support for [JSTransformers](http://github.com/jstransformers).
[](https://travis-ci.org/jstransformers/jstransformer-babel)
[](https://codecov.io/gh/jstransformers/jstransformer-babel)
[](http://david-dm.org/jstransformers/jstransformer-babel)
[](https://www.npmjs.org/package/jstransformer-babel)
## Installation
npm install jstransformer-babel
## API
```js
var babel = require('jstransformer')(require('jstransformer-babel'))
var src = 'let a = 0'
var transformed = babel.render(src, {presets: ['es2015']})
//=> '"use strict";\n\nvar a = 0;'
```
Only `render` method is implemented, which means that through the JSTransformer architecture all `render*` APIs are available.
Passing options to Babel is supported as well, and all options unsupported by Babel are filtered out before passing them to Babel.
In babel@6 (jstransformer-babel@2), the default of transpiling from ES2015 is removed. As a result, in order to transpile from ES2015 just like in jstransformer-babel@2, pass in `['es2015']` as the value of the `presets` option, just like in the example above. If that is too laborious, you can look into using a `.babelrc` file.
Babel configuration files like `.babelrc` are also supported. They can only be detected if you use the `renderFile*` APIs or manually pass in a `filename` option.
## License
MIT