How can I use Bit with Vitejs in React without getting 'defaultExports is not a function' error?

223 views Asked by At

I am new to Bit. I tried creating a very simple component and push it to local bit server using create-react-app, it worked. But when I try to use the same component in a simple vitejs project, the composition doesn't show up. In console I get the following error:

Uncaught (in promise) TypeError: defaultExports is not a function
    at DocsPreview.eval [as render] (docs.preview.runtime.js:56:1)
    at PreviewPreview.eval [as render] (preview.preview.runtime.js:179:1)

enter image description here

Is it a vitejs specific issue? Does bit work with vite? OR am I missing something in typescript?

I expect bit to work with vite.

1

There are 1 answers

1
Jinjiang Zhao On

I think technically the React things you authored on Bit is compatible. However, May I know more details about how you use the composition in a Vite project? I assumed the Vite project isn’t in any Bit workspace, right? Then how did you consume the composition?

If I’m not wrong, at least you can import the React component and consume it as expected.

Thanks.