babel-plugin-transform-throw-expressions
This plugin transforms Throw Expressions into an IIFE.
Example
function test(param = throw new Error('required!')) {
const test = param === true || throw new Error('Falsey!');
}
Installation
npm install --save-dev babel-plugin-transform-throw-expressions
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["transform-throw-expressions"]
}
Via CLI
babel --plugins transform-throw-expressions script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["transform-throw-expressions"]
});
References