I'm trying to understand how ES6 export works.
Here are two local files:
main.html:
<script src="module.js"></script>
<script>
import {hello} from './module'; // Tried both "module" and "module.js"
let val = hello();
alert(val);
</script>
module.js:
export function hello() {
return 'Hello';
}
Expected result: alert with "Hello" text in it. Actual result: errors:
module.js - line 1: Unexpected token
export
main.html - line 3: Unexpected token
{
How to make it work?
PS. Tested in Chrome 67.