Babel preset for compiling JSX in Rax applications, a React-like framework for cross-platform development (web, mini-programs, etc.). Current stable version is 1.0.0-beta.0, though later beta releases exist (e.g., 1.2.2). It includes plugins for JSX syntax, transformation, and display name, with optional development plugins for JSX self/source. Rax is maintained by Alibaba and focuses on performance and universal rendering. Key differentiator: tailored for Rax's custom JSX pragma (e.g., 'createElement' or 'dom') and fragment handling, with throwIfNamespace control.
npm install babel-preset-raxVerified import paths — ran on the pinned version, not inferred.
Setup Babel with babel-preset-rax to transpile JSX in a Rax project, showing configuration and CLI usage.
Use latest version (npm install babel-preset-rax@latest) and check changelog for breaking changes.
Set development flag via JS config: { presets: [['babel-preset-rax', { development: process.env.NODE_ENV === 'development' }]] }Set pragma to 'createElement' (or 'dom' for Rax DOM) in preset options.
Set throwIfNamespace to false in options if XML namespaced tags are needed.
Evaluate if babel-preset-rax is still necessary; consider using @babel/preset-react with custom pragma.
Upgrade to Babel 7: npm install @babel/core @babel/cli --save-dev
Ensure .babelrc or babel.config.js includes 'babel-preset-rax' in presets and that Babel is run on the file.
Add import { createElement } from 'rax'; at the top of your file, or change pragma to 'rax.createElement'.