babel-preset-rax
Babel preset for all Rax plugins.
This preset always includes the following plugins:
- @babel/plugin-syntax-jsx
- @babel/plugin-transform-react-jsx
- @babel/plugin-transform-react-display-name
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
.babelrc
(Recommended)
Via .babelrc
Without options:
With options:
Via CLI
babel --presets babel-preset-rax script.js
Via Node API
;
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
moduleexports = presets: "babel-preset-rax" development: processenvBABEL_ENV === "development" ;
.babelrc
Note: the
env
option will likely get deprecated soon