Use of ChunkExtractor outside of Express server
Author: tomtom94Created Dec 3, 2025Updated Dec 3, 2025
Questions and Help
Hi there, I am now using new ChunkExtractor() outside of the main app.use() or app.get('*') on my server side.
It works fine you can checkout this link on my repo react-easy-ssr
I am doing like this
const app = express()
const extractor = new ChunkExtractor({
statsFile: path.join(paths.clientBuild, paths.publicPath, 'loadable-stats.json'),
entrypoints: ['bundle']
})
indexRoutes.forEach((indexRoute) => indexRoute.Component.preload()) // avoid side effect due to split code on server side
app.use(async (req: Request, res: Response) => { ... })My question is why in all the examples given by loadable-components you haven't been doing this ?
In all your examples, you consistently use this approach :
const server = express()
server
.disable('x-powered-by')
.use(express.static(process.env.RAZZLE_PUBLIC_DIR))
.get('/*', (req, res) => {
const extractor = new ChunkExtractor({
statsFile: path.resolve('build/loadable-stats.json'),
entrypoints: ['client'],
})
...Actually this approch doesn't work with my nodemon config in development mode.
Thanks a lot, bye.
Source: gregberge/loadable-components