diff --git a/build.dev.js b/build.dev.js index 5a5e65a..608db03 100644 --- a/build.dev.js +++ b/build.dev.js @@ -107,6 +107,10 @@ function mkWCFile({ style, html, js }) { .replace('watch() {', 'attributeChangedCallback(name, old, val) {\nif (old === val) {return}') .replace('adopted()', 'adoptedCallback()') + js += `if(!customElements.get('wc-${parseName(name)}')){ + customElements.define('wc-${parseName(name)}', ${name}) + }` + return transform(js, ESBUILD_OPTIONS).then(res => { return `/** * @@ -117,10 +121,6 @@ function mkWCFile({ style, html, js }) { */ ${res.code} - -if(!customElements.get('wc-${parseName(name)}')){ - customElements.define('wc-${parseName(name)}', ${name}) -} ` }) } diff --git a/build.prod.js b/build.prod.js index 2471c62..6aeb47b 100644 --- a/build.prod.js +++ b/build.prod.js @@ -114,6 +114,10 @@ function mkWCFile({ style, html, js }) { .replace('watch() {', 'attributeChangedCallback(name, old, val) {\nif (old === val) {return}') .replace('adopted()', 'adoptedCallback()') + js += `if(!customElements.get('wc-${parseName(name)}')){ + customElements.define('wc-${parseName(name)}', ${name}) + }` + return transform(js, ESBUILD_OPTIONS).then(res => { return `/** * @@ -124,10 +128,6 @@ function mkWCFile({ style, html, js }) { */ ${res.code} - -if(!customElements.get('wc-${parseName(name)}')){ - customElements.define('wc-${parseName(name)}', ${name}) -} ` }) }