diff --git a/src/index.js b/src/index.js index fcca47c..907b2e8 100644 --- a/src/index.js +++ b/src/index.js @@ -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 = { diff --git a/src/plugin/index.js b/src/plugin/index.js index c9fce45..a4adae0 100644 --- a/src/plugin/index.js +++ b/src/plugin/index.js @@ -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