es-toolkit icon indicating copy to clipboard operation
es-toolkit copied to clipboard

Some toolchains fail to find module `es-toolkit/compat`

Open tay1orjones opened this issue 8 months ago • 0 comments

We replaced usages of lodash with es-toolkit/compat in our library, @carbon/react, and have found that consumers with older toolchains are encountering issues with this module, https://github.com/carbon-design-system/carbon/issues/18403.

Two primary issues have been reported:

  1. Projects using jest <=v27 fail and require adding a moduleNameMapper entry to their jest config
  2. Projects using create-react-app/webpack fail to build w/ error:
    .\node_modules\@carbon\react\es\components\DataTable\Table.js
    Cannot find module: 'es-toolkit/compat'. Make sure this package is installed.
    

I think the cause is either

  • some (older) tooling lacks proper support for the exports field in package.json
  • .mjs files trip up certain toolchains module resolution for some reason

There may not be anything you can or want to do to help this situation. You're using exports correctly, it's the tooling w/ the issue. I opted to try and avoid the module resolution problems altogether by temporarily marking es-toolkit as an internal and inline what we use into our bundle, https://github.com/carbon-design-system/carbon/pull/18639

Feel free to close this if you agree it's not actionable on your part. Thanks for all your work on this library! 🙏

tay1orjones avatar Feb 21 '25 16:02 tay1orjones