Or you create a library which contains a collection of 10-20 line of code modules and share it among your projects.
Yes I agree it's better to have one library with 20 helper functions than 20 libraries with 1 function each. Think Lodash.
Although some people will then complain about the size of the library...
Re:The Deno Company
by speedgoose on Tuesday March 30, 2021 @12:37AM
(#26631302)
Yes. Every Lodash function is available in its own npm package too. I use it like this, I rather have 4 lodash packages than the big whole lodash library in one package with almost everything left unused.
Re:The Deno Company
by Master_Odin on Tuesday March 30, 2021 @09:31AM
(#26634394)
These will go away in v5 (if a v5 is ever released) and is not recommended if using a bundler as it'll end up wasting space rather than saving as it'll include duplicate code that each individual function could share.
Re:The Deno Company
by speedgoose on Wednesday March 31, 2021 @01:43AM
(#26643900)
Thanks for the information. I think it will be about time to completely remove lodash from my code bases.
Re:The Deno Company
by runawaybottle on Tuesday March 30, 2021 @02:38AM
(#26631753)
JS libraries only did that to reduce bundle size being sent to the browser. It’s done out of necessity, not because it makes any sense.
Exporting out one method at a time is pretty absurd.
Re:The Deno Company
by speedgoose on Tuesday March 30, 2021 @02:58AM
(#26631851)
Lodash has a lot of features that are not needed anymore or even dangerous sometimes. If you don't need them, why would you install them?
Re:The Deno Company
by runawaybottle on Tuesday March 30, 2021 @03:18AM
(#26631968)
Because it’s simply not a big deal on the server.
Having reusable code wrapped into packages is basic software engineering.