@wdcthemes/babel-preset-default

6.5.0 • Public • Published

WDC babel preset

Babel preset for transforming JavaScript.

Instalation

npm install --save-dev @wdcthemes/babel-preset-default

Usage

Simply add @wdcthemes/babel-preset-default to your .babelrc file

// .babelrc
{
    "presets": [ "@wdcthemes/babel-preset-default"]
}

Options

This babel preset exposes a few options. The default options are listed below.

// .babelrc
{
    "presets": [
        ["@wdcthemes/babel-preset-default", {
            "modules": "auto",
            // defaults to true if modules is false and false otherwise.
            "runtimeESModules": false,
            "wordpress": false,
            "debug": false,
            "removePropTypes": {},
            "targets": [
                "> 1%",
                "ie >= 11",
                "last 2 versions",
                "Firefox ESR"
            ]
        }]
    ]
}

options.modules

It's the @babel/preset-env modules setting. Default's to auto which will detect whether the "caller" (e.g webpack) has ES6 modules support and if so, will disable module transpilation (this is the desired behavior for tree-shaking for example);

options.wordpress

When enabled will load @wordpress/babel-preset-default. Required when building WordPress Gutenberg blocks.

options.debug

Enables debug messages. Usefull to review which presets and plugins babel is using.

options.removePropTypes

By default this babel preset will remove any prop-types declarations when building for production.

You rarelly will need to change this setting, but in case you do, this option let's you specify any of the babel-plugin-transform-react-remove-prop-types options.

options.targets

Let's you specify which browser's are support. Set this option to {} if you want to leverage browserlist config sources (.browserslistrc). By default, the following browsers will be supported.

[
    "> 1%",
    "ie >= 11",
    "last 2 versions",
    "Firefox ESR"
]

The appropriate core-js polyfills will be added automatically for those browsers.

options.development

You can set this flag to enable or disable development mode, however, this preset will automatically detect that based on how it was loaded by the caller (e.g webpack).

Readme

Keywords

Package Sidebar

Install

npm i @wdcthemes/babel-preset-default

Weekly Downloads

1

Version

6.5.0

License

none

Unpacked Size

19.4 kB

Total Files

10

Last publish

Collaborators

  • stefanue