I'm going to explain the situation:
These are the files that I end up with after exporting my Godot game in HTML5: export files
The most relevant file is "WYS 0.1.js", because is where all the other useful files, like the .pck one, are imported and used to execute the application in the HTML file.
In short, if I understand it well, it's a very huge file where the scope is to create a class named "Engine" from which is possible to execute some methods like startEngine() useful to start the game, following specific configurations that are passed as a parameter of the class. If you want to check this file here is the link: https://drive.google.com/file/d/12JYPd5ItYFFelcJcpIX3eU7kr42Y36up/view?usp=sharing (Just skip the initial wall of text to see some code that makes sense).
How the HTML file execute the game?
Simply with a <script> tag with src attribute pointing to the "WYS 0.1.js" path and another <script> tag with some inline JavaScript that create a new instance of the class Engine and deals to correctly load the game and animate the loading of the game (Moving the inline javascript to a separate js file and typing the correct path in the src attribute won't break the execution).
The game, to be correctly executed, needs to be on a server. So, I place myself in the export folder with the command line and create a simple server with this Python command: python -m http.server 8080, and everything works as it should. Just to be clear.
React Part:
After created the app with the npx create-react-app name-app command, my first attempt was to creat a React Component importing the "WYS 0.1.js" and the inline JS code moved in a separate file and, from that React Component, use the Engine to load and start the game correctly (Engine accessible by adding export before the const Engine declaration). But, what I obtained is a compile error reporting a lot of undefined variables and other stuff like that:
Line 10:990: Unexpected use of 'self'
Line 10:74354: Expected an assignment or function call and instead saw an expression
Line 10:131511: 'res' is not defined
Line 10:115986 :Unexpected use of 'addEventListener'
As you can see, these errors are located principally in the Module variable (the wall of text) and, outside of it, only a certain "define" that is placed just under the wall of text.
I also tried to simply add the <script> tags in the index.html file generated by the npx create-react-app command, but it doesn't work at all.
It's not clear to my mind why something is defined in the HTML part and suddenly became undefined when moved in a ReactApp.
Thanks in advance to everyone who will help me, also because information on this topic is very scarce.