My shareable babel preset
$ npm install @travi/babel-preset --save-dev
Via .babelrc
for internal development purposes
This will target the current version of node and transpile my preferred upcoming features.
{
"presets": ["@travi"]
}
This will target the current node version, but will also transpile React features
{
"presets": [["@travi", {"react": true}]]
}
Via Rollup
- Prevent transpilation of module imports/exports so
Rollup
can optimize properly - Transpile to the lowest common denominator of your expected consumers' execution environments
In the rollup.config.js
:
export default {
...
plugins: [
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: [['@travi', {targets: {node: 8}, modules: false}]],
}),
...
],
...
};
export default {
...
plugins: [
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: [['@travi', {targets: {node: 8, browser: true}, modules: false}]],
}),
...
],
...
};
export default {
...
plugins: [
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: [['@travi', {
targets: {node: 8, browser: true},
react: true,
modules: false
}]],
}),
...
],
...
};
$ nvm install
$ npm install
$ npm test