babel-preset-wtw-im
raw JSON → 2.5.0 verified Sat Apr 25 auth: no javascript
Babel preset for Willis Towers Watson Individual Marketplace, version 2.5.0. It bundles babel-preset-react, babel-preset-env, and plugins for lodash, format-message (extract and transform), and styled-components. Release cadence is low, appears to be internal use. Differentiator: opinionated preset tailored for WTW's React + i18n stack with format-message integration.
Common errors
error ReferenceError: [BABEL] unknown: Preset wtw-im is not a function ↓
cause Preset options format wrong - options passed as separate argument instead of nested array
fix
Change .babelrc to "presets": [["wtw-im", {}]]
error Module not found: Can't resolve 'babel-preset-wtw-im' ↓
cause Preset not installed or wrong name used
fix
Run: npm install --save-dev babel-preset-wtw-im, then use 'wtw-im' in presets array
error SyntaxError: Unexpected token import ↓
cause Using ES import syntax with CommonJS preset
fix
Use require() or CommonJS syntax: const preset = require('babel-preset-wtw-im')
Warnings
gotcha Options must be nested in array: [[preset, options]] not [preset, options] ↓
fix Use correct Babel preset options format: "presets": [["wtw-im", {...}]]
gotcha Preset name 'wtw-im' (short form) is required, full 'babel-preset-wtw-im' may not work if Babel cannot resolve ↓
fix Use 'wtw-im' in presets array: "presets": ["wtw-im"]
deprecated babel-preset-env is deprecated in favor of @babel/preset-env for Babel 7 ↓
fix Upgrade to Babel 7 and use @babel/preset-env; this preset is for Babel 6
gotcha If using Node API, require the preset: require('babel-preset-wtw-im') and use in presets array ↓
fix Preset is CommonJS, use require() not import
deprecated babel-core is version 6.x, not compatible with Babel 7 ↓
fix For Babel 7, use @babel/core and @babel/preset-env etc.; this preset is for Babel 6 ecosystem
Install
npm install babel-preset-wtw-im yarn add babel-preset-wtw-im pnpm add babel-preset-wtw-im Imports
- default wrong
import preset from 'babel-preset-wtw-im'correctmodule.exports = require('babel-preset-wtw-im') - babel-preset-wtw-im wrong
{"presets": ["babel-preset-wtw-im"]}correctIn .babelrc: {"presets": ["wtw-im"]} - options wrong
{"presets": ["wtw-im", { "react": false }]}correct{"presets": [["wtw-im", { "react": false }]]}
Quickstart
// .babelrc
{
"presets": [
["wtw-im", {
"env": {
"targets": { "browsers": "> 1%" }
},
"react": true,
"styledComponents": { "ssr": false, "displayName": false },
"extractFormatMessage": false,
"transformFormatMessage": { "inline": false }
}]
]
}
// Then run: npx babel src --out-dir lib