I am trying to make simple example of vanilla ES import export.
index.js
The simplest would be to remove the export
and import
expressions since you're already including both files in your html.
const foo = Math.sqrt(2) // mathModule.js
console.log(foo) // main.js
If you are using node or something similar to run the script, maybe you should use a transpiler such as babel. Import
and Export
are "new" javascript features hence they're not implemented in most browsers