Seems like my web-days are too long away. When I started programming we referenced a script using a <script>
-tag:
<html>
<head>
<script src="lealet.js"></script> <!-- I know the path isn´t correct, I just reference leaflet -->
<script src="myscript.js"></script>
</head>
<body><script>myFunction()</script></body>
</html>
where myScript
is this:
function myFunction() { var map = new L.Map(...); }
which just creates a leaflet-map. Now I wanted to migrate this to some statically-typed TypScript. Instead of referencing leaflet from within my HTML-file, I used this in mScript.ts
:
import * as L from 'leafet';
function myFunction() { var map = L.Map(...); }
I compiled that to JS. However when running my site in the browser using the HTML from above I get this:
Uncaught SyntaxError: Cannot use import statement outside a module
I´m targeting ES6 with modulekind ES6.