babel-preset-moon

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

A modern Babel preset for tooling development from the moonrepo ecosystem. Current stable version is 3.1.4, updated regularly with Babel releases. It configures the env preset for the current Node.js version, enables TypeScript, native async/await, and supports React, Solid, and JSX runtimes. Converts __DEV__/__PROD__/__TEST__ to process.env checks and wraps invariant() in conditionals. Not intended for web apps or package building — use Packemon instead. Ships TypeScript types, requires Node >=18.12.0 and @babel/core >=7.0.0.

error Error: Cannot find module '@babel/core'
cause @babel/core is a peer dependency not installed.
fix
yarn add --dev @babel/core
error Error: [BABEL] unknown preset "moon"
cause babel-preset-moon is not installed or not in node_modules.
fix
yarn add --dev babel-preset-moon
error Support for the experimental syntax 'decorators' isn't currently enabled
cause Decorators option not set but decorators used in code.
fix
Add { decorators: true } to preset options.
gotcha babel-preset-moon is intended for tooling development only, not for web apps or package building.
fix Use Packemon (https://packemon.dev) for building packages or web applications.
deprecated The 'modules' option defaults to false (auto), but setting it to true may break ESM output.
fix Leave modules as false for ESM-friendly output; set to 'commonjs' if CJS required.
gotcha Enabling decorators (decorators: true) forces Babel into loose mode, which may affect output compatibility.
fix Be aware that loose mode changes semantics; test your code thoroughly.
breaking Requires Node >=18.12.0; older Node versions will cause errors.
fix Upgrade Node to >=18.12.0.
npm install babel-preset-moon
yarn add babel-preset-moon
pnpm add babel-preset-moon

Shows how to install, configure babel-preset-moon with React automatic runtime, and an example usage comment.

// Install: yarn add --dev babel-preset-moon @babel/core
// babel.config.js
module.exports = {
  presets: [['moon', { react: 'automatic', decorators: false }]],
};

// Example usage with Node.js ESM:
// Run: node --experimental-vm-modules -e "import('./src/index.js')"