Skip to content

fix(widgets): restore Preact as JSX renderer, align with @deck.gl/widgets design - #543

Merged
charlieforward9 merged 3 commits into
masterfrom
fix/restore-preact-renderer
Mar 5, 2026
Merged

fix(widgets): restore Preact as JSX renderer, align with @deck.gl/widgets design#543
charlieforward9 merged 3 commits into
masterfrom
fix/restore-preact-renderer

Conversation

@charlieforward9

Copy link
Copy Markdown
Member

Summary

Reverts the preact removal from #532 and restores Preact as the internal JSX renderer for @deck.gl-community/widgets, aligning with the design intent established by @deck.gl/widgets (all official widgets use render() from Preact internally).

The original motivation for removing Preact was a Vite source-alias build failure when consuming widget source directly. The correct fix is per-file /** @jsxImportSource preact */ pragmas — not removing Preact.

Changes

  • Revert refactor: remove preact dependency from widgets module #532 — restore .tsx files with Preact JSX, jsxImportSource: "preact" tsconfig, VNode return types on renderObject()/renderCluster()
  • Add /** @jsxImportSource preact */ pragma to all .tsx widget files — overrides jsxImportSource per-file so TypeScript uses Preact's JSX factory even when compiled under a React project's tsconfig (the common case for Vite source aliases)
  • Remove redundant deck?: Deck | null redeclarations from HtmlOverlayWidget, PanWidget, ZoomRangeWidget — base Widget class already declares deck?: Deck<ViewsT>, and the | null conflicted with the base type (Deck | undefined)
  • this.deck = nullundefined in onRemove() to match base class type
  • Widen hasViewManager() parameter to Deck | null | undefined to match callers

Why Preact, not vanilla DOM

@deck.gl/widgets uses Preact internally for all built-in widgets (ZoomWidget, FullscreenWidget, CompassWidget, GimbalWidget). The UI Module RFC explicitly chose Preact for its component model at minimal bundle size (~3kb). Community widgets should follow the same pattern — VanillaJS public interface, Preact internally.

🤖 Generated with Claude Code

@charlieforward9
charlieforward9 force-pushed the fix/restore-preact-renderer branch from 2711381 to 918b5c5 Compare March 5, 2026 05:29
@charlieforward9
charlieforward9 changed the base branch from master to feat/vitest-ci-coverage March 5, 2026 05:30
@charlieforward9
charlieforward9 force-pushed the fix/restore-preact-renderer branch from fe44699 to ad955c7 Compare March 5, 2026 05:45
@charlieforward9
charlieforward9 changed the base branch from feat/vitest-ci-coverage to master March 5, 2026 05:51
charlieforward9 and others added 3 commits March 5, 2026 00:51
…ompat

Align with @deck.gl/widgets design intent: Preact internally, VanillaJS
public API. Fixes TypeScript errors when vendor source is aliased into a
React project.

- Add /** @jsxImportSource preact */ pragma to all .tsx widget files so
  TypeScript uses Preact's JSX factory instead of React's when compiling
  under the main project tsconfig
- Remove redundant `deck?: Deck | null` redeclaration from HtmlOverlayWidget,
  PanWidget, ZoomRangeWidget — base Widget class already declares it;
  the null type conflicted with Widget<ViewsT>.deck which is Deck | undefined
- Change this.deck = null → this.deck = undefined in onRemove() to match
  base class type (Deck | undefined, not Deck | null)
- Widen hasViewManager() parameter to Deck | null | undefined to match
  callers using this.deck which is now Deck | undefined

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@charlieforward9
charlieforward9 force-pushed the fix/restore-preact-renderer branch from ad955c7 to 5c2fa00 Compare March 5, 2026 05:51
@charlieforward9
charlieforward9 merged commit 0b43e69 into master Mar 5, 2026
1 check passed
@charlieforward9
charlieforward9 deleted the fix/restore-preact-renderer branch March 5, 2026 06:17
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