Improve loading times by splitting pages.tsx into smaller files and improving the locality map - #1224
Merged
Merged
Conversation
This was
linked to
issues
Jul 22, 2026
Contributor
There was a problem hiding this comment.
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 largecomponents/pagesbundle. - 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split
pages.tsxinto 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/crosssearchroutes to/occurrence.This PR also reduces the transferred size of
countryPolygons.tsfrom ~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 thecountry_datafolder.