Skip to content

Improve loading times by splitting pages.tsx into smaller files and improving the locality map - #1224

Merged
juhanikat merged 4 commits into
mainfrom
fix-pages-file-importing
Aug 4, 2026
Merged

Improve loading times by splitting pages.tsx into smaller files and improving the locality map#1224
juhanikat merged 4 commits into
mainfrom
fix-pages-file-importing

Conversation

@juhanikat

@juhanikat juhanikat commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Split pages.tsx into separate page files for each entity, which are loaded lazily to avoid loading the entire app whenever any table view etc. is visited. Also renamed the /crosssearch routes to /occurrence.

This PR also reduces the transferred size of countryPolygons.ts from ~20MB to ~5MB. This is done by simplifying the geometry of source .geojson file used to generate the polygons. The simplification was done using mapshaper.org. Both the original and the simplified versions of the .geojson files are in the country_data folder.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve frontend loading/performance by (1) splitting the previously aggregated components/pages.tsx page exports into route-level lazy-loaded src/pages/* modules, and (2) updating the country polygon/bounding-box generation flow to support simplified GeoJSON inputs (reducing map payload size per the PR description).

Changes:

  • Refactored routing to lazy-load individual page modules from frontend/src/pages/* instead of importing a large components/pages bundle.
  • Extracted and retained only shared edit-rights helpers in frontend/src/components/pages.tsx.
  • Updated the country data export tool to be more robust to geometry variations/missing geometry and refreshed the generated countryBoundingBoxes.ts; adjusted Cypress navigation to the new route.

Reviewed changes

Copilot reviewed 16 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/router/index.tsx Replaces generic page-module lazy loader with per-page lazy imports and updates routes (e.g., /occurrence instead of /crosssearch).
frontend/src/pages/FrontPage.tsx Adds a route-level wrapper page component for lazy loading.
frontend/src/pages/LocalityPage.tsx New route-level Locality page module using shared rights helpers.
frontend/src/pages/SpeciesPage.tsx New route-level Species page module using shared rights helpers.
frontend/src/pages/OccurrencesPage.tsx New route-level Occurrences page module using shared rights helpers.
frontend/src/pages/MuseumPage.tsx New route-level Museum page module using shared rights helpers.
frontend/src/pages/ReferencePage.tsx New route-level Reference page module using shared rights helpers.
frontend/src/pages/TimeUnitPage.tsx New route-level Time Unit page module using shared rights helpers.
frontend/src/pages/TimeBoundPage.tsx New route-level Time Bound page module using shared rights helpers.
frontend/src/pages/RegionPage.tsx New route-level Region page module using shared rights helpers.
frontend/src/pages/PersonPage.tsx New route-level Person page module using shared rights helpers.
frontend/src/pages/ProjectPage.tsx New route-level Project page module using shared rights helpers.
frontend/src/components/pages.tsx Removes page JSX exports and keeps only shared edit-rights utilities.
frontend/src/country_data/countryExport.js Improves geometry traversal and handles missing geometry during polygon/bounds generation; adds logging for missing-geometry countries.
frontend/src/country_data/countryBoundingBoxes.ts Updates generated bounding boxes to reflect the newly simplified/processed source geometry.
cypress/e2e/ui.cy.js Updates UI navigation test to use /occurrence route.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/router/index.tsx
Comment thread frontend/src/components/pages.tsx
@juhanikat
juhanikat marked this pull request as ready for review August 4, 2026 10:50
@juhanikat
juhanikat merged commit e9fa3e3 into main Aug 4, 2026
5 checks passed
@juhanikat
juhanikat deleted the fix-pages-file-importing branch August 4, 2026 10:51
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.

Improve map loading times Navigating away from the front page for the first time takes a while due to pages.tsx import in index.tsx

2 participants