Map widget fails to load in territory management after updating third-party JS library

After upgrading a third-party JavaScript library used for territory visualization maps in SAP CX 2105, the map widget completely fails to load. The console shows initialization errors and the map container remains blank.

We updated from Leaflet 1.7.1 to 1.9.4 to get security patches. The old version worked perfectly. Now the widget initialization fails with this error:


TypeError: L.map is not a function
at TerritoryMapWidget.initialize (widget.js:45)

The library is loaded correctly (I can see it in Network tab), but the initialization code that worked before is now broken. Has anyone dealt with third-party library updates breaking map widgets? What’s the proper way to handle API breaking changes in SAP CX client-side customizations?

Good point about RequireJS config. I haven’t explicitly configured a shim for Leaflet. Where exactly should I add this configuration in SAP CX 2105 for territory management widgets?

Leaflet 1.9.x changed how it exports modules. If you’re using AMD or module loaders, the initialization pattern changed. Check if you’re loading Leaflet before your widget code executes. The error suggests L is undefined at initialization time. Try wrapping your initialization in a document ready handler or use the widget framework’s dependency management.

Between Leaflet 1.7 and 1.9, they changed the ESM export format. If SAP CX’s module loader expects AMD or UMD format and Leaflet now ships ESM, you’ll get this exact error. Check which version of the library you’re actually loading - the CDN might be serving a different build. Leaflet offers multiple builds: leaflet.js (UMD), leaflet-src.js (unminified), and ESM modules. Make sure you’re using the UMD build for browser globals.

I’m loading Leaflet in the widget’s dependencies array, which should ensure proper load order. The library file is definitely loading - I can see the network request succeeds. Could this be a namespace conflict or module format issue?