Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Latest commit

 

History

History
87 lines (76 loc) · 2.1 KB

README.md

File metadata and controls

87 lines (76 loc) · 2.1 KB

npm license

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
    })
  ]
})

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' }]
        ]
      })
    })
  ]
})

License

Licensed under the MIT License.