babel-preset-mobx
raw JSON → 2.0.0 verified Sat Apr 25 auth: no javascript deprecated
Babel preset for ES features commonly used with MobX. Current stable version 2.0.0, last updated 2017, no recent releases. Includes transform-decorators-legacy, transform-class-properties, transform-es2015-classes, transform-regenerator. Requires babel-polyfill or regenerator-runtime for async/generators. Outdated and unmaintained; users should migrate to modern Babel (v7+) with individual @babel/plugin proposals or a custom preset. Does not support current MobX 6+ decorator syntax.
Common errors
error Error: Plugin/Preset files are not allowed to export objects, only functions. ↓
cause Using this preset with Babel 7+ which expects functions, not legacy plugin objects.
fix
Upgrade to a Babel 7 compatible preset or use @babel/preset-env with manual plugins.
error ReferenceError: regeneratorRuntime is not defined ↓
cause Missing regenerator-runtime runtime dependency for async functions.
fix
Install regenerator-runtime and import it at the entry point.
error Support for the experimental syntax 'decorators-legacy' isn't currently enabled ↓
cause Babel 7 requires explicit plugin for decorators.
fix
Add @babel/plugin-proposal-decorators with legacy: true to Babel config.
Warnings
deprecated babel-preset-mobx is outdated and unmaintained; not compatible with Babel 7+. ↓
fix Use @babel/preset-env and add required plugins manually for Babel 7+.
gotcha babel-polyfill or regenerator-runtime must be installed separately for async/generators. ↓
fix Install babel-polyfill or regenerator-runtime as a runtime dependency.
gotcha Included plugins (transform-decorators-legacy) are deprecated in Babel 7+. ↓
fix Use @babel/plugin-proposal-decorators and @babel/plugin-proposal-class-properties.
Install
npm install babel-preset-mobx yarn add babel-preset-mobx pnpm add babel-preset-mobx Imports
- preset wrong
import 'babel-preset-mobx' // not meant for direct importcorrect// .babelrc: { "presets": ["mobx"] } - decorator support wrong
import { transformDecoratorsLegacy } from 'babel-preset-mobx'correct// Use babel-preset-mobx in .babelrc - regenerator wrong
// assumed included in preset, but it's notcorrect// need to add regenerator-runtime as dependency
Quickstart
npm install --save-dev babel-preset-mobx
# Add to .babelrc:
{
"presets": ["mobx"]
}