Topic: How do module imports work?

tokerodev priority asked 8 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 8 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:

  1. Download MDB ZIP from 'my orders' or gitlab
  2. copy src folder from mdb5-react-ui-kit-pro-advanced/app/ to my-project/mdb/
  3. Import component you need directly import MDBDatepicker from '../../mdb/src/pro/forms/Datepicker/Datepicker';

tokerodev priority commented 5 months ago

Hello! Any news on this?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • 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