Skip to content

Fixed @svg-maps/world interop so the stats locations map renders under Rolldown#29143

Open
9larsons wants to merge 1 commit into
mainfrom
steve/pla-208-svg-maps-world-interop
Open

Fixed @svg-maps/world interop so the stats locations map renders under Rolldown#29143
9larsons wants to merge 1 commit into
mainfrom
steve/pla-208-svg-maps-world-interop

Conversation

@9larsons

@9larsons 9larsons commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

ref https://linear.app/ghost/issue/PLA-208

@svg-maps/world is 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) so SVGMap always 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 — passes
  • pnpm --filter @tryghost/stats lint — passes
  • pnpm --filter @tryghost/stats test:unit — 234 passed

…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).
@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown

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.

@nx-cloud

nx-cloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 589acf8

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

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change modifies how the @svg-maps/world module is imported and consumed in the locations-card component. A new worldMap constant handles CJS/interop resolution to extract the correct map data, and the SVGMap component now uses this resolved value instead of the raw import.

Changes

File Summary
`apps/stats/src/views/Stats/Locations/components/locations-card.tsx` Added CJS interop wrapper (`worldMap`) for `@svg-maps/world` import; updated `SVGMap` component to use `worldMap` instead of `World`.

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,
World map now shines through the interop haze,
One constant fixed, the globe displays true,
No more broken imports, just a rabbit's due.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing @svg-maps/world interop for Rolldown rendering.
Description check ✅ Passed The description matches the code change and explains the Rolldown interop fix and validation steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch steve/pla-208-svg-maps-world-interop

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
apps/stats/src/views/Stats/Locations/components/locations-card.tsx (1)

11-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

LGTM 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 .default as typeof World (self-referential) rather than the actual map-data shape, but given @svg-maps/world is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 13c561f and 589acf8.

📒 Files selected for processing (1)
  • apps/stats/src/views/Stats/Locations/components/locations-card.tsx

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