From aefc94b89ec25ec2daa4db685a0af079fa894e8b Mon Sep 17 00:00:00 2001 From: sai80082 Date: Tue, 7 Apr 2026 00:15:45 +0530 Subject: [PATCH] fix: replace leaflet-defaulticon-compatibility with direct icon imports for Turbopack compatibility --- package.json | 1 - src/components/LeafletHeatMap.tsx | 13 ++++++++++--- .../TagMissingLocationDialog/Map.tsx | 12 ++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index f61a434..2113fed 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "drizzle-orm": "^0.45.2", "jsonwebtoken": "^9.0.3", "leaflet": "^1.9.4", - "leaflet-defaulticon-compatibility": "0.1.2", "leaflet.heat": "^0.2.0", "lucide-react": "^0.428.0", "next": "15.5.14", diff --git a/src/components/LeafletHeatMap.tsx b/src/components/LeafletHeatMap.tsx index 2a679e5..2280d91 100644 --- a/src/components/LeafletHeatMap.tsx +++ b/src/components/LeafletHeatMap.tsx @@ -5,9 +5,16 @@ import 'leaflet.heat'; import { getAssetGeoHeatmap, IHeatMapParams } from '@/handlers/api/asset.handler'; import { Loader2 } from 'lucide-react'; -// Fix for default markers in Leaflet -import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css'; -import 'leaflet-defaulticon-compatibility'; +// Fix default marker icons for bundlers that don't support ~ aliases +import markerIcon2x from 'leaflet/dist/images/marker-icon-2x.png'; +import markerIcon from 'leaflet/dist/images/marker-icon.png'; +import markerShadow from 'leaflet/dist/images/marker-shadow.png'; + +L.Icon.Default.mergeOptions({ + iconUrl: markerIcon.src, + iconRetinaUrl: markerIcon2x.src, + shadowUrl: markerShadow.src, +}); interface LeafletHeatMapProps { filters: IHeatMapParams; diff --git a/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx b/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx index b5f4673..68385ef 100644 --- a/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx +++ b/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx @@ -4,8 +4,16 @@ import "leaflet/dist/leaflet.css"; import L, { LatLngExpression } from 'leaflet'; -import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css'; // Re-uses images from ~leaflet package -import 'leaflet-defaulticon-compatibility'; +// Fix default marker icons for bundlers that don't support ~ aliases +import markerIcon2x from 'leaflet/dist/images/marker-icon-2x.png'; +import markerIcon from 'leaflet/dist/images/marker-icon.png'; +import markerShadow from 'leaflet/dist/images/marker-shadow.png'; + +L.Icon.Default.mergeOptions({ + iconUrl: markerIcon.src, + iconRetinaUrl: markerIcon2x.src, + shadowUrl: markerShadow.src, +}); import { MapContainer, TileLayer, useMapEvents } from "react-leaflet"; import { useState } from "react";