Skip to content

Commit

Permalink
Reimplement isEqual without pulling in massive lodash.isequal.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
benjamn committed Jun 6, 2019
1 parent b25e93a commit 2578216
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
15 changes: 9 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 6 additions & 16 deletions packages/apollo-utilities/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions packages/apollo-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"dependencies": {
"@wry/equality": "^0.1.0",
"fast-json-stable-stringify": "^2.0.0",
"lodash.isequal": "^4.5.0",
"ts-invariant": "^0.4.0",
"tslib": "^1.9.3"
},
"devDependencies": {
"@types/lodash.isequal": "^4.5.5"
}
}
9 changes: 1 addition & 8 deletions packages/apollo-utilities/src/util/isEqual.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
import isEqualLodash from 'lodash.isequal';

/**
* Performs a deep equality check on two JavaScript values.
*/
export function isEqual(a: any, b: any): boolean {
return isEqualLodash(a, b);
}
export { equal as isEqual } from '@wry/equality';

0 comments on commit 2578216

Please sign in to comment.