This example demonstrates how to use Code Splitting with React 18.
app1
This app consumes theContent
component fromapp2
and uses React.lazy to load it.app2
This app exposes theContent
component and split it into a separate chunk usingReact.lazy
.
The app2
is used to expose a component called Content
and a route called userRoute
.
Run yarn
to install the dependencies.
Run pnpm run start
this will build and start all applications.
Bellow you can see the port mapping:
- localhost:3000 (app1)
- localhost:3001 (app2)