[w3c/webcomponents] How to handle non-type=”module” scripts in HTML Modules? (#798)

(Original OP by @dandclark)

The HTML Modules [design](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/HTMLModules/explainer.md) discussed thus far forbids modules from containing non-module scripts. This allows for overall easier integration into ES modules (which would otherwise be difficult if parsing an HTML module could run script prior to module graph instantiation/evaluation), and prevents issues with parser-blocking scripts like those in HTML Imports.

However it’s not clear how this should best be achieved. Our original proposal suggested that non-module scripts in an HTML Module should be automatically converted to `type=”module”`. This is simple and saves the developer some typing, and is in a similar spirit as the JavaScript module behavior of silently enabling strict mode for all module scripts. The disadvantage is that it could be potentially confusing for a developer new to the feature. I first saw this concern raised [here](https://github.com/w3c/webcomponents/issues/645#issuecomment-433036372) and [here](https://github.com/w3c/webcomponents/issues/645#issuecomment-433150926), and more recently on this [blink-dev thread](https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/ewfRSdqcOd8).

The alternative would be to treat a non-module script in an HTML Module as a parse error, resulting in a failure to instantiate the module. This is much more unambiguous, but devlopers might get a bit tired of needing to inlcude `type=”module” for every script element.

Since there has been discussion on this across a few different threads, I wanted to give a home to the topic here and see if some consensus can be reached.

Thoughts?

> See also (https://github.com/w3c/webcomponents/pull/793)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/798

Received on Wednesday, 27 February 2019 04:01:17 UTC