Azure maps not loading in D365 Ecommerce production build. Getting ReferenceError: Cannot access <something> before Initialization
Screenshot 2024-12-18 163730.png
one of our D365 Ecommerce customers has migrated to Azure maps and are facing some issues in their production build. The map is not loading properly in production build. And we can also see console errors- ReferenceError: Cannot access <something> before InitializationFound some relevant issue in azure maps github pages. Looks like the issue is with webpack and terser minification. The map loads properly in production if minimizer is disabled . However, we are looking for a workaround as exposing source code is not advisable.
https://github.com/Azure/react-azure-maps/issues/187
https://github.com/Azure/react-azure-maps/issues/193
For Ecommerce, we have this starter project on top of which our customers can have their Customizations. https://github.com/microsoft/Msdyn365.Commerce.Online . I tried implementing the suggestion in the github issues pages but none of them worked for this Ecommerce repository.
Note: we use the azure-maps-control version: 3.5.0
steps taken:
- The azure-maps-control works fine in a React App production build (Create React App) which also uses webpack. I have tried to implement same webpack and terser config from the default React App to our Ecommerce repository, but issue is not resolved.
- Tried to use different minimizer like esbuild but got Failed to load error - handle chunk error