I'm trying to use the feature of new browsers that allows you to load JavaScript modules as apposed to scripts.
Every example of this seems super straight forward. You simply change the type attribute from "text/javascript" to "module".
I have a simple test.js file that just grabs a DOM node and sets its inner HTML to "Hello" :
const output = document.querySelector("#output");
output.innerHTML = "hello";
This works when type = "text/javascript" but fails with type = "module" :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Modules</title>
</head>
<body>
<main>
<h1>JS Modules</h1>
<div id="output"></div>
</main>
<script type="module" src="./test.js"></script>
</body>
</html>
What am I missing?