{"id":19254,"library":"babel-preset-amex","title":"Babel Preset Amex","description":"Standard Babel preset for American Express, currently at v4.0.3. Maintained by One Amex, it provides a curated set of Babel presets and plugins for transpiling JavaScript and React applications. Includes @babel/preset-env, @babel/preset-react, and plugins for dynamic imports, class properties, export default from, optional chaining, and react-remove-prop-types (production only). Supports configuration for server-only (Node), modern browsers (n-1), and module format (ESM or CommonJS). Differentiated by its opinionated defaults tailored for American Express projects, with a focus on stability and compliance. Release cadence is irregular, with minor updates and patches as needed.","status":"active","version":"4.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/americanexpress/babel-preset-amex","tags":["javascript","babel","preset","build","babel-preset","transpile","one-app"],"install":[{"cmd":"npm install babel-preset-amex","lang":"bash","label":"npm"},{"cmd":"yarn add babel-preset-amex","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-preset-amex","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to run any Babel preset","package":"@babel/core","optional":false}],"imports":[{"note":"Used in .babelrc or babel.config.js as a preset string, not imported directly. If using babel.config.js with module.exports, string 'amex' is correct.","wrong":"import babelPresetAmex from 'babel-preset-amex'","symbol":"default","correct":"module.exports = { presets: ['amex'] }"},{"note":"Options must be passed as an array pair, not as separate arguments.","wrong":"module.exports = { presets: ['amex', { serverOnly: true }] }","symbol":"Use as preset with options","correct":"module.exports = { presets: [['amex', { serverOnly: true }]] }"},{"note":"The preset is CommonJS; ESM import may cause issues if used in ESM context without proper handling.","wrong":"import preset from 'babel-preset-amex';","symbol":"CommonJS require","correct":"const preset = require('babel-preset-amex');"}],"quickstart":{"code":"// .babelrc\n{\n  \"presets\": [\n    [\n      \"amex\",\n      {\n        \"serverOnly\": false,\n        \"modern\": true,\n        \"moduleFormat\": \"esm\"\n      }\n    ]\n  ]\n}\n\n// Or babel.config.js\nmodule.exports = {\n  presets: [\n    ['amex', {\n      serverOnly: false,\n      modern: true,\n      moduleFormat: 'esm'\n    }]\n  ]\n};\n\n// Install\nnpm install --save-dev babel-preset-amex @babel/core\n","lang":"javascript","description":"Shows how to configure babel-preset-amex in .babelrc or babel.config.js with options for serverOnly, modern, and moduleFormat."},"warnings":[{"fix":"Update to v4.0.3 or later to use the standardized transform.","message":"v4.0.3 replaced @babel/plugin-proposal-optional-chaining with the standardized plugin @babel/plugin-transform-optional-chaining. Older versions used the proposal plugin.","severity":"deprecated","affected_versions":"<4.0.3"},{"fix":"Upgrade Node to version 16 or later.","message":"v4.0.0 dropped support for Node 10, 12, and 14. These Node versions are no longer supported by the preset.","severity":"breaking","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Use 'moduleFormat': 'esm' for ESM; omit or use any other string for CommonJS.","message":"The option 'moduleFormat' only supports 'esm' for ESM output; any other string (including 'cjs') defaults to CommonJS. There is no explicit 'cjs' option.","severity":"gotcha","affected_versions":">=3.6.0"},{"fix":"Ensure NODE_ENV is set correctly to benefit from dead code elimination.","message":"The preset auto-removes prop-types / dead code only in production mode (NODE_ENV=production). In development, those transforms are skipped.","severity":"gotcha","affected_versions":"*"},{"fix":"Use 'modern': true to exclude IE 11 and other legacy browsers.","message":"The legacy browserlist target includes IE 11 (since v4.0.2). Ensure your app does not need to support IE 11 if you set 'modern' to true.","severity":"deprecated","affected_versions":">=4.0.2"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev babel-preset-amex","cause":"Package not installed or listed as devDependency.","error":"Module not found: Can't resolve 'babel-preset-amex'"},{"fix":"npm install --save-dev @babel/core","cause":"@babel/core is a required peer dependency not installed.","error":"Error: Cannot find module '@babel/core'"},{"fix":"Use: presets: [['amex', { ... }]] instead of presets: ['amex', { ... }]","cause":"In babel.config.js, the preset is not wrapped in an array when passing options.","error":"Preset options must be an array, received object"},{"fix":"Set 'moduleFormat': 'esm' or omit/use falsy value for CommonJS.","cause":"The option 'moduleFormat' expects a string value, but got another type.","error":"Invalid config: 'moduleFormat' must be a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}