Webpack includes elliptic
and bn.js
(and other, smaller modules) in your package if you import crypto
as a dependency somewhere in your code.
To avoid these huge dependencies, you can find the specific npm module that provides only the (ality) function that you need.
For example, I imported crypto
to execute;
const crypto = require('crypto'); const hmac = crypto.createHmac('sha1', buf);
... instead (in this situation ...) you can install create-hmac
module and do;
const createHmac = require('create-hmac'); const hmac = createHmac('sha1', buf);
If you need motivation; removing crypto
as dependencies, trimmed to 150 KB from our gzipped bundle size (but YMMV depending on which crypto methods you use).
source share