wojtekmaj / react-date-picker

A date picker for your React app.
https://projects.wojtekmaj.pl/react-date-picker
MIT License
1.27k stars 195 forks source link

Module not found: ESM packages (@wojtekmaj/date-utils) #616

Closed rossanodr closed 1 year ago

rossanodr commented 1 year ago

Before you start - checklist

Description

Description I encountered an error while trying to import the '@wojtekmaj/date-utils' package in the react-calendar module. The error message suggests that ESM packages need to be imported using 'import' instead of the current method.

Next.js version: 13 react-calendar version: 9.2.0

Steps to reproduce

Steps to Reproduce Install and set up Next.js version 13. Add react-calendar version 9.2.0 to the project dependencies. Attempt to import '@wojtekmaj/date-utils' in the CenturyView/Decade.js file located in the './node_modules/react-calendar/dist/cjs/' directory. Expected Behavior The '@wojtekmaj/date-utils' package should be imported successfully without any errors.

Expected behavior

Failed to compile

Actual behavior

Actual Behavior The following error is thrown:

./node_modules/react-calendar/dist/cjs/CenturyView/Decade.js:39:0 Module not found: ESM packages (@wojtekmaj/date-utils) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals Environment

Additional information

No response

Environment

wojtekmaj commented 1 year ago

Hmmm, @wojtekmaj/date-utils is a dual ESM/CJS package. I just published @wojtekmaj/date-utils@1.4.1 - please update it and let me know if this fixes the issue for you.

rossanodr commented 1 year ago

After I've updated to "react-date-picker": "^10.2.0" I got the following error: ./node_modules/react-date-picker/dist/cjs/DateInput/Input.js:32:0 Module not found: ESM packages (update-input-width) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals

rossanodr commented 1 year ago

Ok, I fixed it: probably it was something local. I've deleted the next folder again, restarted my pc and tried to build it again. Now it works

wojtekmaj commented 1 year ago

It was not entirely local, you published this half an hour after I added native ESM support to @wojtekmaj/date-utils package, and it "fixed itself" half an hour after I published a bugfix :D Thanks for reporting!