babel-preset-mandacarutech
v0.1.1
Published
A Babel preset for transpiling JavaScript following our code conventions
Downloads
3
Readme
babel-preset-mandacarutech
A babel preset for transforming your JavaScript for Mandacaru Tech.
Currently contains transforms for all stage 4 (ES2018) and stage 3 syntax. Additionally, stage 4 syntax that is excluded is as follows:
- generators:
regenerator-runtime
is too heavyweight for our use. async/await
:regenerator-runtime
is too heavyweight for our use, and async-to-promises is not yet complete enough to be safely used.- async iterators: depends on both generators and
async function
s - lifted template literal restrictions: we do not use tagged template literals, nor implement custom DSLs, otherwise we would enable this.
Install
$ npm install --save-dev babel-preset-mandacarutech
Usage
Via .babelrc
(Recommended)
.babelrc
{
"presets": ["mandacarutech"]
}
Via CLI
$ babel script.js --presets mandacarutech
Via Node API
require('@babel/core').transform('code', {
presets: ['mandacarutech']
});
Targeting Environments
This module uses @babel/preset-env to target specific environments.
Please refer to @babel/preset-env#targets for a list of available options.
For a list of browsers please see browserlist.
You may override our default list of targets by providing your own targets
key.
{
"presets": [["mandacarutech", {
"targets": {
"chrome": 50,
"ie": 11,
"firefox": 45
}
}]]
}
The following transpiles only for Node v6.
{
"presets": [["mandacarutech", {
"targets": {
"node": 6
}
}]]
}
If you wish, you can also inherit our default list of browsers and extend them using additionalTargets
.
{
"presets": [["mandacarutech", {
"additionalTargets": {
"chrome": 42,
"ie": 8
}
}]]
}
You may override our default debug option by providing your own debug
key.
{
"presets": [["mandacarutech", {
"debug": true
}]]
}
React Development Mode
When process.env.NODE_ENV
is 'development'
, the development
mode will be set for @babel/preset-react
.
You may override our default development option by providing your own boolean development
key.
{
"presets": [["mandacarutech", {
"development": false
}]]
}
React PropTypes removal
This preset can be configured to remove propTypes using babel-plugin-transform-react-remove-prop-types with the following default options:
To enable this transformation with the default options, set the removePropTypes
option to true
:
{
"presets": [["mandacarutech", {
"removePropTypes": true
}]]
}
The default options that will be used are:
{
mode: 'wrap',
additionalLibraries: ['airbnb-prop-types'],
ignoreFilenames: ['node_modules'],
}
Default options can be overridden using the removePropTypes
option. These options will be shallow-merged with the defaults:
{
"presets": [["mandacarutech", {
"removePropTypes": {
"mode": "remove"
}
}]]
}
For example, if you are using this plugin in a deployable app, you might want to use the remove mode for your production build (and disable this transform entirely in development for optimal build speeds).
Classes loose mode
By default, this preset will compile classes in normal mode. This is safer, but comes with a bundle size and runtime overhead. To compile classes in loose mode, set the looseClasses
option to true
:
{
"presets": [["mandacarutech", {
"looseClasses": true,
}]]
}
The risks of enabling loose classes are outlined in the Babel docs.