Skip to content
Projects

Work at Siteimprove · MarketMuse

Breaking up a legacy React monolith

One large app, broken into small container-level features in Nx, layered so dependencies point one way.

Context
The product's frontend was one large Create React App application.
Role
Lead Frontend Developer. I moved it and kept it current through major Nx upgrades.

Decisions

  1. Chose a Next.js proof of concept over committing to the move up front, because it settled the question before we paid for it: we decided not to use Next.js.
  2. Chose one domain per sub-app, each with its own feature, state, data and UI packages over domain-agnostic components, following enterprise guidelines for multi-domain apps over letting any library import any other, because dependencies only ever point one way.
  3. Chose deploying based on what a change depends on, and caching packages between deploys over rebuilding everything on every deploy, because only the packages that changed had to be rebuilt.
  • Made shared base packages isomorphic, working under both SSR and React Server Components.
  • Code-split heavy features and the rich-text editor, lazy-loaded third-party scripts, and memoized expensive tables and heatmaps.
  • Upgraded to React 18, and moved Jest to SWC for a faster test suite.
One app, scoped by domainBefore: one large Create React App application. After: still one app, in an Nx monorepo. Each domain is a sub-app with its own packages: in one, two features depend on a state package and two data packages, beside the domain's own UI; another domain has a single feature and its UI. Below every domain sit domain-agnostic components. Deploys rebuild only the packages a change touched; the rest come from a cache.BeforeCreate React Appone large applicationmany small, container-levelfeatures broken outAfter: still one app, in an Nx monorepoThe appDomain (sub-app)FeatureFeatureStateDataDataUIDomainFeatureUIDomain-agnostic componentsshared by every domaindependencies point downDeploys rebuild only changed packages;the rest come from cache
One app, scoped by domain
  • React
  • TypeScript
  • Nx
  • SSR
  • React Server Components
  • Jest