atlassian / atlassian/extract-react-types

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

Open
#209 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
188
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Because we call `babel.parse()` without specifying the [`filename`](https://babeljs.io/docs/en/options#filename) option ([code](https://github.com/atlassian/extract-react-types/blob/a73f91632d43b6a05d4a380c781e8249257e6bc0/packages/babel-plugin-extract-react-types/index.js#L27)), 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.