Re: [WICG/webcomponents] HTML Modules (#645)

Just throwing in my support and desire for HTML Modules.

I like that idea of using them to import what looks to be similar to an `HTMLTemplateElement` with the same `content` property: 
```
import htmlTemplateThing from 'foo.html';

const documentFragment = htmlTemplateThing.content.cloneNode(true);

// Do stuff with documentFragment or append it wherever you want...
```
The alternative today is authoring HTML as JS template literals and doing being limited to `innerHTML`.

More than that though, we so badly need this for packaging Web Components. 

Authoring and "importing" a complete Web Component is a pretty lame experience. You have to somehow get all your components' template source code, e.g. `<template>My Web Component<style>:host {...}</style></template>`, into the main document and then include the JS with the Custom Element definitions or you use template literals or imperative DOM to construct the template in JS. It's janky and error-prone and inefficient either way. I look at (and use) Riot.js and Vue.js single-file components with envy. I've been experimenting with [a Single File Web Components hack](https://github.com/jfbrennan/single-file-web-component) out of desperation. Would love for the web platform to solve this!

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/645#issuecomment-1603723036
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/645/1603723036@github.com>

Received on Friday, 23 June 2023 06:03:32 UTC