title: function in my javascript module is not defined
body: <p>I'm writing JavaScript for the browser, my script.js has something like </p>
  
  <pre><code>import { foo, bar } from "./lib/sth.js"
  function main() { ... }
  </code></pre>
  
  <p>Then I have this in my browser:</p>
  
  <pre><code>&lt;script type=module src="./script.js"&gt;&lt;/script&gt;
  &lt;body onload="main();"&gt; ... &lt;/body&gt;
  </code></pre>
  
  <p>But it's keep giving me this error:</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: main is not defined
        at onload ((index):7)</p>
  </blockquote>
  
  <p>Why is my main now defined? It works fine before I use type=module, but with the import statement, I believe it has to be type=module</p>