Getting `@apollo/client` to work after upgrade?
jnatten opened this issue · comments
❓Question
After upgrading @apollo/client
(from 3.4.0 to 3.6.0) our application crashes when attempting to construct one of the objects from the package.
It produces this error:
TypeError: L.InMemoryCache is not a constructor
at /app/build/server.js:164594:23
at Q (/app/build/server.js:164599:13)
at yg (/app/build/server.js:196934:13)
at kg (/app/build/server.js:197019:19)
at Nh (/app/build/server.js:198722:46)
at /app/build/server.js:198903:11
at o.handle_request (/app/build/server.js:33044:11)
at o (/app/build/server.js:32888:48)
at a (/app/build/server.js:62153:26)
at /app/build/server.js:75457:49
Razzle config here (with the most intersting part on line 57, i think).
If i remove the appConfig.externals = []
from our config the build starts working as expected again, however then i need to include node_modules
separately from our build
output directory. This increases our total build size quite drastically. It also complicates our build pipeline somewhat so i would really like to avoid it if at all possible.
All help appreciated!
Not sure if razzle should handle this or not, but it looks like node doesn't support the commonjs that @apollo/client
now defaults to. We fixed this by updating resolve.mainFields in our webpack config to prioritize module
.
if (target == 'node' && !dev) {
appConfig.resolve.mainFields = ['module', 'main'];
}