supertokens-core icon indicating copy to clipboard operation
supertokens-core copied to clipboard

TypeError: (intermediate value).default is not a constructor

Open pvharmo opened this issue 3 years ago • 3 comments

🐛 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

pvharmo avatar Feb 01 '22 19:02 pvharmo

Have you tried to import like import * as SuperTokens from 'supertokens-website'?

rishabhpoddar avatar Feb 01 '22 20:02 rishabhpoddar

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.

pvharmo avatar Feb 02 '22 19:02 pvharmo

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.

rishabhpoddar avatar Feb 03 '22 06:02 rishabhpoddar