better-docs
better-docs copied to clipboard
Fix: Babel React component
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.