i wanted to move part of my code into JS module, but when I did that i get:
Uncaught SyntaxError: Unexpected token {
on line 3 of script.js
The script.js starts like this:
'use strict'
import {MyClass} from "./module.js";
The module.js starts like this:
'use strict';
export class MyClass {
Both files are imported in index.html at the end of body:
<script src="js/module.js" type="module"></script>
<script src="js/script.js"></script>
When I change reference to script.js to type="module"
, the error is not thrown anymore, but I cannot use any of script.js's functions in onload etc.