
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
babel-plugin-trycatch-inject-loader
Advanced tools
This loader using babel to transform a file and wrap all function(include class method and arrow function) with try catch clause, it collect specific information: filename,function name, line number, using AST(Abstract Syntax Tree) and Source Map. This loader base on the ouput of babel-loader, include it's generated source and source map.
rethrow: true | false; // rethrow catched error
verbose: true | false; //show verbose log
reporter: String; //report function name, which should be globally accessed. default name is reportError
tmpdir: String; //a temp directory relate to project root dirctory, to write transformed file, for debug purpose only
use loader query string
{
test: /\.jsx$/,
loader: 'babel-try-catch-loader?rethrow=true&verbose=true&reporter=reportError&tempdir=.tryCatchLoader!babel-loader',
exclude: /node_modules/
}
or use default options:
{
test: /\.jsx$/,
loader: 'babel-try-catch-loader!babel-loader',
exclude: /node_modules/
}
since this loader is based on babel-loader and it's source map, so you have to enable webpack's source-map config.
devtool: 'source-map'
before:
export default class testReact extends React.Component {
static defaultProps = {
data: {}
}
componentDidMount() {
console.log('mount....');
}
render() {
return (<p>test</p>);
}
}
after:
...
_createClass(testReact, [{
key: 'componentDidMount',
value: function componentDidMount() {
try {
console.log('mount....');
} catch (_e) {
reportError(_e, "testReact.jsx", "componentDidMount", 7);
throw _e;
}
}
}, {
key: 'render',
value: function render() {
try {
return _react2.default.createElement('p', null, 'test');
} catch (_e2) {
reportError(_e2, "testReact.jsx", "render", 11);
throw _e2;
}
}
}]);
...
FAQs
babel try catch loader for new webpack
We found that babel-plugin-trycatch-inject-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.