$ npm install babel-plugin-transform-throw-expressions
This plugin transforms Throw Expressions into an IIFE.
function test(param = throw new Error('required!')) {
const test = param === true || throw new Error('Falsey!');
}
npm install --save-dev babel-plugin-transform-throw-expressions
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-throw-expressions"]
}
babel --plugins transform-throw-expressions script.js
require("babel-core").transform("code", {
plugins: ["transform-throw-expressions"]
});
© 2010 - cnpmjs.org x YWFE | Home | YWFE