Skip to content

feat: add Mapbox GL JS support with separate build targets#145

Open
dailyprice wants to merge 2 commits intomasterfrom
dailyprice/mapbox-compat
Open

feat: add Mapbox GL JS support with separate build targets#145
dailyprice wants to merge 2 commits intomasterfrom
dailyprice/mapbox-compat

Conversation

@dailyprice
Copy link

Summary

Implement dual-library support for both MapLibre and Mapbox GL JS using build-time path aliasing. The codebase now builds two separate npm packages (maplibre-geoman and mapbox-geoman) with VITE_BASE_MAP environment variable controlling which adapter is used at compile time.

Key Changes

  • Add src/core/map/mapbox/ adapter directory with complete MapLibre API compatibility layer for Mapbox GL JS
  • Mapbox source implementation includes manual applyDiff() logic to handle Mapbox's lack of incremental updateData() API
  • Extract module augmentation and CSS into adapter directories for build-time switching via @mapLib alias
  • Add control class constants (maplibregl-ctrl vs mapboxgl-ctrl) configurable per adapter
  • New tsconfig.mapbox.json for Mapbox build target
  • Add build:mapbox and build:types:mapbox npm scripts
  • Create dev entry point with OSM raster tiles and dynamic:true/false toggle for demonstrating fixes

Testing

Both build targets verified:

  • npm run build → produces dist/maplibre-geoman.*
  • VITE_BASE_MAP=mapbox npm run build → produces dist/mapbox-geoman.*
  • Existing Playwright tests pass without regressions

Closes #7

🤖 Generated with Claude Code

dailyprice and others added 2 commits February 16, 2026 15:19
Implement dual-library support for both MapLibre and Mapbox GL JS using build-time path aliasing. The codebase now builds two separate packages (maplibre-geoman and mapbox-geoman) with VITE_BASE_MAP environment variable controlling which adapter is used.

Key changes:
- Add src/core/map/mapbox/ adapter directory mirroring MapLibre implementation
- Mapbox source uses applyDiff() to manually apply GeoJSONSourceDiffHashed since Mapbox lacks incremental updateData() API
- Extract module augmentation and CSS into adapter directories for build-time switching
- Add control class constants (maplibregl-ctrl vs mapboxgl-ctrl) via @maplib alias
- Update vite.config.ts, tsconfig.json to support baseMap parameter and create tsconfig.mapbox.json
- Add build:mapbox and build:types:mapbox npm scripts
- Create src/dev/index.mapbox.dev.ts with OSM raster tiles and dynamic:true/false toggle to verify fixes
- Both builds verified: npm run build (MapLibre) and VITE_BASE_MAP=mapbox npm run build (Mapbox)

Closes #7

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

When is Mapbox compatible?

2 participants