mui / material-ui

Material UI: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
https://mui.com/material-ui/
MIT License
91.73k stars 31.51k forks source link

[code-infra] Make Babel config path configurable in API docs builder #41999

Closed michaldudak closed 1 week ago

michaldudak commented 1 week ago

The Babel configuration path in the API docs builder was hardcoded, causing problems when the package was used in other repositories. Added the relevant configuration field (defaulting to the previous value).

mui-bot commented 1 week ago

Netlify deploy preview

https://deploy-preview-41999--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad) No bundle size changes

Generated by :no_entry_sign: dangerJS against ca1c9ed60f093da78e41ded73be3fe8b2a197a83

Janpot commented 1 week ago

I think it should be possible to leverage @babel/core API loadPartialConfig to detect the config file location that applies to a file automatically. It's not super well documented, but it seems like the following returns a config location

// config property should contain the path to the project babel.config.js file that applies to `pathToCodeFile`
const { config } = babelCore.loadPartialConfig({ fileName: pathToCodeFile })
michaldudak commented 1 week ago

Thanks! I didn't realize Babel would look for the config automatically. Looks like it works well in both Core and Base UI repos.