I have problem with importing JS scripts from code. I have a canvas
game, and want to import my classes rather than define they in HTML. But when I run my code in E
Solved! The problem was in HTML script declaration:
I used this code:
<script src="base/init.js"></script>
But I don't knew, that I need to specify type
attribute, with code below import
works excellent!
<script src="base/init.js" type="module"></script>
UPD: variables just are file-scoped, to use in another file export variables:
var myVar = "string";
export {myVar};
and then in your file
import {myVar} from "<file>";