@babel/plugin-proposal-throw-expressions
Version:
Wraps Throw Expressions in an IIFE
25 lines (22 loc) • 763 B
JavaScript
import { declare } from '@babel/helper-plugin-utils';
import { types } from '@babel/core';
const index = declare(api => {
api.assertVersion("^7.0.0-0 || ^8.0.0");
return {
name: "proposal-throw-expressions",
manipulateOptions: (_, parser) => parser.plugins.push("throwExpressions"),
visitor: {
UnaryExpression(path) {
const {
operator,
argument
} = path.node;
if (operator !== "throw") return;
const arrow = types.functionExpression(null, [types.identifier("e")], types.blockStatement([types.throwStatement(types.identifier("e"))]));
path.replaceWith(types.callExpression(arrow, [argument]));
}
}
};
});
export { index as default };
//# sourceMappingURL=index.js.map