@gaincompliance/babel-preset
v4.1.40
Published
babel preset for our projects
Downloads
551
Readme
babel-preset-gain
babel preset for our projects
Usage
Installation
$ npm install @gaincompliance/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": ["@gaincompliance"]
}
In React projects
This will target the current node version, but will also transpile React features
{
"presets": [["@gaincompliance", {"react": true}]]
}
Optionally, also transpile immutable.js functionality
{
"presets": [["@gaincompliance", {"react": true, "immutable": 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: [['@gaincompliance', {targets: {node: 8}, modules: false}]],
}),
...
],
...
};
In projects that target both node and browsers
export default {
...
plugins: [
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: [['@gaincompliance', {targets: {node: 8, browser: true}, modules: false}]],
}),
...
],
...
};
In React projects
export default {
...
plugins: [
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: [['@gaincompliance', {
targets: {node: 8, browser: true},
react: true,
modules: false
}]],
}),
...
],
...
};
Optionally, also transform immutable.js functionality
export default {
...
plugins: [
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: [['@gaincompliance', {
targets: {node: 8, browser: true},
react: true,
immutable: true,
modules: false
}]],
}),
...
],
...
};
Optionally, disable transpilation of emotion
(for unit testing, for example)
export default {
...
plugins: [
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: [['@gaincompliance', {
targets: {node: 8, browser: true},
react: true,
emotion: false,
modules: false
}]],
}),
...
],
...
};
Dependencies
$ nvm install
$ npm install
Verification
$ npm test