Skip to content

Commit ccab058

Browse files
committed
Remove lodash.
This boosts perf by not exhaustively checking every action of it's object-ness. We also no longer need to bundle any of lodash, so this saves a good number of bytes too!
1 parent b1016a4 commit ccab058

6 files changed

+43
-66
lines changed

.babelrc

-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
"plugins": [
2727
["transform-es2015-modules-commonjs", { "loose": true }]
2828
]
29-
},
30-
"es": {
31-
"plugins": [
32-
"./build/use-lodash-es"
33-
]
3429
}
3530
}
3631
}

build/use-lodash-es.js

-10
This file was deleted.

package-lock.json

+41-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
},
6161
"homepage": "http://redux.js.org",
6262
"dependencies": {
63-
"lodash": "^4.2.1",
64-
"lodash-es": "^4.2.1",
6563
"loose-envify": "^1.1.0",
6664
"symbol-observable": "^1.0.3"
6765
},

src/combineReducers.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ActionTypes } from './createStore'
2-
import isPlainObject from 'lodash/isPlainObject'
32
import warning from './utils/warning'
43

54
function getUndefinedStateErrorMessage(key, action) {
@@ -26,7 +25,7 @@ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, une
2625
)
2726
}
2827

29-
if (!isPlainObject(inputState)) {
28+
if (!inputState || inputState.constructor !== Object) {
3029
return (
3130
`The ${argumentName} has unexpected type of "` +
3231
({}).toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] +

src/createStore.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import isPlainObject from 'lodash/isPlainObject'
21
import $$observable from 'symbol-observable'
32

43
/**
@@ -147,7 +146,7 @@ export default function createStore(reducer, preloadedState, enhancer) {
147146
* return something else (for example, a Promise you can await).
148147
*/
149148
function dispatch(action) {
150-
if (!isPlainObject(action)) {
149+
if (!action || action.constructor !== Object) {
151150
throw new Error(
152151
'Actions must be plain objects. ' +
153152
'Use custom middleware for async actions.'

0 commit comments

Comments
 (0)