babel-preset-rax

1.0.0-beta.0 • Public • Published

babel-preset-rax npm Dependency Status Known Vulnerabilities

Babel preset for all Rax plugins.

This preset always includes the following plugins:

And with the development option:

Installation

Using npm:

npm install --save-dev babel-preset-rax

or using yarn:

yarn add babel-preset-rax --dev

Usage

Via .babelrc (Recommended)

.babelrc

Without options:

{
  "presets": ["babel-preset-rax"]
}

With options:

{
  "presets": [
    [
      "babel-preset-rax",
      {
        "pragma": "dom", // default pragma is createElement
        "pragmaFrag": "DomFrag", // default is Fragment
        "throwIfNamespace": false // defaults to true
      }
    ]
  ]
}

Via CLI

babel --presets babel-preset-rax script.js

Via Node API

require("@babel/core").transform("code", {
  presets: ["babel-preset-rax"],
});

Options

pragma

string, defaults to createElement.

Replace the function used when compiling JSX expressions.

pragmaFrag

string, defaults to Fragment.

Replace the component used when compiling JSX fragments.

useBuiltIns

boolean, defaults to false.

Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.

development

boolean, defaults to false.

Toggles plugins that aid in development, such as @babel/plugin-transform-react-jsx-self and @babel/plugin-transform-react-jsx-source.

This is useful when combined with the env option configuration or js config files.

throwIfNamespace

boolean, defaults to true.

Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:

<f:image />

Though the JSX spec allows this, it is disabled by default since React's JSX does not currently have support for it.

.babelrc.js

module.exports = {
  presets: [
    [
      "babel-preset-rax",
      {
        development: process.env.BABEL_ENV === "development",
      },
    ],
  ],
};

.babelrc

Note: the env option will likely get deprecated soon

{
  "presets": ["babel-preset-rax"],
  "env": {
    "development": {
      "presets": [["babel-preset-rax", { "development": true }]]
    }
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i babel-preset-rax

Weekly Downloads

45

Version

1.0.0-beta.0

License

BSD-3-Clause

Unpacked Size

5.5 kB

Total Files

3

Last publish

Collaborators

  • wintercn
  • yacheng
  • yuanyan
  • zeroling