Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (source, inputMap) {
var webpackRemainingChain = loaderUtils.getRemainingRequest(this).split("!");
var absoulteFilename = webpackRemainingChain[webpackRemainingChain.length - 1];
var loaderOptions = loaderUtils.parseQuery(this.query);
var globalOptions = this.options.babelTryCatchLoader || {};
var globalOptions = this.options ? (this.options.babelTryCatchLoader || {}) : {};//The options property has been deprecated in webpack 3 and removed in webpack 4.
var userOptions = assign({}, globalOptions, loaderOptions);
var filename = path.relative(process.cwd(), absoulteFilename);
var transOpts = {
Expand Down
14 changes: 10 additions & 4 deletions src/plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ export default {
return
}

// ignore empty function body
const body = path.node.body.body
if (body.length === 0) {
return
const body;
if( t.isArrowFunctionExpression(path.node) && t.isCallExpression(path.node.body) ){
//CallExpression that in ArrowFunctionExpression doesnot have 'body' property. e.g. h => h(App)
body = t.returnStatement(path.node.body);
}else{
// ignore empty function body
body = path.node.body.body
if (body.length === 0) {
return
}
}

//gather function name
Expand Down