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):
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:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got it, you have to create a new
ChunkExtractor
for every request. Then it will collect only chunks for current rendering.Good to know!