webpack-hot-server-middleware icon indicating copy to clipboard operation
webpack-hot-server-middleware copied to clipboard

webpack-hot-server-middleware and react-loadable

Open amangeot opened this issue 7 years ago • 4 comments

Hello, I can't get react-loadable to work with this really cool package for code splitting.

Has anyone managed to do it and could suggest how to do it? Or share an example?

Thank you!

amangeot avatar Nov 16 '17 09:11 amangeot

I'm using react-loadable in the 60fram.es boilerplate, e.g. https://github.com/60frames/react-boilerplate/blob/master/src/components/index/IndexLoadable.js

NOTE: It uses an older version of react-loadable, a more recent version I used on another project required the use of their babel plugin or you need to manually faff around with import-inspector

The key is to disable code splitting when SSRing with:

new webpack.optimize.LimitChunkCountPlugin({
    maxChunks: 1
})

richardscarrott avatar Nov 23 '17 22:11 richardscarrott

I eventually have the time to look at the boilerplate, it sounds very promising, thank you @richardscarrott

Have you considered webpack v3, react-router v4 and react-loadable v5?

I'd like to use the last versions, did you encounter any issue with those for SSR with data fetching and code splitting?

amangeot avatar Dec 04 '17 14:12 amangeot

I've got code splitting working on a private project using Webpack v3 and react-loadable v5, no real problems with those.

I've avoided upgrading to React Router v4 on any projects because the departure from a centralised config means it's no longer possible to match components before rendering to determine data dependencies.

I've heard https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config is a potential solution but tbh it doesn't seem like it has first class support from the react-router team.

richardscarrott avatar Dec 27 '17 12:12 richardscarrott

Check out react-universal-component, redux-first-router, and redux-first-router-demo

hedgepigdaniel avatar Apr 25 '18 14:04 hedgepigdaniel