-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Fix entrypoints for CJS and ESM modules #4792
Conversation
hey @jopesh, I came here looking around after getting the following error - this looks to be in the same realm:
Following this in case this might be a fix. Thanks for this work! |
Same issue with vite-plugin-ssr. Cannot upgrade Mantine until this is fixed. |
Same issue with Rakkas. Node.js (without a bundler) cannot import ESM files with a The fix would be to rename ESM files as Here's the most minimal reproduction possible. Just importing
|
Thanks! |
I've published |
With Remix I get still the same error (Made the project according to instructions: https://mantine.dev/guides/remix/) |
You need to rename |
I've created a PR for remix v2 migration, it works fine, although most of the things like storybook and jest are not supported, but there is not much I can do on my side. |
I am still getting this error in nextjs v13.4.7 |
Try updating to the latest version of Next.js |
I have been experiencing issues with the v2 release of Remix and Mantine v7 (see https://discord.com/channels/854810300876062770/1066443903080869889/1153294961324851220). Since Remix v2 is now ESM-only by default, it apparently changed the interaction with the
@mantine/*
packages:As far as I can tell and by testing the issue with a local modified
mantine
build, it seems that Remix imports the Mantine packages as CommonJS – even though there are ESM files provided.Jacob Parris from the Remix community pointed me to this test: https://arethetypeswrong.github.io/?p=%40mantine%2Fcore%407.0.0
It led me to this problem description: https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FallbackCondition.md in combination with this one https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md
Digging deeper and testing it on my machine, the problem projected on Mantine appears as follows: since Mantine is no ESM-native package (missing type: "module" in package.json), some bundlers (or just native Node.js?) treat it as a CommonJS package, hence the
index.d.ts
type declarations defined early in thepackage.json
. To solve this, one would have to declare different type AND module entrypoints for both ESM and CJS to separate them consequently – like in this example :After changing the ESM output to
.mjs
, creating a duplicateindex.d.mts
file and updating thepackage.json
as shown above, the packages work with Remix v2 (tested @mantine/core and /hooks)It also still works with the
remix-min-template
using >v1 of Remix.Disclaimer: I am not expert in package distribution and this whole CJS/ESM rabbit hole. Hence, I do not declare final wisdom here – just some uneducated afternoon troubleshooting.