mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
3.74k stars 1.11k forks source link

[pickers] Unable to import DatePicker V6 components from components library #9170

Closed reedasha closed 8 months ago

reedasha commented 11 months ago

Order ID or Support key 💳 (optional)

Order ID - #46063

Duplicates

Latest version

The problem in depth 🔍

We have a storybook component library where we're using @mui/x-data-grid-pro and @mui/x-date-pickers. We successfully upgraded datagrid to v6, but when trying to upgrade datepicker to '6.0.0' we faced an issue when importing the component from the components library in a separate project.

We have a component in our library that is using DateCalendar and DesktopDatePicker. The component that is causing issues is DesktopDatePicker, but the same is happening with DatePicker, StaticDatePicker and DateField components. If we remove DesktopDatePicker and leave DateCalendar, it works fine.

When running storybook locally there are no issues, the component with the datepicker is working perfectly fine. It is only when we build the components library with rollup, npm link it with the another project locally and import the component there, is when we get the issue. The app is crashing with the following error in console:

image

If we import DatePicker directly from @mui/x-date-pickers in the project, it works fine as well. Also tried importing components in another project and seeing the same issue, so it shouldn't be connected to the project's particular setup.

Could there be an issue with how rollup is building the new datepicker v6 components?

Your environment 🌎

`npx @mui/envinfo` ``` System: OS: Linux 5.15 KDE neon 5.26 CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz Memory: 4.87 GB / 15.51 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 17.9.1 - ~/.nvm/versions/node/v17.9.1/bin/node npm: 8.11.0 - ~/.nvm/versions/node/v17.9.1/bin/npm Managers: Apt: 2.0.9 - /usr/sbin/apt pip3: 20.2.4 - ~/anaconda3/bin/pip3 RubyGems: 3.1.2 - /usr/bin/gem Utilities: Make: 4.2.1 - /usr/bin/make GCC: 9.4.0 - /usr/bin/gcc Git: 2.25.1 - /usr/bin/git Servers: Apache: 2.4.41 - /usr/sbin/apachectl Virtualization: Docker: 23.0.1 - /usr/bin/docker IDEs: Nano: 4.8 - /usr/bin/nano Sublime Text: 4143 - /usr/bin/subl VSCode: 1.76.2 - /usr/bin/code Vim: 8.1 - /usr/bin/vim Languages: Bash: 5.0.17 - /usr/bin/bash Perl: 5.30.0 - /usr/bin/perl Python: 3.8.5 - /home/reedvl/anaconda3/bin/python Python3: 3.8.5 - /home/reedvl/anaconda3/bin/python3 Ruby: 2.7.0 - /usr/bin/ruby Databases: SQLite: 3.33.0 - /home/reedvl/anaconda3/bin/sqlite3 Browsers: Chrome: 111.0.5563.64 Firefox: 111.0 ```

Browser used is Chrome

alexfauquette commented 11 months ago

Not sure it's related, but both charts and pickers use useEnhancedEffect. However, the pickers sometimes import it with

import useEnhancedEffect from '@mui/utils/useEnhancedEffect';

whereas the grid always uses

import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';

@reedasha could you try to modify your package.json with:

'@mui/x-date-pickers': 'https://pkg.csb.dev/mui/mui-x/commit/8dcf956a/@mui/x-date-pickers',
// or 
'@mui/x-date-pickers-pro': 'https://pkg.csb.dev/mui/mui-x/commit/8dcf956a/@mui/x-date-pickers-pro',

It's the package generated by #9172 where I removed the nested imports

reedasha commented 11 months ago

@alexfauquette Yes! That was it. Thank you so much! Which version is the fix going to be included?

alexfauquette commented 11 months ago

We need to discuss the solution with a team member who is out of office up to next week. So probably in 2 weeks

LukasTy commented 11 months ago

We need to discuss the solution with a team member who is out of office up to next week. So probably in 2 weeks

As we have two approaches in our codebase already, maybe we could revert to using the same one for now (@mui/utils root imports everywhere) to unblock anyone with this case? Once we decide on a direction, an appropriate change could be made to the whole codebase. 🙈 And in any case, the @mui/utils is a somewhat small package, using one or the other import technique shouldn't change the dev build speed significantly. 🤔

cc @alexfauquette @flaviendelangle

reedasha commented 9 months ago

@alexfauquette Hi, are there any updates on this?

LukasTy commented 9 months ago

Hi, are there any updates on this?

Are you still having issues with it? We've made a fix on the @mui/utils side to allow the type of import usage we employ in our packages. It should work correctly on the newest package version. 🤔

github-actions[bot] commented 8 months ago

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.