openstreetmap-polska / openaedmap-frontend

Map which shows locations of defibrillators (AEDs) and allows adding new ones.
https://OpenAEDMap.org
MIT License
29 stars 18 forks source link

Consider chunking/code splitting/dynamic imports #200

Closed starsep closed 7 months ago

starsep commented 7 months ago

Output of npm run build:

vite v5.0.12 building for production...
✓ 588 modules transformed.
build/index.html                     3.49 kB │ gzip:   1.01 kB
build/assets/index-TabOiWkR.css    315.41 kB │ gzip:  41.93 kB
build/assets/index-knhwMFVN.js   1,608.61 kB │ gzip: 417.17 kB

(!) Some chunks are larger than 500 kB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.

Based on bunx vite-bundle-visualizer opening_hours is likely the largest library which is not needed at app start.

starsep commented 7 months ago

The largest library in general is maplibre. Tree shaking doesn't work correctly for it at the moment: https://github.com/maplibre/maplibre-gl-js/issues/977 Due to that browsers report high usage of unused code.

starsep commented 7 months ago

I tried lazy loading opening-hours but: