supertokens-core
supertokens-core copied to clipboard
TypeError: (intermediate value).default is not a constructor
🐛 Bug Report
When using Snowpack, supertokens-website causes the following error TypeError: (intermediate value).default is not a constructor
when calling the init
function.
Useful informations
I'm using snowpack 3.2.2 and supertokens-website 10.0.8.
Here is my index.ts:
import SuperTokens from 'supertokens-website'
SuperTokens.init({ apiDomain: "http://localhost:3001", apiBasePath: "/auth"})
And here is the full error:
Uncaught TypeError: (intermediate value).default is not a constructor
init http://localhost:8082/_snowpack/pkg/supertokens-website.v10.0.8.js:3411
<anonymous> http://localhost:8082/dist/index.js:2
supertokens-website.v10.0.8.js:3411:26
init http://localhost:8082/_snowpack/pkg/supertokens-website.v10.0.8.js:3411
<anonymous> http://localhost:8082/dist/index.js:2
InnerModuleEvaluation self-hosted:2388
evaluation self-hosted:2349
Have you tried to import like import * as SuperTokens from 'supertokens-website'
?
I just tried it but I still get the same error.
It looks like there is a similar issue with an other package on Snowpack: withastro/snowpack#3155
For now, I can work around it by importing and initializing it directly in my index.html. It's not really convenient but it works.
Hmm. We will have to look at how it's built. But this is probably not a priority for us at the moment, unless more people face this issue.
However, please feel free to issue a PR to fix this.