diff --git a/src/Reporters/moveAllToComponents.ts b/src/Reporters/moveAllToComponents.ts index 0e25caee..40537772 100644 --- a/src/Reporters/moveAllToComponents.ts +++ b/src/Reporters/moveAllToComponents.ts @@ -12,7 +12,6 @@ const findAllComponents = ( optimizableComponentGroup: OptimizableComponentGroup ): ReportElement[] => { const allComponents = optimizableComponentGroup.components -// console.log('allComponents: ', allComponents) const insideComponentsSection = allComponents.filter(isInComponents) const outsideComponentsSection = getOutsideComponents(allComponents, insideComponentsSection) @@ -21,34 +20,19 @@ const findAllComponents = ( let counter = 1 for (const [index, component] of outsideComponentsSection.entries()) { - for (const compareComponent of outsideComponentsSection.slice(index + 1)) { - if (isEqual(component.component, compareComponent.component, false)) { - const existingResult = resultElements.filter( - (reportElement) => component.path === reportElement.path - )[0] - if (!existingResult) { - const componentName = - component.component.name || - `${optimizableComponentGroup.type.slice(0, -1)}-${counter++}` - const target = `components.${optimizableComponentGroup.type}.${componentName}` - resultElements.push({ - path: component.path, - action: Action.Move, - target, - }) - resultElements.push({ - path: compareComponent.path, - action: Action.Reuse, - target, - }) - } else { - resultElements.push({ - path: component.path, - action: Action.Reuse, - target: existingResult.target, - }) - } - } + const existingResult = resultElements.filter( + (reportElement) => component.path === reportElement.path + )[0] + if (!existingResult) { + const componentName = + component.component.name || + `${optimizableComponentGroup.type.slice(0, -1)}-${counter++}` + const target = `components.${optimizableComponentGroup.type}.${componentName}` + resultElements.push({ + path: component.path, + action: Action.Move, + target, + }) } } debug(