Skip to content

Upgrade routing and utility libraries - #7857

Open
arikfr wants to merge 2 commits into
fe/06-babel-8-browser-targetsfrom
fe/07-routing-utility-libs
Open

arikfr wants to merge 2 commits into
fe/06-babel-8-browser-targetsfrom
fe/07-routing-utility-libs

Conversation

@arikfr

@arikfr arikfr commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

What type of PR is this?

  • Other (dependencies)

Description

Part 7 of the frontend dependency upgrade stack tracked in #7848. Stacked on #7856.

Routing

  • universal-router 8 → 10. Version 10 bundles path-to-regexp 8 (as universal-router/path-to-regexp), so the direct path-to-regexp 3 dependency is gone.
    • routes.ts sorts routes by parameter count. path-to-regexp 8's parse() returns { tokens } with nested optional groups instead of a flat array, so the counting is rewritten.
    • The router's Context type is now RouterContext, and Route's generic parameters are in the opposite order.
    • path-to-regexp 8 has no inline regex parameters. The one route that used them, /dashboards/:dashboardId([^-]+)(-.*)?, becomes /dashboards/:dashboardId, and its render keeps only the part before the first -, exactly what the regex captured.
  • Verification: I resolved 35 URLs against all our route paths with universal-router 8 (old paths) and 10 (new paths), each sorted the way routes.ts sorts them. The URLs covered every page, static routes that compete with parameterized ones (/queries/new vs /queries/:queryId), dashboards with and without slugs, trailing slashes, case differences, encoded characters and unknown paths. All 35 resolved to the same route and parameters.
  • history stays on 4. history 5's block() also registers a beforeunload listener that always triggers the browser's "leave page?" prompt (source). useUnsavedChangesAlert keeps a blocker registered for as long as the query editor is mounted and only asks when there are unsaved changes. On history 5, every reload or tab close from the editor would prompt. history 5 hasn't had a release since 2022 and offers nothing we need.

Utilities

  • query-string 6 → 9 (ESM-only; added with its dependencies to Jest's transform list). parse/stringify output is identical to 6.14.1 on 21 inputs matching how we use it: location search parsing, the axios params serializer, arrays, flags, null/undefined, encoded characters.
  • use-debounce 3 → 10. useDebouncedCallback returns the debounced function (memoized, with .cancel()/.flush()) instead of [fn, cancel]. That touches 26 call sites, 25 of them one-line destructuring changes. Also, use-debounce/lib deep imports (4 viz-lib files) no longer resolve.
  • chroma-js 1 → 3 (viz-lib). The only breaking change, color.css() output format, isn't used. It still ships a CommonJS build.
  • leaflet 1.3 → 1.9 (viz-lib). leaflet.markercluster 1.5 declares leaflet ^1.3.1. The map and choropleth e2e specs cover the plugins. Leaflet 1.8+ sizes map text in rem, and our root font size is 10px (from Bootstrap), so legends and the attribution became tiny; .leaflet-container keeps its previous 12px. Leaflet's attribution prefix now includes a small flag of Ukraine (its default since 1.8).

Tests
viz-lib's setup froze the clock with MockDate. use-debounce 10 measures elapsed time with Date.now(), so on a frozen clock debounced callbacks never fired, and 29 editor tests timed out. The setup now uses Jest's fake clock, starting at the same fixed date but advancing in real time. Nothing in viz-lib depends on the current time (no snapshot contains the date), and the suite now runs in ~3s instead of ~20s.

Route test: client/app/services/routes.test.js resolves 12 URLs against competing paths (/queries/new vs /queries/:queryId, /dashboards/favorites vs /dashboards/:dashboardId, ...) and checks the sort order. Jest is pointed at universal-router's ES module build: the CommonJS build of its path parser throws on any path (it spreads a string with a helper that only handles arrays). The app is unaffected, since webpack uses the ES module build.

How is this tested?

  • Unit tests (pytest, jest)

  • Lint, type-check (client and viz-lib), jest (client 96, viz-lib 154, no snapshot changes) and the production build pass locally.

  • The route-matching and query-string comparisons above.

  • Visual tests (Add Playwright visual tests for visualizations, remove Percy #7853): only the maps change: the attribution flag, and anti-aliasing along shape edges. Their baselines are updated in a separate commit.

🤖 Generated with Claude Code

Review in cubic

@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Upgrades routing and utility libraries with API changes.

The PR appears safe to merge; no outstanding finding or new actionable issue was identified.

Summary

The PR upgrades routing and utility libraries, adapts route ordering and debounce call sites, updates map styling and test timers, and adds route-resolution coverage.

Reviews (6) · Last reviewed commit: "Update visual test baselines for Leaflet..." · Reviewed by Greptile

Comment thread client/app/services/routes.ts

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 29 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread viz-lib/src/visualizations/chart/Editor/GeneralSettings.tsx
Comment thread viz-lib/__tests__/mocks.js
@arikfr arikfr mentioned this pull request Sep 27, 2026
3 tasks done
@arikfr
arikfr force-pushed the fe/07-routing-utility-libs branch from ba68eec to 3d57946 Compare September 28, 2026 09:42
@arikfr
arikfr force-pushed the fe/06-babel-8-browser-targets branch from c60abf8 to 073936a Compare September 28, 2026 09:42
@arikfr
arikfr force-pushed the fe/07-routing-utility-libs branch 2 times, most recently from 17aacee to cb82389 Compare October 3, 2026 21:06
@arikfr
arikfr force-pushed the fe/06-babel-8-browser-targets branch 2 times, most recently from 2793dae to 2b92673 Compare October 4, 2026 13:56
@arikfr
arikfr force-pushed the fe/07-routing-utility-libs branch from cb82389 to 5a1c8a9 Compare October 4, 2026 13:56
arikfr and others added 2 commits October 8, 2026 14:40
- universal-router 8 → 10, which bundles path-to-regexp 8. Drop our direct
  path-to-regexp 3 dependency and use the bundled one in routes.ts, whose
  `parse()` now returns nested tokens. path-to-regexp 8 has no inline
  regex parameters, so the dashboard route matches `:dashboardId` and
  strips the `-slug` suffix in `render`, as the old regex did.
- query-string 6 → 9 (ESM-only; added with its dependencies to Jest's
  transform list).
- use-debounce 3 → 10: `useDebouncedCallback` returns the debounced
  function (with `.cancel()`) instead of an array, and `use-debounce/lib`
  is no longer importable.
- chroma-js 1 → 3 and leaflet 1.3 → 1.9 in viz-lib.
- viz-lib tests: start the clock at the fixed test date but let it run.
  use-debounce 10 measures elapsed time with Date.now(), so debounced
  callbacks never fired on MockDate's frozen clock.

history stays on 4: history 5's `block()` always installs a beforeunload
prompt, which would make the query editor's conditional unsaved-changes
alert fire on every reload.

Part of #7848.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Leaflet 1.9 adds a flag to its attribution prefix and anti-aliases map
shape edges slightly differently.
@arikfr
arikfr force-pushed the fe/07-routing-utility-libs branch from 5a1c8a9 to 109059d Compare October 8, 2026 12:36

This branch has not been deployed

No deployments
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.

1 participant