[openstreetmap/openstreetmap-website] Load js controller modules only when needed (PR #7147)
Tom Hughes
notifications at github.com
Sun Jun 21 17:57:56 UTC 2026
@tomhughes commented on this pull request.
> @@ -33,9 +33,15 @@ OSM = {
LAYER_DEFINITIONS: <%= MapLayers::full_definitions("config/layers.yml", :legends => "config/legend.yml").to_json %>,
- RTL_TEXT_PLUGIN: <%= javascript_path("@mapbox/mapbox-gl-rtl-text/dist/mapbox-gl-rtl-text.js").to_json %>,
-
- MAKE_PLURAL_CARDINALS: <%= javascript_path("make-plural/cardinals.js").to_json %>,
+ MODULE_PATHS: <%=
+ %i[changeset directions element export history home index new_note note query search]
+ .each_with_object({}) { |module_name, hash| hash[:"index_#{module_name}"] = "index_modules/#{module_name}" }
+ .merge(
+ :mapbox_rtl_text => "@mapbox/mapbox-gl-rtl-text/dist/mapbox-gl-rtl-text.js",
+ :make_plural_cardinals => "make-plural/cardinals.js"
+ )
+ .transform_values { |path| javascript_path(path).sub('javascripts/', 'assets/') }
Seems to work with your branch as well:
```ruby
open-street-map(dev):001> helper.javascript_path("index_modules/query")
=> "/assets/index_modules/query-5b524cf436523b659e9dd960f61315437f2676b40b1faa2e29c6e6da3fefc580.js"
```
and removing that `sub` from that code everything seems to work and it gets the correct URLs and manages to load modules.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7147#discussion_r3448834977
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/7147/review/4540073205 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260621/856d80af/attachment.htm>
More information about the rails-dev
mailing list