forjadev / mjo-forja-webpage

This project is the web page of the amazing forja community, it's built with React, Nextjs, Tailwind, Storybook and lots of love from the contributors.
7 stars 0 forks source link

Issue with Performance and Tree Shaking Due to Barrel Files #21

Closed kevinCubas closed 8 months ago

kevinCubas commented 1 year ago

Description:

The current state of our application is experiencing decreased performance and a tree shaking problem, primarily stemming from the use of barrel files. This not only impacts the speed and efficiency of our application but also results in errors with both server and client components.

Steps to Reproduce:

Ensure you are working in a project branch that contains multiple components, for example, branch with multiple components.

Import a single file from the "@/components" directory.

import { Navbar } from "@/components";

Run the following command:

npm run dev

Observed Behavior:

Importing using a barrel file (@/components), we notice a significant increase in the number of modules being imported. This, in turn, leads to extended compilation times even for a single import. image

Expected Behavior:

Without the use of a barrel file (@/components/navbar/Navbar) should result in a more efficient and performant outcome. image

NOTE: The specified examples were reproduced using the first compilation without caching.

kevinCubas commented 1 year ago

This PR https://github.com/forjadev/mjo-forja-webpage/pull/22 may fix the problem, but also keep the barrel file convention.

Another approach would be to just delete the barrel file and import the components using the full path