babel-preset-cosmo
Babel preset for Cosmo CLI
If you have bootstrapped your project with cosmo
, you are already using this preset. If you would like to configure it, Add .babelrc
to your project root. Cosmo
will use that as babel config instead of default preset.
To use it in a non-cosmo project, Follow the steps bellow:
Install
$ npm install @babel/core @babel/cli babel-preset-cosmo
$ npm install @babel/runtime --save
Or using yarn
:
$ yarn add --dev @babel/core @babel/cli babel-preset-cosmo
$ yarn add @babel/runtime
Usage
In your .babelrc
:
{
"presets": ["cosmo"]
}
ESNext supported features:
const add = (x: number, y: number): number => x + y;
class Dog {
bark = () => console.log("Wooof!");
}
const sleep = ms => new Promise(res => setTimeout(res, ms));
const logAfterTenMs = async () => {
await sleep(10);
console.log("This will log after 10ms");
};
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
console.log(x);
console.log(y);
console.log(z);
let n = { x, y, ...z };
console.log(n);
License
MIT © Sid Doshi