#How can I disable lazy route loading in framework mode?

1 messages · Page 1 of 1 (latest)

shell quartz
#

Hey all,

I searched through the docs and discord, and I couldn't find an answer to this..

How can lazy loading of routes be disabled, so that all routes are included in the client-side bundle?

I'm creating a relatively simple App, where each route shares 99% of the same components.

The whole client-side bundle is relatively small, and I've configured rollup to output everything to a single bundle file.

But, I'm guessing because under the hood there's a call to React.lazy, each route generates a stub which just re-exports the component from the main bundle, like this:

import{i as f}from"./entry.client-g2mY7VCm.js";export{f as default};

This leads to a worse user experience due to an unnecessary network fetch.

Is there a supported way to configure routes.ts to use the components directly, rather than using code splitting?

Thanks!

unkempt parcel
#

There’s no option to do that

eager cairn
#

If you want to single-file-bundle the entire client app, I'd suggest using Data mode directly instead of Framework mode.

ornate ravine
#

you can disable fog of way / lazy route discovery by adding this to your react-router.config.ts
routeDiscovery: { mode: 'initial' },

#

instead of configuring rollup, i'd prefetch on Link render

eager cairn
#

That doesn't disable lazy route module loading, just lazy route module discovery. There's still going to be a network call to fetch the JS for the route module

ornate ravine
#

yea, but it prevents another network call after you've already prefetched js for the next route so the transition is instant