Skip to content

[FEAT REQ] Keep dependencies external in build results #974

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

Closed
GerkinDev opened this issue Mar 8, 2023 · 6 comments · Fixed by #977
Closed

[FEAT REQ] Keep dependencies external in build results #974

GerkinDev opened this issue Mar 8, 2023 · 6 comments · Fixed by #977

Comments

@GerkinDev
Copy link
Contributor

GerkinDev commented Mar 8, 2023

Is your feature request related to a problem? Please describe.
Building an app that imports @floating-ui results in the transitive dependency being included twice. Moreover, stats in bundlephobia does not reflect the size of this module itself, but concatenated with all its deps.

Describe the solution you'd like
Mark dependencies as external in rollup config, so that the app bundling handles resolution itself

Describe alternatives you've considered
Use the source directly

@gabrieljablonski
Copy link
Member

This is definitely something we weren't considering. We'll see how to approach this since we've recently migrated to esbuild as the default bundler. Thanks for the suggestion.

@GerkinDev
Copy link
Contributor Author

Thank you :) a quick lookaround & inspection of the dist esm build reveals that dependencies weight about half the size of the minified file. I know it isn't much, since the minified is pretty light, but duplicate transitive dependencies add up quite quickly

Cheers ! 🍻

@gabrieljablonski
Copy link
Member

about half the size of the minified file

I know it isn't much

50% is actually quite a lot IMO, it would only start being less relevant if we were talking about <<<1KB.

I'm not super experienced with optimal practices when it comes to bundling, so I'm not sure how best to approach this. @danielbarion will probably have some more interesting perspectives.

If you also have any further suggestions regarding this, we'd be glad to hear.

@danielbarion
Copy link
Member

I'll do some tests as soon as I have free time, maybe if we add the float-ui as peer-dependencies can solve the issue, but I need to double-check and see how this will work for both situations:

  • Projects using floating-ui on their own
  • Projects not using floating-ui

Thanks for letting us know about this problem! Also, as @gabrieljablonski said, every 1kb is important for us.

@GerkinDev
Copy link
Contributor Author

Having contributed to multiple front-end libs myself, I took the habit to keep almost every deps of those libs as peer dependencies (except very small ones) and configure the bundler to preserve import/require statements, EXCEPT for builds that aims to be distributed via CDN.
When user build their app, via a bundler, it makes its best to link to the same module if version ranges matches.

I never used esbuild though, but if you're OK with it, I can do the tests, PR with config & a couple of stats. I love bundlers, and I would be pleased to give you a hand

@danielbarion
Copy link
Member

Yes sure!

Please feel free to submit a PR and we will take a look and test as soon as possible :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants