Modularity: ES6 modules vs. HTML imports vs. asm.js

# Axel Rauschmayer (7 years ago)

With Web Components, we also get HTML Imports. This seems like yet another modularity construct on the web. Would it make sense to coordinate this with ES6 modules? I?m also hoping/assuming that asm.js will eventually use ES6 modules(?)

# Sam Tobin-Hochstadt (7 years ago)

HTML imports are importing HTML, not JS. Coordination is always good, but I don't know what that would entail here.

asm.js modules have some specific needs, and it may or may not be able to use ES6 modules. I'll let Dave speak to that.

# Axel Rauschmayer (7 years ago)

HTML imports are importing HTML, not JS. Coordination is always good, but I don't know what that would entail here.

They import a mix of HTML, CSS and JavaScript. So it isn’t entirely clear to me, either, what an integrated solution would look like (or if it would even make sense). But apart from the content, they are very similar to ES6 modules: you would also want to load on demand, they have dependencies that need to be fulfilledd, etc.

Axel

# Guy Bedford (7 years ago)

Will it be possible to ensure that HTML imports can allow the specific ES6 loader to be specified (just as I asked about script tags in my previous post)?

HTML imports using ES6 modules makes a lot of sense, because script tag duplication causes unnecessary script re-execution otherwise (imagine jquery being a <script> tag on many imports - if it is an imported module its code is executed only once).

So the main issue I'm worried about is that there needs to be some way to indicate that a custom loader should be used all the way down the import tree.

<script>
  window['my-es6-loader'] = new Loader( ... );
</script>
<link rel="import" loader="my-es6-loader" href="/imports/something.html">

is not enough because imports within the imported document would then revert to the system loader. Not sure how this gets solved.

In terms of the build tooling, these will now need to include the scope of both systems, but this seems rather inevitable at this point.

# Yehuda Katz (7 years ago)

I started a conversation with Rafael Weinstein last week about the possibility of integrating these systems. I believe that it is possible and desirable, but there are many open questions to answer still.

It will be easier to begin the discussion seriously once the Loader API is entirely specified, imho.