Fixed @svg-maps/world interop so the stats locations map renders under Rolldown#29143
Fixed @svg-maps/world interop so the stats locations map renders under Rolldown#291439larsons wants to merge 1 commit into
Conversation
…r Rolldown ref https://linear.app/ghost/issue/PLA-208 `@svg-maps/world` is a CJS-only data package shaped `{__esModule, default}` with no ESM build. Rolldown resolves the default import to the wrapper object rather than the map data, so `<SVGMap map={World}>` received no locations and rendered blank. Interop-unwrapping the default fixes it and is bundler-agnostic (under Rollup the data object has no `.default`, so the fallback returns it unchanged).
|
Bugbot is not enabled for this team, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | <1s | View ↗ |
nx run-many -t test:unit -p @tryghost/stats,@tr... |
✅ Succeeded | 2m 4s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 1m 38s | View ↗ |
nx run-many -t lint -p @tryghost/stats,@tryghos... |
✅ Succeeded | 25s | View ↗ |
nx run ghost:build:assets |
✅ Succeeded | 2s | View ↗ |
nx run ghost:build:tsc |
✅ Succeeded | 6s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-07-06 20:38:41 UTC
WalkthroughThe change modifies how the Changes
Sequence Diagram(s)Not applicable — this is a small, localized data-resolution fix with no observable multi-component interaction flow. Estimated code review effort: 1 (very low) Related issues: None specified Related PRs: None specified Suggested labels: bug, stats Suggested reviewers: None specified 🐰 A tiny hop through CJS's maze, 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/stats/src/views/Stats/Locations/components/locations-card.tsx (1)
11-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLGTM overall — minor note on the type-cast pattern.
The interop fallback is correct and bundler-agnostic. The cast
(World as {default?: typeof World})is a bit unusual since it types.defaultastypeof World(self-referential) rather than the actual map-data shape, but given@svg-maps/worldis untyped CJS, this is a reasonable pragmatic workaround.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/stats/src/views/Stats/Locations/components/locations-card.tsx` around lines 11 - 13, The interop fallback in locations-card.tsx is fine, but the cast on World is using an awkward self-referential type for .default. Update the World unwrap in the locations-card component to use a clearer, non-self-referential shape for the CJS wrapper while keeping the same runtime fallback behavior, and keep the symbol worldMap as the place where the actual map data is selected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/stats/src/views/Stats/Locations/components/locations-card.tsx`:
- Around line 11-13: The interop fallback in locations-card.tsx is fine, but the
cast on World is using an awkward self-referential type for .default. Update the
World unwrap in the locations-card component to use a clearer,
non-self-referential shape for the CJS wrapper while keeping the same runtime
fallback behavior, and keep the symbol worldMap as the place where the actual
map data is selected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ac5955c0-55ff-462c-8680-5e597d901ff6
📒 Files selected for processing (1)
apps/stats/src/views/Stats/Locations/components/locations-card.tsx

ref https://linear.app/ghost/issue/PLA-208
@svg-maps/worldis a CJS-only data package shaped{__esModule, default}with no ESM build. Under the Rolldown bundler the default import resolves to the wrapper object instead of the map data, so<SVGMap map={World}>gets no locations and the stats locations map silently renders blank.This interop-unwraps the default (
World.default ?? World) soSVGMapalways receives the actual map data. The fix is bundler-agnostic: under Rollup the data object has no.default, so the fallback returns it unchanged and behavior is preserved.Validation (stock Vite/Rollup)
pnpm --filter @tryghost/stats build— passespnpm --filter @tryghost/stats lint— passespnpm --filter @tryghost/stats test:unit— 234 passed