mui / material-ui-pickers

Date & Time pickers for Material UI (support from v1 to v4)
https://github.com/mui/material-ui-pickers/issues/2157
MIT License
2.32k stars 833 forks source link

Support for nested imports? #1934

Closed aamirafridi closed 3 years ago

aamirafridi commented 4 years ago

Using the Import like this for treeshaking

import {
  DesktopDateRangePicker,
  MobileDateRangePicker,
} from "@material-ui/pickers/DateRangePicker/DateRangePicker";

No TS error but JS errored Cannot find module '@material-ui/pickers/DateRangePicker/DateRangePicker'

aamirafridi commented 4 years ago

I know that this works

import {
  DesktopDateRangePicker,
  MobileDateRangePicker,
} from "@material-ui/pickers";
oliviertassinari commented 4 years ago

@aamirafridi We don't support nested imports for the pickers repository. We might with https://github.com/mui-org/material-ui/issues/19706. I think that the correct solution would be:

import DateRangePicker, {
  DesktopDateRangePicker,
  MobileDateRangePicker,
} from "@material-ui/pickers/DateRangePicker";

The incentive so far for supporting it is that tree-shaking doesn't work in development, which can harm the DX.

aamirafridi commented 4 years ago

Ok thanks :)

oliviertassinari commented 4 years ago

Keeping it open to signal that it's not fixed and incentive for more comments.

oliviertassinari commented 3 years ago

Done in https://next.material-ui.com/components/pickers/