
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
babel-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
The npm package babel-trycatch-inject-loader receives a total of 0 weekly downloads. As such, babel-trycatch-inject-loader popularity was classified as not popular.
We found that babel-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.
Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.