bottleneck icon indicating copy to clipboard operation
bottleneck copied to clipboard

Don't package unnecessary files in npm pack

Open elliot-nelson opened this issue 4 years ago • 4 comments

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 the src and test folders out of the distributed package, which is the main goal.

elliot-nelson avatar May 18 '20 13:05 elliot-nelson

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: bottleneck bundle size 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?

jtnix avatar May 23 '20 02:05 jtnix

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.)

elliot-nelson avatar May 23 '20 03:05 elliot-nelson

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.

jtnix avatar May 25 '20 22:05 jtnix

Up

devvaneio avatar Jan 28 '21 20:01 devvaneio