So, react-lazy & suspense does not work in gatsby as React.lazy and Suspense is not yet available for server-side rendering. But, we can use Loadable Components(https://loadable-components.com/docs/getting-started/) for that instead. So, I have used loadable components in gatsby & have also used & configured gatsby-plugin-loadable-components-ssr in gatsby-config.js file. But, I am getting "WebpackError: Invariant Violation: loadable: SSR requires @loadable/babel-plu gin
, please install it." while deploying it on netlify. So, I am not able to split the js code. If anyone has tried it before or have similar things happened in past & have fixed it, then kindly help me out.
Asked
Active
Viewed 2,914 times
3

user8084720
- 193
- 1
- 4
- 15
-
Have you tried to add the plugin to webpack, refer to this doc: https://www.gatsbyjs.org/docs/add-custom-webpack-config/ – Ghassan Maslamani Jun 04 '20 at 12:15
-
Try `npm install -D @loadable/babel-plugin` and then in your babel config add `@loadable/babel-plugin` to the plugins array. – Adam Bohannon Oct 09 '20 at 02:43