Comments (10)
i saw it specifically for bun, but im not entirely sure since it was apparent in the ElysiaJS integration :)
from scalar.
TIL barrel files are bad
https://dev.to/thepassle/barrel-files-a-case-study-o5p
from scalar.
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.
Are you saying there is a difference between NodeJS and bun in that regard?
from scalar.
Sounds like a problem with bun? Other bundlers definitely do not include type
-only imports...
from scalar.
Maybe related
https://twitter.com/gregberge_/status/1760341181396111843
from scalar.
@amritk is that still an issue? I think you fixed it, did you?
from scalar.
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.
@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.
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)
- Client Libraries Icons Not Appearing from CDN HOT 2
- Add schema based validation for request data HOT 2
- Nuxt missing deps HOT 6
- Api search redirection not working properly HOT 2
- Npm scalar install is conflicting with git scalar internal tool HOT 1
- The wildcard notation for mediaType don t support (e.g. */* or application/*) HOT 1
- Docusaurus: sidebar item method badge shows incorrect background color when item is selected
- Docusaurus: inconsistent handling of color mode settings
- Docusaurus: OpenAPI 3.1 webhooks do not render HOT 1
- Response body not showing when using api-reference v1.22.45 HOT 3
- Docusaurus: toast style missing background HOT 2
- treat single-value enums as constants
- Link to model from GET endpoints HOT 1
- ability to use two auth methods at the same time
- svelte integration
- Support for HTML abbr tags
- Add multiple api spec support out of the box
- Support for application/x-www-form-urlencoded in request body UI playground
- Strange behaviour with `description` paired with `additionalProperties`
- Authentication section does not handle oauth2 securitySchemes properly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scalar.