0

Have just started integrating recompose into a large webapp and wondering if there are ways to optimise bundle sizes (IE implement code splitting) using recompose (webpack in the background)?

My current use case with recompose is simple - a 'isAuthorised?' HOC which ensures a user is logged in. Most of my routes go thru this single HOC.

I want to be able to code split based on routes, but unsure how to do this with each route being enhanced with isAuthorised HOC.

Using react, redux, react-router, recompose, webpack 2

  • Recompose has nothing to do with code splitting. Webpack can do that for you with proper setup. – wuct Apr 13 '17 at 06:26

1 Answers1

0

Your route components are the ones that eventually end up referencing other modules that would create a distinct chunk. It's important that these be dynamically imported so that the router can load and defer requiring these until they're required/hit by the user.

Whether you use your HOC to decorate the routes when you declare them or import them in the actual module and decorate the route components before they're exported doesn't really matter.

Filip Dupanović
  • 32,650
  • 13
  • 84
  • 114