Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
depiction opened this issue Feb 28, 2020 · 10 comments
Closed
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@depiction
Copy link

depiction commented Feb 28, 2020

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".

@lookfirst
Copy link
Owner

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.

@lookfirst lookfirst added bug Something isn't working good first issue Good for newcomers labels Feb 28, 2020
@lookfirst lookfirst changed the title @material-ui/lab shouldn't be required when not using Autocomplete [bug] @material-ui/lab shouldn't be required when not using Autocomplete Feb 28, 2020
@depiction
Copy link
Author

depiction commented Feb 29, 2020

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.

@lookfirst
Copy link
Owner

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

@kybarg
Copy link
Contributor

kybarg commented Feb 29, 2020

I would say this is duplicate of #138

@lookfirst
Copy link
Owner

Optional seemed to work!

@lookfirst
Copy link
Owner

This is actually not fixed...

@lookfirst
Copy link
Owner

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

@lookfirst
Copy link
Owner

@martinrojas
Copy link

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'

@lookfirst
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants