Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kevinCubas opened this issue Sep 11, 2023 · 1 comment · Fixed by #22
Closed

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

kevinCubas opened this issue Sep 11, 2023 · 1 comment · Fixed by #22
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kevinCubas
Copy link
Contributor

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 kevinCubas added enhancement New feature or request help wanted Extra attention is needed labels Sep 11, 2023
@kevinCubas
Copy link
Contributor Author

This PR #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant