atlassian / extract-react-types

One stop shop for documenting your react components.
https://atlassian.github.io/extract-react-types/
MIT License
179 stars 28 forks source link

Babel plugin fails to extract props when project Babel config contains overrides #209

Open jksmithing opened 2 years ago

jksmithing commented 2 years ago

Because we call babel.parse() without specifying the filename option (code), the plugin is not compatible with projects that have overrides in their Babel config.

E.g. if babel.config.js contains overrides: [{ test: '**/*.ts', plugins: ['@babel/plugin-transform-typescript'] }] then it will silently fail because we ignore errors and Babel cannot determine what config to use for parsing.

The issue explains the problem more thoroughly: https://github.com/babel/babel/issues/11540

Passing { filename: '' } into the babel.parse() options appears to fix the issue.