babel-preset-cozy-app

raw JSON →
2.8.4 verified Sat Apr 25 auth: no javascript maintenance

Babel preset for Cozy Cloud applications. Version 2.8.4 is the current stable release (last updated 2021, now in maintenance mode). It configures Babel with plugins and presets needed for Cozy apps, including environment-based presets (react, node) and specific plugins for Cozy's flags system and inline style imports. Differentiator: purpose-built for Cozy platform, with automatic configuration for their specific stack (e.g., cozy-flags, cozy-ui).

error Error: Cannot find module 'babel-preset-cozy-app'
cause Package not installed or not in node_modules.
fix
npm install babel-preset-cozy-app --save-dev
error Error: Plugin/Preset files are not allowed to export objects, only functions.
cause Using default import (ESM) instead of require().
fix
Use require() in babel.config.js, not import.
error ReferenceError: regeneratorRuntime is not defined
cause Missing async/transform-runtime configuration.
fix
Add useBuiltIns: 'usage' and corejs:3 options, or add @babel/polyfill (deprecated).
breaking v2 dropped support for Node < 10 and Babel 6. Use Babel 7+.
fix Upgrade to Babel 7 and Node >=10.
deprecated The package is in maintenance mode; no new features. Consider migrating to @cozy/babel-preset-cozy-app if available.
fix Check for replacement in cozy-libs monorepo.
gotcha Do not use preset path 'cozy-app/react' - it will fail. Sub-presets must be configured via options.
fix Use { presets: [['cozy-app', { preset: 'react' }]] }
gotcha The preset automatically includes @babel/plugin-transform-runtime. Ensure @babel/runtime is in dependencies.
fix Add @babel/runtime to dependencies (not devDependencies).
npm install babel-preset-cozy-app
yarn add babel-preset-cozy-app
pnpm add babel-preset-cozy-app

Shows typical usage in babel.config.js with React preset and polyfill options.

// babel.config.js
module.exports = {
  presets: [
    ['cozy-app', {
      preset: 'react',  // options: 'react', 'node', 'react-native'
      targets: { browser: 'last 2 versions' },
      useBuiltIns: 'usage',
      corejs: 3
    }]
  ]
};