-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
dont bundle everything in one file / should not require @mui/x-date-pickers unless used #237
Comments
add the peerDependencies, they will be stripped out of your bundler # yarn add @mui/x-date-pickers @mui/icons-material |
@dohomi I think the concern here is about the way components are imported from react-hook-form-mui. In mui, we can import components using both named import as well as path import. // Named import
import { TextField } from '@mui/material';
// Path import
import TextField from '@mui/material/TextField'; Named imports are good for a better development experience but it can lead to slower startup times as it can contain the full library code. Mui has documented this in their guide for minimizing bundle size. https://mui.com/material-ui/guides/minimizing-bundle-size/ Also, If we can move components for @mui/x-date-pickers to a different package it would be better because it is possible not everyone is going to use those components. |
is that really a concern nowadays? Isn't everyone using modern tools like Vite or NextJS which have very fast startup times? We could have a look for v7 if it make sense to support additional exports, but I find it rather confusing if there are multiple approaches, not sure if MUI will keep the path imports in v6 though |
Modern tools, such as Vite or NextJS, do have an exceptionally rapid startup time. However, when dealing with projects that have a large number of components, the use of barrel files can result in slower updates during Hot Module Replacement (HMR) and longer startup times. I have found these two articles from Vite and NextJS for optimizing performance and avoiding the use of barrel files Vite documentation: https://vitejs.dev/guide/performance#avoid-barrel-files |
The way the installation section is worded right now makes it seem like the peer dependencies are supposed to be optional:
|
closing in favour of #252 |
Duplicates
Latest version
Current behavior 😯
import { FormContainer, TextFieldElement } from 'react-hook-form-mui'
throws in webpack
why ? because package bundles everything in one file
[nix-shell:~/projects/asdf]$ tree /home/srghma/projects/asdf/node_modules/react-hook-form-mui /home/srghma/projects/asdf/node_modules/react-hook-form-mui ├── dist │ ├── date-fns.d.ts │ ├── date-fns.js │ ├── date-fns.js.map │ ├── esm │ │ ├── chunk-FJYXLP4R.js │ │ ├── chunk-FJYXLP4R.js.map │ │ ├── date-fns.js │ │ ├── date-fns.js.map │ │ ├── index.js │ │ └── index.js.map │ ├── index.d.ts │ ├── index.js │ └── index.js.map ├── LICENSE ├── package.json └── README.md 2 directories, 15 files
Expected behavior 🤔
expected
allow import as
similar to how mui itself allows
The text was updated successfully, but these errors were encountered: