Bumped vite and vitest in portal, sodo-search, announcement-bar#27869
Conversation
The three mid-version public/UMD apps move from vite@5.4.21 + vitest@3.2.4 to vite@7.3.2 + vitest@4.1.2, aligning with the rest of the apps lane that landed via PR #27731, ccf3d73, and #27867. @vitest/coverage-v8 bumped from 3.2.4 to 4.1.2 in all three. @vitest/ui (portal only) removed - it was listed but no script referenced it. Substantive changes beyond the bumps: vite-plugin-svgr v3 -> v4 changed the SVG import API. v3 exposed both `default` (URL) and named `ReactComponent` on every .svg import; v4 splits them - ./foo.svg is the URL, ./foo.svg?react is the React component (as default export). Migrated 55 `import {ReactComponent as X} from '...svg'` patterns to `import X from '...svg?react'` across: - 51 imports in portal (29 files) - 3 imports in sodo-search (1 file) - 1 import in announcement-bar (1 file) No vitest 3 -> 4 breaking patterns were present in these workspaces (no typed `vi.fn<>` generics, no `global.fetch` references, no `MockInstance<>` patterns). Verification: - portal: 541/541 tests (1 skipped, pre-existing), build, lint - sodo-search: 8/8 tests, build, lint (one autofix for import sort in the SVG migration target) - announcement-bar: 1/1 tests, build, lint - All three UMD wrappers intact in produced .umd.js bundles
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (32)
WalkthroughThis pull request systematically modernizes SVG icon imports across three Ghost applications. The change migrates from the legacy SVGR 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27869 +/- ##
==========================================
- Coverage 73.74% 73.73% -0.01%
==========================================
Files 1519 1519
Lines 127726 127726
Branches 15291 15291
==========================================
- Hits 94186 94182 -4
- Misses 32613 32615 +2
- Partials 927 929 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The final two public/UMD apps move from vite@5.4.21 + vitest@1.6.1 to vite@7.3.2 + vitest@4.1.2, finishing the unification across apps/* that started with PR #27731 and continued through #27867 and #27869. Every workspace under apps/ now runs the same vite + vitest pair. @vitest/coverage-v8 in comments-ui jumped from 0.34.6 to 4.1.2 - it had been pinned to a version compatible with vitest 0.x and was years out of date. Substantive changes beyond the bumps: 1. vite-plugin-svgr v3 -> v4 changed the SVG import API (./foo.svg now gives the URL, ./foo.svg?react gives the React component as default export). Migrated 16 imports across: - 14 in comments-ui (12 files) - 2 in signup-form (2 files) Both typings.d.ts files were split into *.svg (URL default) and *.svg?react (component default), using `import type` instead of the legacy `import React = require('react')` pattern. 2. vitest 1 -> 4 had two test-side issues in comments-ui: a. setup-tests.ts: `global.ResizeObserver = vi.fn() .mockImplementation(() => ({...}))` - vitest 4 enforces that mocks called with `new` have constructable implementations, and arrow functions are not constructable. Switched to function expression form. b. test/unit/utils/api.test.ts: three tests each called vi.spyOn(window, 'fetch') with no teardown. The spy persisted across tests, accumulating call counts. Added an afterEach with vi.restoreAllMocks(). 3. vite 5 -> 7 build performance fix in all four public UMD apps (signup-form, comments-ui, plus portal and sodo-search already on vite 7 from #27869). Each app's vite.config used `commonjsOptions.dynamicRequireTargets: SUPPORTED_LOCALES.map( locale => '../../ghost/i18n/locales/' + locale + '/X.json')`, producing an array of ~60 explicit paths. Under vite 7's bundled @rollup/plugin-commonjs, each entry in that array triggers a full directory crawl from `dynamicRequireRoot` (= repo root, including node_modules) at the start of every build. The result was a ~58s delay before rollup's buildStart hook fired, which under `vite build && vite preview` blew playwright's webServer timeout (10s for signup-form, 20s for comments-ui). Replaced the N-entries-per-locale array with a single glob - `['../../ghost/i18n/locales/*/X.json']` - which the plugin resolves with one crawl. Same bundle output (verified byte-for-byte for portal/sodo-search/comments-ui; signup-form bundle size unchanged at 301817 bytes). Build time drops from ~60s to ~2s. Also fixed for portal and sodo-search in this PR even though they're not on the failing branch - they were already shipping the slow pattern on main via #27869 and the savings apply. Patch version bumps on both new packages (CI version-bump check requires this whenever source files change in a monitored app). Verification: - comments-ui: 207/207 unit tests, build (2.7s, was 60s), lint - signup-form: build (2.0s, was 60s), lint - portal: build (3.6s, was 60s+) - bundle byte-identical - sodo-search: build (4.7s, was 60s+) - bundle byte-identical - Local repro: dev:test webServer ready in 4s (was timing out)
The final two public/UMD apps move from vite@5.4.21 + vitest@1.6.1 to vite@7.3.2 + vitest@4.1.2, finishing the unification across apps/* that started with PR #27731 and continued through #27867 and #27869. Every workspace under apps/ now runs the same vite + vitest pair. @vitest/coverage-v8 in comments-ui jumped from 0.34.6 to 4.1.2 - it had been pinned to a version compatible with vitest 0.x and was years out of date. Substantive changes beyond the bumps: 1. vite-plugin-svgr v3 -> v4 changed the SVG import API (./foo.svg now gives the URL, ./foo.svg?react gives the React component as default export). Migrated 16 imports across: - 14 in comments-ui (12 files) - 2 in signup-form (2 files) Both typings.d.ts files were split into *.svg (URL default) and *.svg?react (component default), using `import type` instead of the legacy `import React = require('react')` pattern. 2. vitest 1 -> 4 had two test-side issues in comments-ui: a. setup-tests.ts: `global.ResizeObserver = vi.fn() .mockImplementation(() => ({...}))` - vitest 4 enforces that mocks called with `new` have constructable implementations, and arrow functions are not constructable. Switched to function expression form. b. test/unit/utils/api.test.ts: three tests each called vi.spyOn(window, 'fetch') with no teardown. The spy persisted across tests, accumulating call counts. Added an afterEach with vi.restoreAllMocks(). 3. vite 5 -> 7 build performance fix in all four public UMD apps (signup-form, comments-ui, plus portal and sodo-search already on vite 7 from #27869). Each app's vite.config used `commonjsOptions.dynamicRequireTargets: SUPPORTED_LOCALES.map( locale => '../../ghost/i18n/locales/' + locale + '/X.json')`, producing an array of ~60 explicit paths. Under vite 7's bundled @rollup/plugin-commonjs, each entry in that array triggers a full directory crawl from `dynamicRequireRoot` (= repo root, including node_modules) at the start of every build. The result was a ~58s delay before rollup's buildStart hook fired, which under `vite build && vite preview` blew playwright's webServer timeout (10s for signup-form, 20s for comments-ui). Replaced the N-entries-per-locale array with a single glob - `['../../ghost/i18n/locales/*/X.json']` - which the plugin resolves with one crawl. Same bundle output (verified byte-for-byte for portal/sodo-search/comments-ui; signup-form bundle size unchanged at 301817 bytes). Build time drops from ~60s to ~2s. Also fixed for portal and sodo-search in this PR even though they're not on the failing branch - they were already shipping the slow pattern on main via #27869 and the savings apply. Patch version bumps on both new packages (CI version-bump check requires this whenever source files change in a monitored app). Verification: - comments-ui: 207/207 unit tests, build (2.7s, was 60s), lint - signup-form: build (2.0s, was 60s), lint - portal: build (3.6s, was 60s+) - bundle byte-identical - sodo-search: build (4.7s, was 60s+) - bundle byte-identical - Local repro: dev:test webServer ready in 4s (was timing out)
Why
The three mid-version public/UMD apps move from
vite@5.4.21 + vitest@3.2.4tovite@7.3.2 + vitest@4.1.2, aligning with the rest of the apps lane that landed via PR #27731, commitccf3d7368f, and PR #27867. After this PR, onlysignup-formandcomments-uiremain on the legacy stack.Bumps
portalsodo-searchannouncement-barAlso removed:
@vitest/uifromportal/package.json— it was listed but no script referenced it.Patch version bumps on all three packages (CI version-bump check requires this whenever source files change in a monitored app).
Substantive changes beyond the bumps
SVG migration (vite-plugin-svgr v3 → v4)
v3 exposed both
default(URL) and namedReactComponenton every.svgimport; v4 splits them —./foo.svgis the URL,./foo.svg?reactis the React component (as default export). v3's dual-export came from itstransformhook merging with Vite's URL handling; v4'sloadhook bypasses Vite's asset pipeline entirely, so the dual export cannot be preserved by configuration.Migrated 55 imports total:
portal(29 files)sodo-search(1 file)announcement-bar(1 file)All are the simple form:
import {ReactComponent as Foo} from '...svg'→import Foo from '...svg?react'. Noimport.meta.globpatterns in these workspaces (unlike shade), and no typings.d.ts changes needed (these are.jsprojects, not TS).vitest 3 → 4
No breaking patterns hit. None of the workspaces use typed
vi.fn<>generics,global.fetch, orMockInstance<>. The function-shape generic fix that hit shade isn't needed here.Test plan
pnpm --filter @tryghost/portal test— 541/541 passing (1 skipped, pre-existing)pnpm --filter @tryghost/sodo-search test— 8/8 passingpnpm --filter @tryghost/announcement-bar test— 1/1 passingpnpm --filter @tryghost/portal build— exit 0; UMD wrapper intact atapps/portal/umd/portal.min.js(~2.4MB, comparable to main)pnpm --filter @tryghost/sodo-search build— exit 0; UMD wrapper intact atapps/sodo-search/umd/sodo-search.min.js(~307KB)pnpm --filter @tryghost/announcement-bar build— exit 0; UMD wrapper intact atapps/announcement-bar/umd/announcement-bar.min.js(~136KB)sodo-search/src/components/popup-modal.jsafter the SVG migration)Notes
fs/pathimports from@tryghost/root-utils,@tryghost/i18n, andfind-rootare pre-existing — same modules were externalized under vite 5; the warning text format is just more visible in vite 7.