I am looking into splitting dash_extensions into chunks as the bundle size has grown too large. I tried to follow the approach of dash-core-components, but i keep getting chunk load errors,
Not that I’m aware of. Would be fantastic to create one though, so any notes you could provide from your experience - once it’s working - would be very helpful!
Based on the null in the url there, I’m wondering if the webpackChunkName comment is missing? These comments are used by webpack to name the chunk files, like:
@alexcjohnson yes, I was indeed missing the “webpackChunkName”. I wasn’t aware that it was used for naming. Reading through your link @AnnMarieW I realised that I also needed to manually add entries to the _js_dist list in “init.py”. Implementing these changes and updating a few libraries, the async loading is now working. Thank you so much for your help
Moving the Lottie, Burger and Mermaid components to separate chunks, the main bundle size has decrease from 1.3 MB to about 40 kB (!). And after getting a hold what is going on, it’s actually not that complicated. It is in fact quite elegant
Based on this recently merged pull request from @xhlu, you will now have the option to create a new custom component with the dash-component-boilerplate that uses async loading. All the hard work will already be done!
Now, when you create a new project with the cookiecutter one of the questions is:
Not to pre-jump the docs - but should I use-async for everything? I’m writing a wrapper for a rich text editor, (so low-code, but larger dependancy packages) and was wondering if this would be something worth doing for that?
It’s just a single component file - so perhaps it makes no difference to me?
Thanks a bunch and apologies if its a basic question!
Amien
Chunking requires knowledge of Promises and/or JS async, as well as understand the differences in webpack configuration between chunking and non-chunking. Once you successfully built your first async components, the subsequent ones should be easier.
That said, I recommend it for multi-page apps, where a component is only used in a single app. Also recommend if your component bundle is large (if it’s written in pure React and the bundle size is very small, you could choose to skip async).