luma.gl icon indicating copy to clipboard operation
luma.gl copied to clipboard

Luma errors when using Vite: Super expression must either be null or a function

Open amcdnl opened this issue 3 years ago • 4 comments

Issue

I'm migrating from CRA to Vite for my UI builds, however, when I try to run the project I get the following error:

inherits.js:4 Uncaught TypeError: Super expression must either be null or a function

which traces back to:

image

if I look at the code throwing the error:

image

It shows that superClass is null which is referring to the Resource class.

If you do some quick research, it seems like its related to the class extends with static props: https://stackoverflow.com/questions/30116430/reactjs-giving-error-uncaught-typeerror-super-expression-must-either-be-null-or

Versions

"@msrvida/sanddance-react": "3.0.1",
"@deck.gl/core": "8.3.7",
"@deck.gl/layers": "8.3.7",
"@luma.gl/core": "8.3.1",
"vite": "^3.0.8",

amcdnl avatar Aug 19 '22 12:08 amcdnl

On the master branch all examples in the luma.gl examples folder use vite and this has not come up. It could of course be specific to the v8 release branch. An isolated repro case might be useful.

ibgreen avatar Aug 19 '22 13:08 ibgreen

There could have been some circular referencing that was fixed between 8.3 and 8.5.

My suggestion is to upgrade deck/luma to the latest releases. There are plenty of users using vite/esbuild right now.

Pessimistress avatar Aug 19 '22 13:08 Pessimistress

Sadly I'm locked due to Sanddance. I was able to work around this by forcing it to use the ES5 version in Vite:

    resolve: {
      alias: {
        '@luma.gl/core': '@luma.gl/core/dist/es5/index.js',

amcdnl avatar Aug 19 '22 13:08 amcdnl

@danmarshall

Pessimistress avatar Aug 19 '22 13:08 Pessimistress