Skip to content

Commit

Permalink
replace lodash depency in slate (ianstormtaylor#4245)
Browse files Browse the repository at this point in the history
* replace lodash/omit with custom fn

* replace lodash/isEqual with fast-deep-equal
  • Loading branch information
JonasKruckenberg authored May 12, 2021
1 parent 41af058 commit b33a531
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-bears-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate': patch
---

Removed lodash dependecy to reduce bundled footprint
5 changes: 4 additions & 1 deletion packages/slate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
"dependencies": {
"@types/esrever": "^0.2.0",
"esrever": "^0.2.0",
"fast-deep-equal": "^3.1.3",
"immer": "^8.0.1",
"is-plain-object": "^3.0.0",
"lodash": "^4.17.4",
"tiny-warning": "^1.0.3"
},
"devDependencies": {
"lodash": "^4.17.21"
},
"keywords": [
"canvas",
"contenteditable",
Expand Down
13 changes: 9 additions & 4 deletions packages/slate/src/interfaces/text.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import isPlainObject from 'is-plain-object'
import isEqual from 'lodash/isEqual'
import omit from 'lodash/omit'
import isEqual from 'fast-deep-equal'
import { Range } from '..'
import { ExtendedType } from './custom-types'

Expand Down Expand Up @@ -37,9 +36,15 @@ export const Text: TextInterface = {
): boolean {
const { loose = false } = options

function omitText(obj: Record<any, any>) {
const { text, ...rest } = obj

return rest
}

return isEqual(
loose ? omit(text, 'text') : text,
loose ? omit(another, 'text') : another
loose ? omitText(text) : text,
loose ? omitText(another) : another
)
},

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5656,7 +5656,7 @@ faker@^4.1.0:
resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f"
integrity sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8=

fast-deep-equal@^3.1.1:
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
Expand Down

0 comments on commit b33a531

Please sign in to comment.