Babel Plugin

Description

Transpile code to different dialects of javascript.

Install

This package depends on the babel-core module.

yarn add babel-core babel-preset-es2015 babel-plugin-transform-react-jsx --dev
npm install babel-core babel-preset-es2015 babel-plugin-transform-react-jsx --save-dev
Parameters
Name Type Description ?Default
config Object when using other fuse-box only properties, babel config is passed in as .config
limit2project boolean to use this plugin across an entire project (including other modules like npm) true
extensions Array<string> file extensions to allow with fuse-box [".jsx"]
test Regex files to match <code>/\.(j|t)s(x)?$/</code>

Examples

JSX

const {BabelPlugin} = require("fuse-box");

plugins: [
    BabelPlugin({
      config: {
        sourceMaps: true,
        presets: ["es2015"],
        plugins: [
            ["transform-react-jsx"],
        ],
      },
    })
]

Shorthand

when only passing in a babel config, there is no need for .config

plugins: [
  BabelPlugin({
    presets: ["es2015"]
  })
]

Note

The BabelPlugin will merge options from your .babelrc file and any options passed into the plugin directly. If an option exists in both, then the options object passed into the plugin will take priority.