<needle-engine> in another page shows an error

When using Vue with a router, I would like to be on a specific page instead of the index. It works correctly except that the console shows an error : Cannot read properties of null (reading 'addEventListener') (in any page).

Unfortunately I don’t have any stacktrace of this error (the sourcemaps are missing), and the weird thing is that it occurs even while omitting to load the needle engine’s sources (@needle-tools/engine and generated/gen.js).

Original Post on Discord

by user 615280976855171083

Hey - if you have this running locally you should be able to see stacktraces - have you tried that?

itself is just a regular web component that then does some extra work to set up a Canvas to render into etc., so would be interesting what actually fails there

Well the sources are local, but I got plenty of messages in the console saying that the source maps are missing, I don’t know why. :open_mouth: Thus the stacktrace only points to “index.html” with a random line.

by user 615280976855171083

Indeed, I don’t know which script tries to add a listener on this element too early. I’ll try to search a bit more.

by user 615280976855171083

Hey @totjoss can you try to break on that error using the chrome debugger?

Unfortunately I can’t break on it as I have no information about where the error happens.
I’ve just been testing on a new project with the default settings/vite (sourcemaps are working with this project). But I still have no other info than this:

by user 615280976855171083

I only had to comment the element to make the error happen, event if the scripts are commented as well.

by user 615280976855171083

Do you think you could give us access to the project or send a small repo of it?

Well, actually you just have to make a new blank web project via Needle Engine “create project” and then comment the lines on the index.html and you’ll get the error.

by user 615280976855171083

Even with a basic scene.
image.png

by user 615280976855171083

Ah i have an suspicion what the reason could be. Can you try removing the needle plugins from the vite.config.js?

Yep ! That’s it, when removing the needlePlugins(command, needleConfig), line, no error shown.

by user 615280976855171083

Ok, then one of the plugins does assume e.g. the needle engine component. Should be easy to fix :slightly_smiling_face:

Additionally it should be a dev server only problem

Not sure if you can confirm?

Oh never tried to build a project yet.

by user 615280976855171083