Package Exports
- @reboost/plugin-babel
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@reboost/plugin-babel) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Babel Plugin
Adds support for transforming JavaScript or TypeScript with Babel.
Usage
Setup
- Install it using
npm
npm i @reboost/plugin-babel -D- 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
})
]
})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: [
// Your babel plugin,
// for example
['@babel/plugin-proposal-pipeline-operator', { proposal: 'smart' }]
]
})
})
]
})