Open Loykos opened 6 years ago
We've already externalised clipper-lib
, leaflet
and ramda
Majority of the bundle is taken up by jsts
(~430kb) which is a dependency of turf-intersect
which we use for determining polygon intersections.
I don't think externalising turf-intersect
makes much sense, as it's a fairly niche dependency. Requiring it to be an external dependency only defers the issue since the eventual bundle size remains the same.
When gzipped bundle size is ~127kb which of course you should be applying server-side. I actually think that's a fairly healthy size for the complexity of FreeDraw.
It may also be worth considering dynamically import
ing FreeDraw, and displaying a loading message of some kind whilst the chunk is loaded:
async loadMap(textNode) {
textNode.innerHTML = 'We are loading the map...';
await import('./map-with-freedraw.js');
// voila...
}
That way FreeDraw stays out of the your main bundle, and is only requested when actually needed.
Thanks @Wildhoney for answering me. I currently have gzip compression. I'll load the module async with dynamic import and I'll keep following the project.
Thank you!
Hi,
I like very much this library! I'm building the library with webpack and the result file weight ~600 kb. Is there a way to reduce the bundle size?
Thanks for your suggestions