I'm using Vite in a nodejs environment to build a ThreeJS app. The scene and all the ThreeJS elements, functions are stored in main.js .
I want to execute a function when I click a button, that's why I use the "onclick" attribute. I don't want to overcharge the app by using an event listener to that button.
My problem is that the console is saying the said function is undefined, and after some tests all the functions from that file are undefined. The browser console can't execute them, and none of the nodes present on the page can execute the functions.
Since the code relies on imports, the file is linked to the html file with this tag type="module"
meaning the whole page is a module. I tried to use the "export" keyword when declaring the function but I can't use imports in a onclick property so it didn't work.
I'm sure the function works since when I call it from the module (in the same file it got declared) I can see it is executed in the browser. I don't know what to do, I'm pretty sure there's a solution but even by looking in Mozilla's documentation I couldn't find anything... Have a nice day and thank you for reading... Feel free to ask for more context if you need so :)