fix(react, vue): remove sideeffects to improve treeshaking (#24313)

This commit is contained in:
Liam DeBeasi
2021-12-06 11:39:23 -05:00
committed by GitHub
parent 0920797612
commit 13d4418588
10 changed files with 455 additions and 355 deletions

View File

@ -32,13 +32,30 @@ export const proxyOutputs = (instance: any, el: any, events: string[]) => {
events.forEach(eventName => instance[eventName] = fromEvent(el, eventName));
}
export function ProxyCmp(opts: { inputs?: any; methods?: any }) {
const decorator = function(cls: any) {
if (opts.inputs) {
proxyInputs(cls, opts.inputs);
export const defineCustomElement = (tagName: string, customElement: any) => {
if (
customElement !== undefined &&
typeof customElements !== 'undefined' &&
!customElements.get(tagName)
) {
customElements.define(tagName, customElement);
}
}
// tslint:disable-next-line: only-arrow-functions
export function ProxyCmp(opts: { defineCustomElementFn?: () => void, inputs?: any; methods?: any }) {
const decorator = function (cls: any) {
const { defineCustomElementFn, inputs, methods } = opts;
if (defineCustomElementFn !== undefined) {
defineCustomElementFn();
}
if (opts.methods) {
proxyMethods(cls, opts.methods);
if (inputs) {
proxyInputs(cls, inputs);
}
if (methods) {
proxyMethods(cls, methods);
}
return cls;
};