Closed dawidvdh closed 7 years ago
wrap-root-epic should only be used server side. There is a client side version that you can import that is just an identity function (provided for symmetry).
I general have a separate entry for both server and client and everything that is specific to the environment must come in through those entry points. I teach a class where we build an isomorphic app using RO and this library.
The repo can be found here https://github.com/realworldreact/react-shoppe
This is the common entry point for both parts of the app: https://github.com/realworldreact/react-shoppe/blob/class/2017/may-intro-rx/common/create-store.js
This is the source for the server. You can see here is where we import wrapRootEpic: https://github.com/realworldreact/react-shoppe/blob/class/2017/may-intro-rx/server/boot/root.js#L27
The client side entry point is here: https://github.com/realworldreact/react-shoppe/blob/class/2017/may-intro-rx/client/index.js
Since this file does not import anything from REE, then it does not import the whole library and we avoid the issue of bundle size.
If you'd like to import the client side code you can use the client side entry point:
https://github.com/BerkeleyTrue/react-redux-epic/blob/master/client.js
But this is not necessary to get SSR working.
Ah... I see... thank you so much for this, makes so much sense :)
For documentation purposes:
I believe there was some bug that I was not able to fix any other way but through importing the whole library.
Hey,
I am busy optimizing a project utilizing this, however i see that this is importing the entire
rxjs
library in wrap-root-epic#L1 which is causing my vendor bundle to gain an additional 200kb in weight.Is there anyway to optimize this? Or am I possibly doing something incorrectly?