@greenwood/plugin-babel

0.29.2 • Public • Published

@greenwood/plugin-babel

Overview

A Greenwood plugin for using Babel and applying it to your JavaScript.

This package assumes you already have @greenwood/cli installed.

Installation

You can use your favorite JavaScript package manager to install this package.

examples:

# npm
npm install @greenwood/plugin-babel --save-dev

# yarn
yarn add @greenwood/plugin-babel --dev

Usage

Add this plugin to your greenwood.config.js.

import { greenwoodPluginBabel } from '@greenwood/plugin-babel';

export default {
  ...

  plugins: [
    greenwoodPluginBabel()
  ]
}

Create a babel.config.cjs in the root of your project with your own custom plugins / settings that you've installed and want to use.

module.exports = {
  plugins: [
    '@babel/plugin-proposal-class-properties',
    '@babel/plugin-proposal-private-methods'
  ]
};

This will then process your JavaScript with Babel using the configured plugins and settings you provide.

For now Babel configuration needs to be in CJS. Will we be adding ESM support soon!

Options

This plugin provides a default babel.config.js that includes support for @babel/preset-env using browserslist with reasonable default configs for each.

If you would like to use it, either standalone or with your own custom babel.config.js, you will need to take the following extra steps:

  1. Install @babel/runtime and regenerator-runtime as direct dependencies of your project
    # npm
    npm install @babel/runtime regenerator-runtime
    
    # yarn
    yarn add @babel/runtime regenerator-runtime
  2. When adding greenwoodPluginBabel to your greenwood.config.js, enable the extendConfig option
    import { greenwoodPluginBabel } from '@greenwood/plugin-babel';
    
    export default {
      // ...
    
      plugins: [
        greenwoodPluginBabel({
          extendConfig: true
        })
      ]
    };

If you have a custom babel.config.js, this option will merge its own presets and plugins in the array ahead of your own (if you have them).

Package Sidebar

Install

npm i @greenwood/plugin-babel

Weekly Downloads

1

Version

0.29.2

License

MIT

Unpacked Size

7.95 kB

Total Files

6

Last publish

Collaborators

  • thescientist13