Skip to content
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

replace object-hash with JSON.stringify #49

Open
gajus opened this issue Mar 25, 2021 · 4 comments
Open

replace object-hash with JSON.stringify #49

gajus opened this issue Mar 25, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@gajus
Copy link

gajus commented Mar 25, 2021

There is no obvious reason for using object-hash here and it adds 32kb to the bundle size.

https://bundlephobia.com/result?p=use-async-resource@2.2.1

@andreiduca
Copy link
Owner

andreiduca commented Mar 25, 2021

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:

But again, they are stringifiers, not hashers.

@miguelski
Copy link

also scope hoist in parcel (not sure about webpack) doesn't work because of object-hash

@andreiduca
Copy link
Owner

I will look into alternatives. Thank you for bringing it up. 🙏🏻

@andreiduca andreiduca added the enhancement New feature or request label May 26, 2021
@gajus
Copy link
Author

gajus commented Jul 23, 2022

Any chance of this getting addressed? It is currently being flagged as the biggest dead weight in our app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants