Skip to content

chore(build): upgrade vite to v8 and align the coupled toolchain - #46

Merged
Ardnived merged 5 commits into
mainfrom
chore/vite-8-upgrade
Jul 14, 2026
Merged

Ardnived merged 5 commits into
mainfrom
chore/vite-8-upgrade

Conversation

@Ardnived

@Ardnived Ardnived commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Upgrades Vite from 5.4.11 to 8.1.4 and moves every Vite-coupled dev dependency in lockstep — the @vitejs/plugin-react and vite-plugin-css-injected-by-js majors peer on Vite 8 exclusively, so the root toolchain can't go piecemeal. Vite 8 swaps the bundler core to Rolldown + Oxc; the widget's two build artifacts (the self-injecting embed.js and the standalone SPA) are verified to behave exactly as before.

  • Root toolchain now on a single Vite 8 major (Ladle keeps its own internal Vite 6, as designed)
  • vite.config.ts migrated to the Vite 8 surface; the load-bearing unhashed embed.js and the sahaj-atlas-style injected style tag are preserved
  • Browser-verified end to end: embed.js loads, styles inject, the map renders, and drawers navigate

Changes

Dependency bumps (package.json / pnpm-lock.yaml):

Package From To
vite ^5.4.11 ^8.1.4
@vitejs/plugin-react ^4.3.4 ^6.0.3
vite-plugin-css-injected-by-js ^3.5.2 ^5.0.1
vite-tsconfig-paths ^4.3.2 ^6.1.1
vitest ^2 ^4.1.10
@ladle/react 4.1.2 ^5.1.1
@types/node 20.5.7 ^22.12.0
  • vite.config.ts — build.rollupOptions → build.rolldownOptions; styleId → attributes: { id: 'sahaj-atlas-style' } (plugin v5 deprecated styleId); __dirname → import.meta.dirname; dropped a long-commented experimental.renderBuiltUrl block.
  • scripts/add-locale-key.mjs — the @types/node 20→22 bump made Array.at(-1) (typed string | undefined) an invalid index key under checkJs (TS2538); index with a definite string instead. Runtime-identical — split('.') always yields ≥1 segment.
  • package.json engines.node — added ^20.19.0 || >=22.12.0 to record the Node floor this upgrade introduces (Vite 8 / plugin-react 6 require it), so a too-old Node fails loudly in local dev / the Pages build instead of opaquely.
  • .github/workflows/ci.yml + scripts/get-cloudflare-preview-url.mjs — repoint the smoke lane at the app's Pages project (CF_PROJECT → sahajatlas.pages.dev) after the Cloudflare integration was moved to two projects (sahajatlas = app, sahajatlas-design = Ladle playground). Also hardened the preview-URL picker to only accept the configured project's *.pages.dev (never fall back to an arbitrary deploy), so smoke can't accidentally run against the design/Ladle site.
  • Vitest 2→4 and Ladle 4→5 needed no config changes (pure version bumps); walked their migration notes (no workspace→projects file here; specs use only stable vi.* APIs).

Decision: build.target — accept the Vite 8 default

Vite 8 raises the default browser floor to Baseline Widely Available 2026-01-01 (Chrome/Edge 111, Firefox 114, Safari 16.4), up from Vite 5's ~Chrome 87 / Safari 14. We accept the new default rather than pinning an older floor: the widget's headline feature is Mapbox GL v3, which already requires modern browsers, so the raised floor doesn't meaningfully change who can use the map. Documented inline in vite.config.ts.

Verification

  • Lint: ✓ pnpm lint (--max-warnings 0)
  • Types: ✓ pnpm typecheck (app + test projects)
  • Tests: ✓ pnpm test:run — 153 tests / 22 files, 947ms (well under the edit-loop hook's ~5s budget)
  • Build: ✓ pnpm build — no rollupOptions deprecation warning (config on rolldownOptions); dist/embed.js emitted unhashed + hashed assets/* for the SPA
  • Ladle: ✓ pnpm ladle:build — all stories render under Ladle 5
  • Install: ✓ pnpm install clean — no Vite peer-dependency warnings; single root Vite major; vaul patch still applies

Manual / visual verification

Ran the production build embedded against the local seeded SahajCloud backend (pnpm preview, standalone entry + demo.html):

  1. <sahaj-atlas> custom element upgrades (:defined); embed.js (Rolldown bundle) executes with 0 console errors.
  2. <style id="sahaj-atlas-style"> present with ~85 KB of valid Lightning-CSS-minified CSS (Raleway @import + .mapboxgl-map rules intact — Lightning CSS is the new default minifier).
  3. Map renders (WebGL2, .mapboxgl-canvas 2400×1524) with clustered event markers; localized country list resolves over HTTP.
  4. Drawer navigation works: clicking a country routes / → /brazil, opens the region drawer, and the map camera frames the region.

(Screenshots captured locally; the map+data render depends on a live SahajCloud client, so it's easiest to re-confirm on the PR's Cloudflare preview.)

Notes for reviewer

  • ✅ Cloudflare deploy — resolved. The old atlas-legacy Pages image predated Vite 8's Node floor (that check failed on Vite 8 while passing on main/Vite 5). The Cloudflare integration was moved to two projects on the current (Node 22) build image — sahajatlas (the app) and sahajatlas-design (the Ladle playground) — both of which now build and deploy under Vite 8. The smoke lane was repointed to the app project (see Changes). All checks green.
  • Doc follow-up (out of scope): CLAUDE.md and .claude/docs/{architecture,mcp-setup}.md still describe the deploy as the single atlas-legacy project, and demo.html has a commented syatlas.pages.dev example URL — worth refreshing to the new two-project setup in a separate docs pass.
  • Reviewed clean. A /code-review (high effort) and a security-review both passed: the config migration preserves the embed.js + sahaj-atlas-style contract, supply-chain provenance checks out (all six bumps are the official-registry latest, lockfile has no non-registry sources), and no secret/env reaches the bundle. Dismissed nits: caret vs exact pins on @ladle/react/@types/node (kept caret — matches the issue's targets + sibling bumps; lockfile pins exact), and the pre-existing assetInfo param name.
  • Security follow-up (out of scope here): the audit flagged [email protected] (< patched 3.4.9, GHSA-vxr8-fq34-vvx9) — the widget's XSS defense in EventPanel, one patch behind. Pre-existing runtime dep, untouched by this build-tooling PR; worth its own chore(deps) bump.
  • Follow-up (out of scope): Vite 8 resolves tsconfig paths natively (resolve.tsconfigPaths: true) and prints an info line suggesting vite-tsconfig-paths can be dropped. Left in per the issue (which bumps, not removes it); worth a small separate PR.
  • entryFileNames and the multi-entry input carry over unchanged under rolldownOptions (verified: Vite 8 types re-add input/output to the option, and the build emits embed.js unhashed).

Closes #45

🤖 Generated with Claude Code

Ardnived and others added 3 commits July 14, 2026 12:15
Bump vite ^5.4.11 -> ^8.1.4 and every vite-coupled dev dependency in
lockstep. The plugin-react and css-injected-by-js majors peer on vite 8
exclusively, so the root toolchain moves as one:

- @vitejs/plugin-react ^4 -> ^6
- vite-plugin-css-injected-by-js ^3 -> ^5
- vite-tsconfig-paths ^4 -> ^6
- vitest ^2 -> ^4
- @ladle/react 4 -> ^5 (keeps its own internal vite 6)
- @types/node 20 -> ^22 (matches the CI Node 22 floor)

The @types/node 20->22 bump surfaces a latent type error in the new
locale helper: Array.at(-1) is `string | undefined`, which the newer lib
types reject as an index key (TS2538). Index with a definite string
instead -- runtime-identical, since split() always yields >=1 segment.

Refs #45

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adopt the Rolldown/Oxc surface Vite 8 exposes:

- build.rollupOptions -> build.rolldownOptions (v8 deprecates the old
  name; the multi-entry input + unhashed-embed.js entryFileNames carry
  over unchanged)
- vite-plugin-css-injected-by-js v5 deprecates `styleId`; move to
  `attributes: { id: 'sahaj-atlas-style' }` (host sites key off this
  exact style-tag id, so it stays stable)
- __dirname -> import.meta.dirname (config runs as ESM under Node >=22)
- drop the long-commented experimental.renderBuiltUrl block

build.target is left at the Vite 8 default (Baseline Widely Available
2026: Chrome/Edge 111, Firefox 114, Safari 16.4) -- documented inline.

Closes #45

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Vite 8, @vitejs/plugin-react 6, and the rest of the bumped toolchain
require Node ^20.19.0 || >=22.12.0. Record that floor in `engines.node`
so local dev and the Cloudflare Pages build surface a too-old Node
instead of failing opaquely mid-build (CI already runs Node 22).

Refs #45

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying atlas-legacy with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8946814
Status:🚫  Build failed.

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
sahajatlas 8946814 Jul 14 2026, 11:46 AM

Empty commit — no diff. Triggers a fresh push event so the two new
Cloudflare Pages projects build against this PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5d56e1b
Status: ✅  Deploy successful!
Preview URL: https://3fc5e063.sahajatlas.pages.dev
Branch Preview URL: https://chore-vite-8-upgrade.sahajatlas.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5d56e1b
Status: ✅  Deploy successful!
Preview URL: https://59cf7964.sahajatlas-design.pages.dev
Branch Preview URL: https://chore-vite-8-upgrade.sahajatlas-design.pages.dev

View logs

…n one

The Cloudflare Pages integration was swapped from atlas-legacy
(syatlas.pages.dev) to two projects: sahajatlas (the app) and
sahajatlas-design (the Ladle playground). The smoke job's stale
CF_PROJECT=syatlas matched neither, so the URL picker fell back to the
first *.pages.dev it found (the design/Ladle deploy) and ran the SPA
smoke specs against the component playground — which has no id="syatlas"
— and failed.

Point CF_PROJECT at sahajatlas.pages.dev, and stop pick() falling back to
an arbitrary deploy: with two projects per PR, only accept a URL for the
configured project (else keep polling, then skip).

Refs #45

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit e2368e2 into main Jul 14, 2026
4 checks passed
@Ardnived
Ardnived deleted the chore/vite-8-upgrade branch July 14, 2026 13:55
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.

chore(build): upgrade vite to v8 and align the coupled toolchain

1 participant