Reduce @wordpress/data package size with implementing native JS functions instead of Lodash #27982
Labels
[Package] Data
/packages/data
[Status] Duplicate
Used to indicate that a current issue matches an existing one and can be closed
[Type] Performance
Related to performance efforts
I love the
@wordpress/data
package so much because it really solved major problems at my application and I think it should gain more popularity among the React community. But hey, once I import it, my app size increases drastically.@wordpress/data
package alone is 33kb at the moment.Here is the list of its dependencies:
1-
lodash
73Kb2-
@wordpress/compose
34kb3-
@wordpress/redux-routine
10kb4-
@wordpress/hooks
6kb5-
@wordpress/deprecated
2kb6-
@wordpress/is-shallow-equal
2kb7-
@wordpress/priority-queue
2kb8-
@wordpress/escape-html
2kbAround 164kb to just use
@wordpress/data
.. I hope this would be reduced.I think that
lodash
is a major part here. I hope to replace the the functions used from lodash with native js implementation.Here is the list of lodash functions used in
@wordpress/data
,@wordpress/compose
and@wordpress/redux-routine
:{ forEach, without, debounce, includes, castArray, throttle, camelCase, upperCase, omit, get, mapValues, isObject, has ,flowRight, isPlainObject, map, isString, merge }
One short term solution is to change the syntax for lodash import in those packages from:
to
so if any one uses the package outside WordPress, he may need to have
lodash-webpack-plugin
but the long term solution is to implement vanilla JS functions instead of lodash functions in those packages:@wordpress/data
,@wordpress/compose
and@wordpress/redux-routine
The text was updated successfully, but these errors were encountered: