Skip to content

Stop bundling the places and competitions data into the /map client scripts - #333

Merged
yakew7 merged 1 commit into
StudentSuite:mainfrom
propcgamer20-png:perf/map-client-bundle
Nov 2, 2026
Merged

yakew7 merged 1 commit into
StudentSuite:mainfrom
propcgamer20-png:perf/map-client-bundle

Conversation

@propcgamer20-png

Copy link
Copy Markdown
Member

What this changes

Fixes #293. /map no longer loads the script chunk that held the whole studymap.config (all places and all competitions). Client code stops importing the config; the server page reads it and passes cities, center and defaultZoom down as props, as the issue proposed.

  • src/lib/places-utils.ts (new): filterPlaces, getCities, cityBounds and Bounds, with no config import. getCities takes preferredOrder from its caller (default []).
  • src/lib/places.ts: keeps getPlaces() and a getCities wrapper that defaults to the config order, and re-exports the helpers, so every server importer and places.test.ts are unchanged.
  • src/app/map/page.tsx, src/app/embed/page.tsx: read cities, center, defaultZoom from the config and pass them as props.
  • PlacesMap, EmbedMap, MapView: take center/defaultZoom (MapView's are now required) instead of reading the config.
  • SuggestPlaceDialog, UserPlaceDialog: take datasetCities as a prop instead of computing getCities(getPlaces()) at module scope.
  • city-stats-card.tsx imports from places-utils.
  • Tests updated for the new props (no new behaviour, so no new tests).

Proof

Same machine, npm run build on main and on this branch, summing the distinct /_next/static/chunks/*.js files referenced by .next/server/app/map.html:

main this branch
Script chunks loaded by /map 18 17
Total script bytes 2,072,038 1,118,236
Largest chunk 953,743 (contains lhr-airport-01 and broadcom-masters) 243,268 (contains neither)
/map HTML 699,079 707,040

The HTML grows by 7,961 bytes because the page now serialises cities, center and defaultZoom as props. lhr-airport-01 appears once in the built /map HTML (the server props), as before; the issue's separate point about serving places from a JSON route is untouched.

grep -l lhr-airport-01 .next/static/chunks/*.js still lists one chunk on this branch. It is not referenced by map.html; as far as I could tell from the source it is the lazily loaded site-search dialog (site-search.tsx imports getPlaces and getCompetitions), which loads when someone opens search. I did not change that.

  • npm run typecheck, npm run lint, prettier --check src: clean. npm run test:unit: 647 passed.

Not verified

I did not load /map in a browser on this branch, so the acceptance items "all 1,950 pins render" and "filters, search, share and near-me work" are covered by the existing component tests only.

Type of change

  • Code or fix
  • New public place(s)
  • New or updated benefit guide
  • New or updated resource link
  • Docs

@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@propcgamer20-png is attempting to deploy a commit to the studentsuite Team on Vercel.

A member of the Team first needs to authorize it.

@yakew7
yakew7 merged commit 940270c into StudentSuite:main Nov 2, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/map ships the places dataset twice, in a 4.4 MB page and a 896 KB script

2 participants