This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
2.1.0 breaks compose
if you're using lodash-webpack-plugin
#1831
Labels
docs
Focuses on documentation changes
has-reproduction
❤ Has a reproduction in a codesandbox or single minimal repository
I should preface this by saying that I don't think this is exactly Apollo's fault, nor am I sure it's Apollo's problem - but I wanted to document this issue and the results of my investigation into it.
Intended outcome:
I've got an app that uses react-apollo in conjunction with babel-plugin-lodash and lodash-webpack-plugin. It uses the
compose
function as documented in Apollo's official docs, passing in several functions as separate arguments to be composed. I expect this to result in the functions being composed together.Actual outcome:
react-apollo 2.1.0 uses lodash's
flowRight
function directly as its implementation ofcompose
.flowRight
has a behavior (implemented using lodash's private_flatRest
function) that will cause it to treat multiple arguments as if you passed an array into it. However, lodash-webpack-plugin replaces_flatRest
withidentity
.The result is a rather cryptic error for components that use
compose
:This happens because
flowRight
expects itsfuncs
argument to be an array, but because lodash-webpack-plugin replaced_flatRest
withidentity
, it's still being passed a bunch of functions as separate arguments.Again, this is not really Apollo's fault. But it might be worth documenting somewhere that using lodash-webpack-plugin can break things in subtle ways, since it seems like Apollo is increasing its reliance on lodash.
How to reproduce the issue:
https://github.com/nbudin/react-apollo-error-template/tree/2.1.0-compose-lodash-webpack-plugin
Version
The text was updated successfully, but these errors were encountered: