How to make a class-based custom element side-effect-free so webpack only bundles the explicitly imported components
问题 I have a set of spec v1 custom elements which I'm using webpack 4 to bundle (and babel-loader to transpile). The components all look similar to this: export class CompDiv extends HTMLDivElement { constructor(...args) { const self = super(...args); self.property = null; return self; } connectedCallback() { console.log('connected CompDiv'); } } customElements.define('comp-div', CompDiv, { extends: 'div' }); Now to be able to create custom packages from these components using selective, named