farmOS / farmOS-map

farmOS-map is an OpenLayers wrapper library designed for agricultural mapping needs. It can be used in any project that has similar requirements.
https://farmOS.github.io/farmOS-map
MIT License
35 stars 21 forks source link

Allow the public path to be set for Webpack chunk loading #182

Closed paul121 closed 1 year ago

paul121 commented 1 year ago

This is a prerequisite for fixing this farmOS core issue where farmOS-map chunks are not loaded for maps rendered via AJAX: https://www.drupal.org/project/farm/issues/3243922

The trick is that we need to set __webpack_public_path__ in the farmOS-map entrypoint main.js: https://stackoverflow.com/a/51245153. I chose to add this in a separate publicPath.js file as recommended by the Webpack On the fly docs (see warning message). This change works when simply added to the top of main.js but it raises eslint errors so a separate import makes this cleaner as well.

Added a quick note about this to the "Advanced integrations" section of the README, I'm not sure if we need to include additional details there?

paul121 commented 1 year ago

I've opened a merge request that implements this change for farmOS core: https://git.drupalcode.org/project/farm/-/merge_requests/73

But I think it is worth noting that this change could be useful for other projects that use farmOS-map in another framework where they are not bundling farmOS-map themselves.

mstenta commented 1 year ago

I think this makes sense to me, and the changes look relatively simple. I'll defer the final decision to @symbioquine though since he has a better understanding of the considerations than I do.

paul121 commented 1 year ago

Thanks @symbioquine and also thank you @vital-agronomics for funding my time on this!