bottleneck
bottleneck copied to clipboard
Don't package unnecessary files in npm pack
SUMMARY
I noticed that the bundle size for bottleneck
is larger than I'd expect, since (by default) it is packing everything. I took a stab at limiting this only to files that are necessary.
DETAILS
- Pack
lib/*
, along with*.(js|ejs|ts)
. You might be able to restrict this even further, but at least this keeps thesrc
andtest
folders out of the distributed package, which is the main goal.
I tried your build in my recent CRA project but saw no difference in bundle size vs. 2.19.5 current according to source-map-explorer, bottleneck is still 48k for me:
I also don't understand why there appears to be 15k in redis support libraries when I am not using redis. Am I missing something?
Ah, thanks for testing it out!
The change I'm suggesting will only lower the cost of the npm published package (for example, a server app that uses bottleneck as a dependency). It won't affect the size of the pre-bundled .js files that would be used in a browser app.
(As far as the redis files go, there are several .js files generated - like light.js - one of those alternate bundles might be available that would not contain the redis utils.)
Ahh, I was wondering if I was seeing all that because I am using bottleneck in a client app. I just need something to prevent client from queuing more than 4 API calls per second to an API, maybe there is something else I should try? I will check out the light.js option, though.
Up