rax-babel-config

raw JSON →
2.0.4 verified Sat Apr 25 auth: no javascript

Base Babel configuration for the Rax framework (cross-platform React-like UI). Version 2.0.4 is the latest stable release. This package provides a factory function that returns a Babel config object, with options to enable JSX stylesheet transforms, JSX+ plugins, JSX-to-HTML transforms, Node target preset-env, and Regenerator runtime control. It is part of the rax-scripts monorepo. Key differentiator: designed specifically for Rax projects, encapsulating the needed presets and plugins for optimal Rax development.

error Cannot find module 'rax-babel-config'
cause Package not installed or not in node_modules.
fix
Run 'npm install rax-babel-config --save-dev'.
error require() of ES Module not supported
cause Trying to require a package that is defined as type: module in package.json.
fix
Use dynamic import() or convert to CommonJS. Note: rax-babel-config itself is CJS, but if your project is ESM, use createRequire.
error getBabelConfig is not a function
cause Incorrect import style; package exports a function directly, not a named export.
fix
Use 'const getBabelConfig = require('rax-babel-config');' as default import.
error TypeError: Cannot read property 'presets' of undefined
cause Babel config merging issue; getBabelConfig returns an object, but it may need to be spread into a full babel config.
fix
Properly merge the returned config object with your base Babel configuration.
breaking Version 3.x of rax-scripts introduced breaking changes for postcss-loader options in rax-webpack-config and @builder/rax-pack.
fix Update your postcss-loader configuration to match new options format; refer to changelog.
deprecated rax-babel-config is a legacy package; consider migrating to the newer @builder/rax-babel-config.
fix Replace rax-babel-config with @builder/rax-babel-config in package.json and update imports.
gotcha Package does not export as ES module; must use require() in Node.js CommonJS. Using import may fail depending on bundler/Node version.
fix Use require() or set up CJS interop.
gotcha The 'styleSheet' option enables a plugin that transforms JSX style objects; if not needed, disable to avoid unnecessary transforms.
fix Set styleSheet: false in options if not using inline styles.
gotcha The 'jsxPlus' option enables JSX+ syntax (e.g., loops, conditionals). Ensure your Babel runtime supports these extensions.
fix Install @babel/plugin-transform-react-jsx if jsxPlus is used incorrectly.
npm install rax-babel-config
yarn add rax-babel-config
pnpm add rax-babel-config

Shows how to install and use rax-babel-config to generate a Babel config for a Rax project.

const getBabelConfig = require('rax-babel-config');

const babelConfig = getBabelConfig({
  styleSheet: true,
  jsxPlus: false,
  jsxToHtml: false,
  isNode: false,
  disableRegenerator: false
});

console.log(JSON.stringify(babelConfig, null, 2));