Closed chetank628 closed 4 years ago
We use React.lazy
with dynamic imports to do code splitting. The following babel plugins need to be added
"@babel/plugin-syntax-dynamic-import",
"dynamic-import-webpack",
We use
React.lazy
with dynamic imports to do code splitting. The following babel plugins need to be added"@babel/plugin-syntax-dynamic-import", "dynamic-import-webpack",
I have already tried that but ssr is not working ,only client side loading happens that too when hmr picksup, can you give me any working code snippet that would be helpful
Hi @chetank628 , https://reactjs.org/docs/code-splitting.html#reactlazy
react lazy
and Suspense
is not yet available for server-side rendering. Please use @loadable/component
.
by installing
fyn a @babel/plugin-syntax-dynamic-import @loadable/component react-notify-toast
add plugin to your src/client/.babelrc.js
:
module.exports = {
extends: "electrode-archetype-react-app-dev/config/babel/babelrc-client.js",
plugins: [
"@babel/plugin-syntax-dynamic-import"
]
};
Then you can use @loadable/component
to do dynamic import. Please refer this as an example
@1846689910 Thank you! This was very helpful. Does loadable SSR work with electrode? When I run the demo via ignite, SSR shows <strong>Dynamic Imported Component is loading ...</strong>
. It is working great for me on CSR.
Thanks!
Hi @brandonburkett Thank you. It is actually working now in only CSR, since only client-side changed. I will look into it
@1846689910 hi, it seems the loadable feature has been shipped in https://github.com/electrode-io/electrode/pull/1240/files
But there seems to be no documentation available regarding the usage.
Would want to give this feature a try!
I have gone through the issue there was one pr for code-splitting long back which was reverted back have anybody managed to get work code-splitting after that with this because without code-splitting building a large scale enterprise application is a pain for the user experience, if Walmart uses this in production then how you manage code splitting