Topic: How do module imports work?
tokerodev priority asked 9 months ago
Expected behavior
I am able to import individual components from dedicated modules, as specified here: https://mdbootstrap.com/docs/react/getting-started/optimization/
Actual behavior
I get the following error:
Cannot find module 'mdb-react-ui-kit/modules/MDBDatepicker' or its corresponding type declarations. ts(2307)
Resources (screenshots, code snippets etc.)
We have a fork of the pro repository on a self-hosted GitLab instance. I've encountered this error both when using our fork and when trying to use the official mdb-react-ui-kit
package.
Mateusz Lazaru staff answered 9 months ago
The optimization guide was created for older MDB versions. We will probably leave it only in legacy docs or mark it as deprecated.
About the problem:
Standard import described in the documentation import { MDBDatepicker } from 'mdb-react-ui-kit';
should make all the dead code removed in the build process. Unfortunately, it doesn't work perfectly at the moment, because of static property usage.
We will fix it as a priority.
Until that, if you need to reduce bundle size, importing from the source could be a workaround:
- Download MDB ZIP from 'my orders' or gitlab
- copy
src
folder frommdb5-react-ui-kit-pro-advanced/app/
tomy-project/mdb/
- Import component you need directly
import MDBDatepicker from '../../mdb/src/pro/forms/Datepicker/Datepicker';
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB React
- MDB Version: MDB5 7.2.0
- Device: N/A
- Browser: N/A
- OS: Windows 10
- Provided sample code: Yes
- Provided link: Yes