Skip to content

Use of ChunkExtractor outside of Express server #1033

@tomtom94

Description

@tomtom94

💬 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions