Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix react-docgen complaining about missing filename config #24

Conversation

mauriciosoares
Copy link
Contributor

@mauriciosoares mauriciosoares commented Jun 18, 2021

When I updated react-docgen in another PR, I first added a check to only use the filename option for TS files. But that broke my (and possibly others) project build complaining that the filename option is required for those files. This is the error I was getting:

[BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
    ```
    babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });
    ```
    See https://babeljs.io/docs/en/options#filename for more information.

The file producing this error was a .js file with pretty simple JSX syntax into it.

I started looking into this, and noticed that adding the filename option for all files when calling the react-docgen lib fixed the issue. In my other PR the tests were breaking for react and flow with that filename option because I had to install a babel presets for those (since I updated babel, I didn't really add these presets).

So this PR adds the presets for react and flow + no longer checks if the file extension is ts in order to use the filename option. That'll now be provided for every file that's used.

btw, no idea why the package.lock file had such a big difference from old to new file on this PR, must be related to a different node version we're using... 🙈

@typicode
Copy link
Owner

👍 I'll publish a fix, thanks :)

@typicode typicode merged commit 77df88f into typicode:main Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants