-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate Buffer dependency [WIP] #925
base: main
Are you sure you want to change the base?
Conversation
Thank you wmhilton! I auto-formatted the code using prettier-standard. 🤖 |
Hi @wmhilton,
this would also enable vercel's edge runtime to work:
|
@nadilas I'm afraid this will never be finished. OP is not working on the project anymore. |
thanks @jcubic, does that mean it is in general not recommended to use the library at all? |
@nadilas No, it means that the project is driven only by contributors, it's maintained but there is no single person that does all the hard work of adding new features and fixing bugs. If you want to help and remove Buffer dependency you are more than welcome to do this. |
@jcubic as it should be. I'll take a crack at it |
BREAKING CHANGE: methods will return
Uint8Array
s instead ofBuffer
s.Reasoning:
Buffer
is not isomorphic, and using it breaks Angular. (You can polyfill it manually but it doesn't work out-of-the-box.)Buffer
whenUint8Array
has been around forever and is part of the language.buffer
module (which gets automatically inserted by Webpack) shaving off a whopping 5.71 KB.I've confirmed that
sha.js
is the only module usingBuffer
(viasafe-buffer
). Since we recently enabled WebCrypto SHA1 as an optional optimization - and the "new" MS Edge based on Chromium actually supports SHA-1 digest (at least in the beta version currently installed) - and in Node we could always use the native SHA1... I definitely wonder if we could get away with dropping thesha.js
dependency. That would save an additional 1 KB, and when I compile that with Webpack, we now are at 64 KB instead of 71 KB gzipped, or a 10% reduction, which is pretty phenomenal. The only bigger improvement would be if we could drop packo.