Upgrading from version 4 to version 5 of @kinde-oss/kinde-auth-react gives compiler error
I've just upgraded @kinde-oss/kinde-auth-react from version 4.0.4 to version 5.5.0 and I get presented with the following compiler error:
After some googling it looks like the change may be related to CommonJS exports, but I'm pretty lost at this point. I'm importing
KindeProvider
like so:
8 Replies
Hi @jamie, your import looks correct.
Could you please share your
package.json
file?Oh actually that's the current branch I'm on
That should be the correct one
@Abdelrahman Zaki - Kinde
I've noticed that in node_modules
@kinde-oss/kinde-auth-react
the package.json shows:
But the files in dist/
look like:
It seems ./dist/kinde-auth-react.mjs
and ./dist/kinde-auth-react.js
don't exist, and the .mjs
files are not used.
Also the .js
files are missingHi @jamie, it looks like you're on version
5.6.0-2
, which is a pre-release.
Could you try switching to the latest stable version and see if it works?
Let me know how it goes!Hi @Abdelrahman Zaki - Kinde, yeah this was just from some experimental work I was doing to try and get things working. I found a fix in the end, but it doesn't seem to work with 5.5.0.
My colleague has opened a PR request with the SDK in question here: https://github.com/kinde-oss/kinde-auth-react/pull/155
I suspect that this isn't sufficient since as I understand it, you're using bundling software to generate the package.json. Also, when I tried to implement a fix for 5.5.0, it didn't work so I had to stick with 5.6.0-2.
Either way it is clear that the package.json is not correctly exporting. I have implemented a patch in our software to get things working with 5.6.0-2 using
patch-package
. In case it's helpful here's the patch file:GitHub
fix(package-json): fix package.json exports to provide correct mjs/...
Explain your changes
At present the imports and exports of the package are incorrectly mapped. This PR fixes them.
(Context: if you clone the repo, install it and run vite build, you get a cjs and ...
patches/@kinde-oss+kinde-auth-react+5.6.0-2.patch
To clarify, a base install of 5.5.0 also didn't helpHi @jamie, just letting you know the PR has been merged, thanks a lot for your help and detailed investigation! Really appreciate you taking the time to patch and share your findings.
Let us know if you run into anything else!