-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Reimplement isEqual without pulling in massive lodash.isequal. #4924
Conversation
I was mistaken when I claimed, "Since the |
@capaj In the process of reimplementing const isEqual = require("lodash.isequal");
const a = { self: { self: { self: {}}}};
a.self.self.self.self = a;
const b = { self: {}};
b.self.self = b;
console.log(isEqual(a, b)); // true
console.log(isEqual(b, a)); // false It would be fine for |
Very nice find. Did you open a bug in Lodash repo? |
@capaj Planning to do that, though I think we'll stick with the smaller implementation. Thanks for sending me down this path! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great @benjamn!! 👍
Follow-up to #4915. I have kept the tests from that PR, just not the lodash-based implementation of isEqual. The lodash.isequal package has a ton of extra features we don't need, and weighs in at a whopping 10KB minified (3.8KB after gzip). Very little of that machinery is really necessary to fix #4824. I extracted this functionality into a separate npm package called @wry/equality, so that we have the flexibility to depend on the same logic in other packages without importing apollo-utilities.
427e35c
to
e083dfc
Compare
Follow-up to #4915. I have kept the tests from that PR, just not the
lodash
-based implementation ofisEqual
.The
lodash.isequal
package has a ton of extra features we don't need, and weighs in at a whopping 10KB minified (3.8KB after gzip). Very little of that machinery is really necessary to fix #4824.I extracted this functionality into a separate npm package called
@wry/equality
, so we have the flexibility to depend on the same logic in other packages without importingapollo-utilities
.Here's the new implementation.