Giter VIP home page Giter VIP logo

Comments (10)

marclave avatar marclave commented on May 27, 2024 1

i saw it specifically for bun, but im not entirely sure since it was apparent in the ElysiaJS integration :)

from scalar.

hanspagel avatar hanspagel commented on May 27, 2024 1

TIL barrel files are bad
https://dev.to/thepassle/barrel-files-a-case-study-o5p

from scalar.

amritk avatar amritk commented on May 27, 2024 1

haha no no I don't think barrels are going anywhere. Just that import type thing so the whole module doesn't get imported when you just want types doesn't hurt ๐Ÿ˜„

from scalar.

hanspagel avatar hanspagel commented on May 27, 2024

Are you saying there is a difference between NodeJS and bun in that regard?

from scalar.

jaens avatar jaens commented on May 27, 2024

Sounds like a problem with bun? Other bundlers definitely do not include type-only imports...

from scalar.

hanspagel avatar hanspagel commented on May 27, 2024

Maybe related
https://twitter.com/gregberge_/status/1760341181396111843

from scalar.

hanspagel avatar hanspagel commented on May 27, 2024

@amritk is that still an issue? I think you fixed it, did you?

from scalar.

amritk avatar amritk commented on May 27, 2024

What I thought barrels are recommended? What are you doing to me hanssssss. Good article though something we can definitely improve on ๐Ÿ‘๐Ÿพ. I always thought the bundler would treeshake out everything you don't use. Something to think about for sure.

Yea I think this is on the import side not on the references side, though we could reduce our package use at some point.

Also I did not know about that you HAVE to import type {} I will add that eslint rule ๐Ÿ––๐Ÿพ

We should setup some tests to see whats going on

from scalar.

jaens avatar jaens commented on May 27, 2024

@amritk It's useful to actually read the article ๐Ÿ™ƒ

For our local development environment, and also for running our unit tests, we don't bundle; we use buildless development, and we get a lot of benefits from this approach.


always thought the bundler would treeshake out everything you don't use.

Yes. That is what happens. In production.

In development, eg. Vite does something slightly different: It does not treeshake, but it pre-bundles external dependencies into one file.
This still causes absolutely all JS code to be loaded when using barrel files, but since it's one file and browsers can just parse (but not necessarily execute) hundreds of megabytes of JS per second (on dev machines), it's not a huge issue.

The author seems to be using the most barebone development environment possible, which yeah, does not work well with hundred-module barrel graphs.

Though as a solution, I would rather suggest the author should start using tools actually meant for large production-grade software. The barrel file ship has already sailed.

from scalar.

hanspagel avatar hanspagel commented on May 27, 2024

Yeah, thatโ€™s what I thought, too. Tree-shaking is hard though and Iโ€™ve had too many cases where tree shaking didnโ€™t work as expected, so definitely something worth to keep an eye on.

That said, before replacing any barrel files we should have a proof that weโ€™re actually improving something. ๐Ÿ˜…

from scalar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.