Babel Preset React Native Stage-0
raw JSON → 1.0.1 verified Sat Apr 25 auth: no javascript maintenance
A Babel preset that enables stage-0 (latest experimental) JavaScript features in React Native projects. Version 1.0.1 is the latest stable release; the project is in maintenance mode. It wraps babel-preset-react-native with stage-0 transformations, including optional legacy decorator support via a sub-preset. Unlike combining babel-preset-react-native and babel-preset-stage-0 separately, this preset ensures compatibility and avoids common conflicts and errors in the RN bundler. No updates expected; users should consider newer alternatives like babel-preset-react-native with explicit plugin selection.
Common errors
error Error: Cannot find module 'babel-preset-react-native-stage-0' from '/path/to/project' ↓
cause Preset not installed or .babelrc uses the full npm name instead of the short name.
fix
Run 'npm install babel-preset-react-native-stage-0 --save' and use '"react-native-stage-0"' in presets.
error ReferenceError: regeneratorRuntime is not defined ↓
cause Stage-0 features like async/await require regenerator runtime, which may not be bundled.
fix
Add 'transform-regenerator' plugin or use babel-polyfill.
error SyntaxError: Unexpected token (1:14) - ... while parsing file: /path/to/file.js ↓
cause Incorrect usage of stage-0 syntax that is not transformed due to cache or missing plugin.
fix
Clear packager cache: 'watchman watch-del-all' then 'react-native start --reset-cache'.
error error: bundling failed: Error: Couldn't find preset "react-native-stage-0/decorator-support" relative to directory ↓
cause Using the decorator-support sub-preset path incorrectly in non-Babel config files.
fix
Ensure the preset is referenced only in .babelrc or babel config, not in other tools.
Warnings
deprecated Package has not been updated since 2018; consider migrating to modern alternatives. ↓
fix Use '@babel/preset-env' and '@babel/preset-react' with individual stage-0 plugins, or babel-preset-react-native with explicit plugin lists.
breaking Combining this preset with the standalone 'babel-preset-stage-0' causes Babel errors and broken builds. ↓
fix Remove 'babel-preset-stage-0' from presets; this preset already includes stage-0 features.
gotcha Including the full preset name 'babel-preset-react-native-stage-0' in the presets array will not be resolved; Babel requires the short name. ↓
fix Use 'react-native-stage-0' in the presets array.
gotcha After adding this preset, you must clear the React Native packager cache to avoid strange Babel errors. ↓
fix Run 'watchman watch-del-all' and then start packager with '--reset-cache'.
deprecated Legacy decorator support (decorator-support sub-preset) may not work with newer Babel versions. ↓
fix Use '@babel/plugin-proposal-decorators' with the appropriate version.
Install
npm install babel-preset-react-native-stage-0 yarn add babel-preset-react-native-stage-0 pnpm add babel-preset-react-native-stage-0 Imports
- default preset wrong
"presets": ["babel-preset-react-native-stage-0"]correct"presets": ["react-native-stage-0"] - decorator-support preset wrong
"presets": [["react-native-stage-0", { "decorators": true }]]correct"presets": ["react-native-stage-0/decorator-support"] - require() usage wrong
const presets = require('babel-preset-react-native-stage-0/decorator-support')correctconst presets = require('babel-preset-react-native-stage-0');
Quickstart
// Create .babelrc in project root
{
"presets": ["react-native-stage-0"]
}
// Install
npm install babel-preset-react-native-stage-0 --save
// After adding preset, clear cache and restart packager
watchman watch-del-all
react-native start --reset-cache
// Example usage in App.js using stage-0 features like exponentiation operator
const square = (x) => x ** 2;
console.log(square(5)); // 25