Skip to content

Re: https://github.com/OpenHistoricalMap/issues/issues/929, changes t…o ohm-website to allow it to work with map-styles as an npm module. - #269

Merged
erictheise merged 12 commits into
stagingfrom
929-shift-to-npm-approach-map-styles
Mar 14, 2025

Conversation

@erictheise

Copy link
Copy Markdown

This is a companion pull request to OpenHistoricalMap/map-styles#32.

@github-actions github-actions Bot added the big-pr label Feb 6, 2025
@github-actions

github-actions Bot commented Feb 6, 2025 •

Copy link
Copy Markdown
2 Warnings
⚠️ Number of updated lines of code is too large to be in one PR. Perhaps it should be separated into two or more?
⚠️ Merge commits are found in PR. Please rebase to get rid of the merge commits in this PR, see CONTRIBUTING.md.

Generated by 🚫 Danger

@danrademacher

Copy link
Copy Markdown

As noted in OpenHistoricalMap/map-styles#32 (comment), we will need to ultimately host separate, fully functional style JSON files for each of the styles we host (Historical, Railway, Woodblock, Japanese Scroll) so that those styles can be easily used by other consumers, knowing they are pulling from the canonical source on openhistoricalmap.org.

@danrademacher danrademacher left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, this all seems fine based on reading the code. But when I try to run the code locally, I get a big ol' Rails error:

image

ohm-website-web-1  | Started GET "/" for 172.20.0.1 at 2025-02-11 01:43:39 +0000
ohm-website-web-1  | Processing by SiteController#index as HTML
ohm-website-web-1  |   Rendering layout layouts/map.html.erb
ohm-website-web-1  |   Rendering site/index.html.erb within layouts/map
ohm-website-web-1  |   Rendered site/index.html.erb within layouts/map (Duration: 5.5ms | GC: 0.0ms)
ohm-website-web-1  |   Rendered layout layouts/map.html.erb (Duration: 235.6ms | GC: 0.8ms)
ohm-website-web-1  | Completed 500 Internal Server Error in 488ms (ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 3.7ms)
ohm-website-web-1  |
ohm-website-web-1  |
ohm-website-web-1  |
ohm-website-web-1  | ActionView::Template::Error (couldn't find file 'map-styles/dist/ohm.styles' with type 'application/javascript'
ohm-website-web-1  | Checked in these paths:
ohm-website-web-1  |   /app/app/assets/config
ohm-website-web-1  |   /app/app/assets/favicons
ohm-website-web-1  |   /app/app/assets/images
ohm-website-web-1  |   /app/app/assets/javascripts
ohm-website-web-1  |   /app/app/assets/opensearch
ohm-website-web-1  |   /app/app/assets/stylesheets
ohm-website-web-1  |   /app/vendor/assets/iD
ohm-website-web-1  |   /app/vendor/assets/javascript
ohm-website-web-1  |   /app/vendor/assets/jquery
ohm-website-web-1  |   /app/vendor/assets/leaflet
ohm-website-web-1  |   /app/vendor/assets/polyfill
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/teaspoon-1.4.0/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/teaspoon-1.4.0/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/doorkeeper-5.7.1/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/doorkeeper-5.7.1/vendor/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/i18n-js-3.9.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/bootstrap_form-5.4.0/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/jquery-rails-4.6.0/vendor/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/turbo-rails-2.0.11/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actiontext-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actiontext-7.2.2/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actioncable-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/activestorage-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actionview-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /app/config
ohm-website-web-1  |   /app/node_modules
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/popper_js-2.11.8/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/bootstrap-5.3.3/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/bootstrap-5.3.3/assets/javascripts
ohm-website-web-1  |   /app/test/javascripts
ohm-website-web-1  |   /app/test/javascripts/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/teaspoon-mocha-2.3.3/lib/teaspoon/mocha/assets):
ohm-website-web-1  |
ohm-website-web-1  | Causes:
ohm-website-web-1  | Sprockets::FileNotFound (couldn't find file 'map-styles/dist/ohm.styles' with type 'application/javascript'
ohm-website-web-1  | Checked in these paths:
ohm-website-web-1  |   /app/app/assets/config
ohm-website-web-1  |   /app/app/assets/favicons
ohm-website-web-1  |   /app/app/assets/images
ohm-website-web-1  |   /app/app/assets/javascripts
ohm-website-web-1  |   /app/app/assets/opensearch
ohm-website-web-1  |   /app/app/assets/stylesheets
ohm-website-web-1  |   /app/vendor/assets/iD
ohm-website-web-1  |   /app/vendor/assets/javascript
ohm-website-web-1  |   /app/vendor/assets/jquery
ohm-website-web-1  |   /app/vendor/assets/leaflet
ohm-website-web-1  |   /app/vendor/assets/polyfill
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/teaspoon-1.4.0/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/teaspoon-1.4.0/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/doorkeeper-5.7.1/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/doorkeeper-5.7.1/vendor/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/i18n-js-3.9.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/bootstrap_form-5.4.0/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/jquery-rails-4.6.0/vendor/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/turbo-rails-2.0.11/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actiontext-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actiontext-7.2.2/app/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actioncable-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/activestorage-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/actionview-7.2.2/app/assets/javascripts
ohm-website-web-1  |   /app/config
ohm-website-web-1  |   /app/node_modules
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/popper_js-2.11.8/assets/javascripts
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/bootstrap-5.3.3/assets/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/bootstrap-5.3.3/assets/javascripts
ohm-website-web-1  |   /app/test/javascripts
ohm-website-web-1  |   /app/test/javascripts/stylesheets
ohm-website-web-1  |   /var/lib/gems/3.1.0/gems/teaspoon-mocha-2.3.3/lib/teaspoon/mocha/assets)
ohm-website-web-1  |     1: <% content_for :head do %>
ohm-website-web-1  |     2:   <%= javascript_include_tag "index" %>
ohm-website-web-1  |     3: <% end %>
ohm-website-web-1  |     4:
ohm-website-web-1  |     5: <% content_for(:body_class) { "map-layout" } %>
ohm-website-web-1  |
ohm-website-web-1  | app/views/layouts/map.html.erb:2
ohm-website-web-1  | app/views/layouts/map.html.erb:1
ohm-website-web-1  | config/initializers/compressed_requests.rb:27:in `call'
ohm-website-web-1  | config/initializers/cors.rb:9:in `call'

this is specific to pages with the map on it. About, Copyright, other mapless pages work fine. Homepage, /history, /export all fail with the same error

@erictheise

Copy link
Copy Markdown
Author

Did you do a yarn install or rebuild the website container?

@danrademacher

Copy link
Copy Markdown

Did you do a yarn install or rebuild the website container?

I just did my usual practice of switching to the branch/PR I want to test and running docker compose up --build which typically "just works" (though it can take a while).

To confirm, I checked out staging, and confirmed that the same pages that fail on this branch work as expected on staging

Is there some additional step required to run yarn install in a separate CLI for the web container or something?

@erictheise

Copy link
Copy Markdown
Author

Do you have an @openhistoricalmap/map-styles subdirectory under node_modules? If not, yarn install should pick it up. Or you could try running docker compose up --build --no-cache and see if that gets it. I don't run --build that often but when I do I find that often it doesn't pick up fresh changes due to caching.

If the module's been installed then it's a bug.

@danrademacher

Copy link
Copy Markdown

Tried this docker compose up --build --no-cache and that doesn't run (unknown flag), but did the following:

docker compose build --no-cache
docker compose up

Got the same result:
image

Lookimg at the build log, I see this:

=> [ 2/11] RUN apt-get update   && apt-get install --no-install-recommends -y   build-essential   curl   default-jre  184.4s
 => [ 3/11] RUN npm install --global yarn                                                                                6.5s
 => [ 4/11] RUN mkdir -p /app                                                                                            0.3s
 => [ 5/11] WORKDIR /app                                                                                                 0.0s
 => [ 6/11] ADD Gemfile Gemfile.lock /app/                                                                               0.0s
 => [ 7/11] RUN gem update bundler                                                                                       5.3s
 => [ 8/11] RUN bundle install                                                                                         110.8s
 => [ 9/11] ADD package.json yarn.lock /app/                                                                             0.0s
 => [10/11] ADD bin/yarn /app/bin/                                                                                       0.0s
 => [11/11] RUN bundle exec bin/yarn install                                                                            65.1s
 => exporting to image                                                                                                  30.5s
 => => exporting layers                                                                                                 30.5s
 => => writing image sha256:088c07a03746bf846374c2733da1d2a11c2af25f41b391a8dade6c99a7db2914                             0.0s
 => => naming to docker.io/library/ohm-website-web

So it looks to me like bundle exec bin/yarn install is running and not erroring out. Also taking 65 seconds, which seems reasonable.

I then opened a terminal on ohm-website docker container and just did a manual yarn install at the root command prompt to see if that helped. The output was this:

# yarn install
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > @mapbox/[email protected]" has unmet peer dependency "mapbox-gl@>=0.32.1 <2.0.0".
[4/4] Building fresh packages...

Done in 26.32s.
# 

But I still get the same rails error on loading the homepage locally:
couldn't find file 'map-styles/dist/ohm.styles' with type 'application/javascript'

@erictheise

erictheise commented Feb 24, 2025 •

Copy link
Copy Markdown
Author

Although my Mac showed the correct subdirectory (node_modules/@openhistoricalmap/map-styles/) logging into the Docker container still showed an earlier attempt not associated with our organization (node_modules/map-styles/).

I tried to rm -rf node_modules on the Docker container but got a

rm: cannot remove 'node_modules/': Device or resource busy

error. I then tried yarn cache clean, and yarn remove map-styles which failed because that package isn't in package.json. I took another look into node_modules and found it was gone, despite the cannot remove message. A new yarn install brought in the correct npm package.

Nothing yet for you to check out, @danrademacher, I am still documenting what I'm doing in case we need to cherry pick some of these steps later.

@danrademacher

Copy link
Copy Markdown

I just reran the Docker build and confirmed it all now builds without error. We do have some issue with the styles that's different than the green water we had before:
image

I suspect this is a result of some reworking of vector tiles that @Rub21 did and then @tsinn styled, but I'm not 100% sure of that. Hopefully pushing the latest maps styles to NPM and pulling in here will resolve the issue.

Good news is the build from scratch is confirmed working, no more yarn errors.

@Rub21

Rub21 commented Mar 11, 2025

Copy link
Copy Markdown
Member

@danrademacher we currently remove land layer from osm and create other osm_land provider, seems the npm modules is still pointing to the osm provider, lates version of map-styles is using the osm_land provider https://github.com/OpenHistoricalMap/map-styles/blob/staging/main/main.json#L25C6-L32

danrademacher pushed a commit to OpenHistoricalMap/openhistoricalmap-embed that referenced this pull request Mar 12, 2025
This is pending the merge of OpenHistoricalMap/ohm-website#269 and should be merge only after that change. Note that we will also have a redirect of `main/main.json` to `/historical/historical.json`, so this PR is really about showing what we want people to do, and there should be no downtime
@erictheise
erictheise merged commit 613249a into staging Mar 14, 2025
@erictheise
erictheise deleted the 929-shift-to-npm-approach-map-styles branch March 18, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

big-pr javascript Pull requests that update Javascript code merge-commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants