-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
docs: clarify that barrel file issue is for apps rather libs #17651
Conversation
|
Could you link to the issue you're referring? |
Oops. Sorry about that. I've updated the description with a link to the issue comment |
Thanks! I'm good with merging this. I'll let @bluwy do it to review the wording. As a note, the only thing that may be interesting is how this affects dependencies that aren't pre-bundled. We talked with Anthony in the past that some deps would be better of avoiding prebundling (if they are esm and doesn't have many deps). But I imagine these would mainly be prebundled already like Vite. |
I'm not really sure about this wording change. The docs page already implies that the suggestions only apply to a Vite app. The other sections don't quite make sense for library authors. Even with that aside, avoiding barrel files in libraries is somewhat beneficial too. Not all environments can bundle them, e.g. you're using a very big icon library that exports all SVG metadata objects in SSR. |
The reason I was sending a PR to this page is because I saw people talking about whether or not barrel files should be avoided in libraries. I think it's better to be explicit about apps vs libraries here since this could apply to both. It's a pretty complicated question because there's a tradeoff between developer experience and performance. I know in the vite-plugin-svelte docs we have much more info on this topic, so I just updated it to add a link there I've never seen it be a problem in SSR before. The dependency would probably be bundled and tree shaken in production where you might be most performance sensitive. |
In SSR, dependencies are usually externalized so the barrel files affect the runtime. So indeed the advice applies to both libraries and apps, but in the context of this page, it still focuses on the app side. I don't think we need to change this section. |
You will pay a small hit parsing more code, but I'm not sure it's too meaningful on the server. Also, during build dependencies are usually bundled, so it's largely restricted to dev where that level of performance difference matters even less. |
Description
Blu states in the issue that barrel file performance issue is for apps rather libs. Make that clearer in the docs.
#8237 (comment)