Turn HTML imports into HTMLTemplateElement
npm install babel-plugin-transform-html-import-to-templateTurn HTML imports into HTMLTemplateElement.
Given the following _template.html_.
``html`
html template 🌞
#### in
`js`
import template from './template.html'
// ...
this.shadowRoot.append(template.content.cloneNode(true))
#### out
`js`
var template = document.createElement(template).innerHTML = 'html template 🌞'
`sh`
$ yarn add -D babel-plugin-transform-html-import-to-template
.babelrc
`json`
{
"plugins": ["transform-html-import-to-template"]
}
`sh`
$ babel --plugins transform-html-import-to-template script.js
`javascript
import core from 'babel-core'
const plugins = [
// ...
'transform-html-import-to-template'
// ...
]
core.transform(code, { plugins })
``