Babel Plugin
Adds support for transforming JavaScript or TypeScript with Babel.
Usage
Setup
Install it using npm
npm i -D @reboost/plugin-babel
Install @babel/core
, if not already installed
npm i @babel/core
Import it from the package
const { start } = require('reboost');
const BabelPlugin = require('@reboost/plugin-babel');
Add it to the plugins array
const { start } = require('reboost');
const BabelPlugin = require('@reboost/plugin-babel');
start({
plugins: [
BabelPlugin({
})
]
})
Options
Supports all Babel options.
Example
Speeding up the build by excluding node modules
You may not need babel transformations on node_modules
files. You can simply exclude them by using UsePlugin
.
This will increase performance too.
const { start, builtInPlugins: { UsePlugin } } = require('reboost');
const BabelPlugin = require('@reboost/plugin-babel');
start({
plugins: [
UsePlugin({
include: /.*/,
exclude: /node_modules/,
use: BabelPlugin()
})
]
})
Transforming new features
NOTE: While developing (not production) your app you should not transform
your JavaScript code to support extremely old browsers,
you should transform just the new features or proposals.
const { start, builtInPlugins: { UsePlugin } } = require('reboost');
const BabelPlugin = require('@reboost/plugin-babel');
start({
plugins: [
UsePlugin({
include: /.*/,
exclude: /node_modules/,
use: BabelPlugin({
plugins: [
['@babel/plugin-proposal-pipeline-operator', { proposal: 'smart' }]
]
})
})
]
})
License
Licensed under the MIT License.