use-async-resource
use-async-resource copied to clipboard
replace object-hash with JSON.stringify
There is no obvious reason for using object-hash here and it adds 32kb to the bundle size.
https://bundlephobia.com/[email protected]
Agreed, object-hash is large enough, but JSON.stringify doesn't preserve object equivalence: for identical objects with different order of their keys, it results in different values.
Another thing to keep note of: very large objects will result in very large keys, whereas a hash function will have the same length regardless of the object sizes.
There are alternatives, smaller and (maybe) faster. Too many actually. But I have not done much research:
- https://www.npmjs.com/package/fast-json-stable-stringify
- https://www.npmjs.com/package/json-stable-stringify
- https://www.npmjs.com/package/fast-stable-stringify
- https://www.npmjs.com/package/faster-stable-stringify
But again, they are stringifiers, not hashers.
also scope hoist in parcel (not sure about webpack) doesn't work because of object-hash
I will look into alternatives. Thank you for bringing it up. 🙏🏻
Any chance of this getting addressed? It is currently being flagged as the biggest dead weight in our app.