Adding JavaScript modules to the web platform
If you don&#x27;t find JavaScript modules confusing, you should. I work on a module loader [1] and I find it quite confusing. To clarify we have 3 things:<p>1. import and export syntax, this is defined in ES2015. It&#x27;s just syntax, it doesn&#x27;t explain how modules should be loaded.<p>2. The Loader spec (<a href="http:&#x2F;&#x2F;whatwg.github.io&#x2F;loader&#x2F;" rel="nofollow">http:&#x2F;&#x2F;whatwg.github.io&#x2F;loader&#x2F;</a>) which defines a full loader including hooks to do just about anything you can possibly need. This allows you to do really crazy things like define modules dynamically and import then dynamically (which the static import&#x2F;export syntax doesn&#x27;t allow). We use this extensively in StealJS (or at least an older version of it) and it&#x27;s pretty powerful.<p>3. import type=module is what this article is referring to. It defines a tag that allows you to import modules in the browser. You can&#x27;t use a regular script tag, modules are different; they are strict mode by default for example.<p>If you read the GitHub issue there was some discussion of whether import type=module should use the Loader spec. It probably should. But the Loader spec isn&#x27;t done so... reading the spec and seeing things like the module map [2] it sounds like import type=script defines a miniature sized loader.<p>I don&#x27;t blame them for doing this, Loader has taken too long and people are clamoring for <i>something</i>. The Loader spec has a weird history; it was close to being done in ES2015 but when it was ejected it sit for a <i>long</i> time without much work. Then around last summer it was heavily worked on and got pretty far. But now as it sits, no commits like the last 2 and a half months [3]<p>At this point I wouldn&#x27;t be surprised to see Loader go away. It&#x27;s probably too controversially and too big to ever get done. I imagine the web will just have the import type=module loader and Node will do it&#x27;s own this. This is going to make writing portable JavaScript as annoying going forward as it&#x27;s always been.<p>[1] <a href="http:&#x2F;&#x2F;stealjs.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;stealjs.com&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;html.spec.whatwg.org&#x2F;multipage&#x2F;webappapis.html#module-map" rel="nofollow">https:&#x2F;&#x2F;html.spec.whatwg.org&#x2F;multipage&#x2F;webappapis.html#modul...</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;loader&#x2F;commits" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;loader&#x2F;commits</a>