better-docs icon indicating copy to clipboard operation
better-docs copied to clipboard

Fix: Babel React component

Open flolbr opened this issue 3 years ago • 0 comments

When running on a React component with the better-docs/component plugin enabled, this error shows up:

C:\<project_path>\node_modules\better-docs\component.js:68
      throw error
      ^

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

It appeared to be caused by the call to reactDocs.parse() in component.js:58.

By passing an empty filename argument (since it is not used anyway), the error stops being thrown and the doc builds fine.

flolbr avatar Oct 18 '22 13:10 flolbr