Skip to main content

Code Splitting

ReSolve uses webpack to transpile and bundle the application code so it can run on client browsers, the server and serverless platforms.

ReSolve takes advantage of webpack's code splitting functionality to split the bundles into chunks. A chunk can be server-only (for business logic), browser-only (for UI and client logic) or isomorphic (for view models on the server side and Redux reducers on the client).

When you build a reSolve application, the following chunks are generated:

  • Command processor code - aggregate command handlers and projections (server only)
  • View model projection (isomorphic)
  • Read model projections and resolvers (server only)
  • API handlers (server only)
  • SSR renderer (server only, with peer dependencies with client, such as styled-components)
  • The client application with UI (browser only)

All these chunks are used by the target application. Some chunks can include other chunks. For instance, the client includes the view model projection chunk to automatically generate Redux reducers.

In a cloud/serverless environment, chunks like read model projections & resolvers, SSR renderer, API handlers and REST business logic are distributed to appropriate cloud executors.

When an application runs locally, the @resolve-js/scripts utility loads all necessary chunks and combines them with the runtime code.