strothj / react-docgen-typescript-loader

Webpack loader to generate docgen information from Typescript React components.
Other
360 stars 47 forks source link

`__docgenInfo` object is undefined #2

Closed ainalain closed 6 years ago

ainalain commented 6 years ago

Hi, I'm sorry for troubling you for the second time, I'm really excited with your plugin 😇

When I commented 'react-select' import #1, all my stories have been compiled and run well. But the was no propTypes table, although I left the comments for every prop, as Storybook Addon Info described.

After debugging I found the reason if this absence.

In your example of plugin usage, the tsconfig.json file defines the module type option as "module": "commonjs".

In our project, we use ES6 modules, so our tsconfig.json contains this line: "module": "esnext". As a result, the Info Addon doesn't recognize the docgen object of the passed component function: the isNotEmpty method of makeTableComponent module returns undefined. This is because Webpack references all variables in our component with WEBPACK_IMPORTEDMODULE_{number}{variableName} thing.

screen shot 2018-02-10 at 22 25 39

In comparison, the check for __docgenInfo in your example works as expected:

screen shot 2018-02-11 at 01 21 40

I see that the react-docgen-typescript also uses commonjs modules in its tsconfig.json. Maybe this is react-docgen-typescript issue, not your. Or maybe there is a known solution for my case and I didn't found it. I'm not familiar with Webpack internal process, so for the moment, I don't know how to solve this issue.

strothj commented 6 years ago

Thanks for the report. I’ll take a look sometime this week.

strothj commented 6 years ago

Hello, I'm tracking this issue on #3. Should have a solution in not to long.

strothj commented 6 years ago

Closing as it is addressed by plugin.