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

>b) Use ES6 template literal to instantiate from inlined HTML string.

I don't understand why HTML modules have to be involved with this. Why is this necessary:

```js
import template from module `
<div>hello, world</div>
` as HTMLTemplateElement;
```

when you can already do this?:

```js
const template = HTMLTemplateElement`
<div>hello, world</div>
`;
```

If you want to inline a `import template from 'my-template.html' as HTMLTemplateElement;` statement as a build step, surely it's straightforward to transform that from the import to the const declaration?

There's no equivalent for inlining a script import either, which I would guess is because the whole intent of the import system is to bring in external dependencies.

AFAICT the inline case is already well supported by template strings. What benefit is there to reinvent this  wheel with imports?

You could actually cover case b) using only case a) if you can provide a computed URL to import from. For example:

```js
import x from inlineCss`.rule {}` as StyleSheet;
```

This could simply create a blob URL to the inline string, and request that. Then we only have to implement generic imports with a URL, and get the inline case for free.

-- 
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/645#issuecomment-322436684

Received on Tuesday, 15 August 2017 10:48:34 UTC