question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ChunkExtractor loads more chunks than necessary

See original GitHub issue

💬 Questions and Help

Hi, I am experiencing an issue with code-splitting and server-side rendering where ChunkExtractor loads a lot of extra chunks upon page load rather than just the chunk the view requires.

(Almost all of these chunks are for other unrelated views): Curated_Online_Asian_Art_Gallery

This issue occurs on both development and production and the behaviour is similar whether we use ChunkExtractorManager or collectChunks. This is how we do it at the moment:

import { ChunkExtractor } from '@loadable/server'

...

const statsFile = './home/deploy/razzle/build/loadable-stats.json' 
const extractor = new ChunkExtractor({ statsFile, entrypoints: ['client'] })

...

const server = express()
server.
    ...
    .get('/*', async (req, res) => {
        ...
        const app = (
            <CookiesProvider cookies={req.universalCookies}>
                <ApolloProvider client={client}>
                     <StaticRouter context={context} location={req.url}>
                         <App />
                     </StaticRouter>
                </ApolloProvider>
             </CookiesProvider>
         )

        getDataFromTree(app)
            .then(() => {

                ...
                html = renderToString(extractor.collectChunks(app))
                ...

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
gregbergecommented, Mar 13, 2019

I got it, you have to create a new ChunkExtractor for every request. Then it will collect only chunks for current rendering.

0reactions
gregbergecommented, Mar 22, 2019

Good to know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ChunkExtractor loads more chunks than necessary · Issue #265
Hi, I am experiencing an issue with code-splitting and server-side rendering where ChunkExtractor loads a lot of extra chunks upon page load ......
Read more >
Loadable Components SSR - chunkNames in Server Stats file ...
When I run the build command, the chunks are named based on id, as I believe react-scripts is hard-wired to run in production...
Read more >
Chunk loading set to max, but far away chunks still won't load ...
In multiplayer the server chooses the max distance (but clients can still set it lower than that, just not higher). Alternately it could...
Read more >
How to improve performance in your apps with Lighthouse ...
It provides a Babel Plugin (which delegates chunks under the hood during build) and a Chunk Extractor — to collect chunks server side...
Read more >
4 Reasons To Employ A Key Chunk Extractor API ...
Key Chunk Extractor API is an endorsed component with the capability and benefits of chunking without the need to split gathered data into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found