pwaLUPMIS2/dist/assets/vite-helpers-BlTxHScW.js
ekke 8674ca4df2 Build: stop the lazy geotiff and shapefile chunks loading at startup
vite.config.js splits geotiff and shpjs out so they load only when a user opens
a Cloud-Optimized GeoTIFF or imports a shapefile, but the built index.html
preloaded both on every visit — about 428 kB (152 kB gzipped) nobody had asked
for.

Two separate causes, both visible in the entry chunk's first line:
- it imported Vite's preload helper, used by every dynamic import(), from the
  geotiff chunk. The helper is a virtual module with no node_modules path, so
  Rollup had parked it there; needing it at startup dragged the whole chunk in.
  It now has a chunk of its own, about 1 kB.
- it imported JSZip from the shpjs chunk. JSZip reached the bundle through
  shp-write, which gis-export.js imports for Shapefile export, so it is needed
  at startup whatever happens; filing it under shpjs pulled that chunk in too.
  It is now its own chunk, costing the 31 kB it actually is.

dist/ rebuilt: index.html now preloads vite-helpers and jszip instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-23 13:40:13 +02:00

3 lines
1.1 KiB
JavaScript

const p="modulepreload",v=function(l){return"/"+l},d={},y=function(f,c,E){let i=Promise.resolve();if(c&&c.length>0){let r=function(e){return Promise.all(e.map(o=>Promise.resolve(o).then(s=>({status:"fulfilled",value:s}),s=>({status:"rejected",reason:s}))))};document.getElementsByTagName("link");const t=document.querySelector("meta[property=csp-nonce]"),u=t?.nonce||t?.getAttribute("nonce");i=r(c.map(e=>{if(e=v(e),e in d)return;d[e]=!0;const o=e.endsWith(".css"),s=o?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${s}`))return;const n=document.createElement("link");if(n.rel=o?"stylesheet":p,o||(n.as="script"),n.crossOrigin="",n.href=e,u&&n.setAttribute("nonce",u),document.head.appendChild(n),o)return new Promise((m,h)=>{n.addEventListener("load",m),n.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${e}`)))})}))}function a(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return i.then(r=>{for(const t of r||[])t.status==="rejected"&&a(t.reason);return f().catch(a)})};export{y as _};
//# sourceMappingURL=vite-helpers-BlTxHScW.js.map