MoralisWeb3 / react-moralis

Hooks and components to use Moralis in a React app
MIT License
624 stars 166 forks source link

React Moralis not working with Vite Built React App #210

Closed djimenezdev closed 2 years ago

djimenezdev commented 2 years ago

Hello! So I have built my react app using vite rather than create react app. I installed react-moralis via yarn and I imported the MoralisProvider Component into my main.jsx and wrapped the App component as seen below:

react-moralis-1

And when I run the app I get this issue:

react-moralis-2

I was confused about this until I read that I needed to have the moralis pacakage installed as react-moralis requires it as a dependency so I installed moralis via yarn and thought that would fix the issue until I got this error in the console:

react-moralis-3

Would anyone happen to know how I could go about fixing this issue?

Thanks for the help!

ErnoW commented 2 years ago

Hmm, seems to be an issue with how Vite is handleing ES6 modules. I saw this post (https://community.parseplatform.org/t/vue-vite-parse-js-error-super-expression-must-either-be-null-or-a-function/2001), a similar error on Parse (Moralis bootstrapped from Parse, so this is likely the same error)

We have little experience in Vite, and need to check if this is an issue that we can solve, or if it is a configuration of Vite for example.

ErnoW commented 2 years ago

Possibly related to: https://github.com/MoralisWeb3/Moralis-JS-SDK/issues/271

djimenezdev commented 2 years ago

No worries! thank you so much reading through the links you sent me helped me figure out how to get it working in development and production. I appreciate the help!