Closed dvinubius closed 1 year ago
I've been able to solve the issue by going into
node_modules/react-moralis/lib/index.esm.js
and changing an import to a deep import:
import MoralisImport from 'moralis';
to
import MoralisImport from 'moralis/dist/moralis.js';
Clearly not ideal, but it makes it apparent that the bundler can't handle this dependency properly because of the way it is written in terms of its own imports / bundling process.
To make it more clear - vite uses rollup.js to perform the bundling. When dependencies have mixes es6 and commonJS modules this typically creates issues which can be mitigated by refactoring of the dependencies.
So if any of you guys who have worked on the moralis packaging could take a look, it's much appreciated! And surely helps future devs that get into this situation.
Thanks for the clear report. We will change the whole build process in the next major update (see https://github.com/MoralisWeb3/Moralis-JS-SDK/issues/245), where we also consider to use rollup (or other modern building tools), So that would probably resolve the issue.
That's great news! Thanks for all the work. Keep it up 👍
Maybe related (leaving it as a reference). Since Moralis is bootstrapped from Parse, and saw this issue with Vite on the Parse forums: https://community.parseplatform.org/t/vue-vite-parse-js-error-super-expression-must-either-be-null-or-a-function/2001
Closing this issue, as it's not relevant anymore since v2
New Bug Report
This issue seems related to Moralis SDK itself. However, I'm using react-moralis: ^1.3.1.
My react code is inside a Vite App and written in typescript.
I'm opening an issue with the Vite developer, too, but please take a look guys. You may recognize the potential source of the issue, or at least quickly exclude that it's from Moralis, I'll know where to tackle it best.
Issue Description
The cloud function call works in local development.
But in a production bundle it throws the following exception
Here is the stack trace
This is in Cloud.js line 98:
This is also Cloud.js line 171:
This is encode.js line 149:
This is encode.js line 65:
This is my vite.config.ts:
Server
0.0.347
Client