From a3403adcff8596a7000cd30f4438bcabf675887e Mon Sep 17 00:00:00 2001 From: lttb Date: Mon, 13 Jan 2020 02:34:51 +0300 Subject: [PATCH 1/2] fix: provide filename to babel --- src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b6afca2..5e03202 100644 --- a/src/index.js +++ b/src/index.js @@ -19,6 +19,7 @@ export default function({ types: t }) { } function injectReactDocgenInfo(path, state, code, t) { + const { filename } = state.file.opts; const program = path.scope.getProgramParent().path; let docgenResults = []; @@ -36,7 +37,9 @@ function injectReactDocgenInfo(path, state, code, t) { } const handlers = [...defaultHandlers, ...customHandlers, actualNameHandler]; - docgenResults = ReactDocgen.parse(code, resolver, handlers); + docgenResults = ReactDocgen.parse(code, resolver, handlers, { + filename, + }); if (state.opts.removeMethods) { docgenResults.forEach(function(docgenResult) { From f5ad2e208db6764631c888585041090026f1f446 Mon Sep 17 00:00:00 2001 From: lttb Date: Mon, 13 Jan 2020 02:35:33 +0300 Subject: [PATCH 2/2] fix: apply necessary babel presets and plugins it's important to set all the necessary presets and plugins in the babel root config to avoid issues with react-docgen --- .babelrc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.babelrc b/.babelrc index e7d1644..5d7d2e0 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,4 @@ { - "presets": [ - "@babel/env", - ] + "presets": ["@babel/env", "@babel/flow", "@babel/react"], + "plugins": ["@babel/plugin-proposal-class-properties"] }