I have created two web components that live in separate files. When I try to reference one in the other using an import I get an error
Uncaught SyntaxError: Unexpected token '-'
My code
File1
class element1 extends HTMLElement {
constructor() {
super();
const li = document.createElement('li');
this.shadowRoot.append(li);
}
}
customElements.define('my-element1', element1);
File 2
import {my-element1} from ".element1.js"
class element2 extends HTMLElement {
constructor() {
super();
const ol = document.createElement('ol');
ol.appendChild(document.createElement('my-element1'));
this.shadowRoot.append(ol);
}
}
customElements.define('my-element2', element2);