mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
chore(client): take the GL engines out of the entry chunk (#1801)
* refactor(settings): load the GL map preview on demand MapViewGL and JourneyMapGL are both behind lazy() so a Leaflet-only install never downloads the GL engines. MapboxPreview imported mapbox-gl and maplibre-gl statically, which put them back in the entry chunk and cancelled that out. Wrap it in lazy()/Suspense on both the desktop tab and the mobile screen. The entry chunk drops from 7987 kB to 5157 kB (2057 kB to 1292 kB gzipped); the engines now ship as their own chunk, loaded when a GL provider is picked. The preview no longer resolves synchronously, so the tests that read it right after switching provider await it now. * chore(client): drop unused deps, self-host MuseoModerno, add a bundle baseline @react-pdf/renderer, react-window and @types/react-window have no importers anywhere: TripPDF builds HTML for the browser print window and JourneyBookPDF goes through marked. RegisterPage is dead too, /register renders LoginPage. MuseoModerno was the last font still coming from the Google CDN through a render-blocking <link>, while main.tsx already self-hosts Poppins and Geist for exactly the reason stated in the comment there. Same weights, now bundled. Add rollup-plugin-visualizer behind `npm run build:analyze` so the splitting work has numbers to argue with, pin build.target instead of inheriting Vite's default, and bring the workbox size ceiling down from 10 MB to 6 MB — anything above it is dropped from the precache manifest silently, which only shows up as a broken offline app.
This commit is contained in:
@@ -183,7 +183,8 @@ describe('MapSettingsTab – GL providers', () => {
|
||||
expect(screen.getByText('Mapbox Access Token')).toBeInTheDocument();
|
||||
expect(screen.getByText('Map Style')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Map Template')).not.toBeInTheDocument();
|
||||
expect(screen.getByTestId('gl-preview')).toHaveAttribute('data-provider', 'mapbox-gl');
|
||||
// The preview is lazy-loaded, so the first read of it has to await the chunk.
|
||||
expect(await screen.findByTestId('gl-preview')).toHaveAttribute('data-provider', 'mapbox-gl');
|
||||
expect(screen.getByDisplayValue(MAPBOX_STANDARD)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -240,7 +241,7 @@ describe('MapSettingsTab – GL providers', () => {
|
||||
expect(screen.queryByText('3D Buildings & Terrain')).not.toBeInTheDocument();
|
||||
expect(screen.getByDisplayValue(OFM_LIBERTY)).toBeInTheDocument();
|
||||
expect(screen.getByText('Preset or OpenFreeMap style URL. OpenFreeMap styles work without a token.')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('gl-preview')).toHaveAttribute('data-provider', 'maplibre-gl');
|
||||
expect(await screen.findByTestId('gl-preview')).toHaveAttribute('data-provider', 'maplibre-gl');
|
||||
});
|
||||
|
||||
it('FE-COMP-MAP-023: switching from MapLibre back to Mapbox drops the OpenFreeMap style', async () => {
|
||||
@@ -274,7 +275,7 @@ describe('MapSettingsTab – GL providers', () => {
|
||||
|
||||
await user.type(screen.getByPlaceholderText('pk.eyJ1Ijoi...'), 'pk.token');
|
||||
|
||||
expect(screen.getByTestId('gl-preview')).toHaveAttribute('data-token', 'pk.token');
|
||||
expect(await screen.findByTestId('gl-preview')).toHaveAttribute('data-token', 'pk.token');
|
||||
});
|
||||
|
||||
it('FE-COMP-MAP-026: the 3D and quality toggles drive the preview', async () => {
|
||||
@@ -282,6 +283,7 @@ describe('MapSettingsTab – GL providers', () => {
|
||||
render(<MapSettingsTab />);
|
||||
await user.click(screen.getByText('Mapbox GL'));
|
||||
|
||||
await screen.findByTestId('gl-preview');
|
||||
const preview = () => screen.getByTestId('gl-preview');
|
||||
expect(preview()).toHaveAttribute('data-3d', 'true');
|
||||
expect(preview()).toHaveAttribute('data-quality', 'false');
|
||||
|
||||
Reference in New Issue
Block a user