SoftwareBrothers / better-docs

Beautiful toolbox for jsdoc generated documentation - with 'typescript', `category` and `component` plugins
MIT License
861 stars 127 forks source link

Fix: Babel React component #231

Open flolbr opened 2 years ago

flolbr commented 2 years ago

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.