lookfirst/mui-rff

[bug] @material-ui/lab shouldn't be required when not using Autocomplete

depiction opened this issue · 10 comments

The readme says to run yarn add mui-rff @material-ui/core @material-ui/pickers final-form react-final-form to install all required dependencies. It also says to run yarn add @material-ui/lab if using Autocomplete. I created a basic login form using MUI-RFF with only the TextField (no Autocomplete).

import { TextField } from "mui-rff";

However, I got a compilation error when building my project.

Module not found: Can't resolve '@material-ui/lab/Autocomplete' in '/node_modules/mui-rff/dist'

I therefore had to install @material-ui/lab.

Expected behavior
@material-ui/lab shouldn't be required unless Autocomplete is imported from "mui-rff".

Thanks for the report. I noticed this as well. If you have ideas on how to solve this short of building every single component as its own package, that would be great.

Maybe @material-ui/lab could be included as an optional dependency in package.json, then imported using require() inside the Autocomplete function. See https://npm.github.io/using-pkgs-docs/package-json/types/optionaldependencies.html.

Yea, that or a peerDependency. Would you like to experiment and tell me which one is best?

I would say this is duplicate of #138

Optional seemed to work!

This is actually not fixed...

Storing this here for later consideration: https://github.com/pikapkg/pack

Adding this here to document it. With a clean install in a new project. The TextField component brings up the following error Error: Can't resolve '@mui/x-date-pickers'

Closing, haven't found a need to fix this in years...