Skip to content

refactor: bundle all vendor deps into spotmap-map.js, drop copy-deps#44

Merged
techtimo merged 2 commits into
mainfrom
claude/automate-js-build-copy-VKLpZ
Apr 15, 2026
Merged

refactor: bundle all vendor deps into spotmap-map.js, drop copy-deps#44
techtimo merged 2 commits into
mainfrom
claude/automate-js-build-copy-VKLpZ

Conversation

@techtimo

@techtimo techtimo commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Imports Leaflet, all plugins (fullscreen, GPX, EasyButton, TextPath, BeautifyMarker, Swiss tile layer), Font Awesome, and custom CSS directly in src/map-engine/index.ts so webpack packs everything into the single build/spotmap-map.js + build/spotmap-map.css output
  • Deletes scripts/copy-deps.js and eliminates the public/ vendor subdirectories entirely
  • Removes all separate wp_enqueue_script/wp_enqueue_style calls for Leaflet and plugins from class-spotmap-public.php
  • Assigns window.L = L after import so future Leaflet plugins loaded as separate <script> tags still find the global
  • Disables webpack performance.hints to suppress bundle-size warnings

Why

WordPress caching/optimisation plugins were reordering or concatenating the previously separate Leaflet script tags and breaking the dependency chain. Bundling everything into one file eliminates that entire class of issues and simplifies the build.

Test plan

  • npm run build completes without errors
  • Map renders correctly on the frontend (markers, GPX tracks, tile layers)
  • Swiss tile layer (leaflet-tilelayer-swiss) works
  • Fullscreen button, EasyButton controls visible
  • Font Awesome icons render on markers
  • Block editor live preview still works (uses window.Spotmap)
  • No JS console errors on map pages

Import Leaflet, all plugins, Font Awesome, and custom CSS directly in
src/map-engine/index.ts so webpack packs everything into the single
build/spotmap-map.js + build/spotmap-map.css output. This eliminates
the copy-deps.js script and the public/ vendor subdirectories entirely.

window.L is explicitly assigned after import so future Leaflet plugins
loaded as separate <script> tags still find the global, matching the
behaviour of the old enqueue-based approach.

Fixes a class of issues where WordPress caching/optimisation plugins
reorder or concatenate the previously separate Leaflet script tags and
break the dependency chain.

https://claude.ai/code/session_01AAsqtsybGk9VPJ4FmggxBC
@codecov

codecov Bot commented Apr 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@techtimo techtimo merged commit 13f7197 into main Apr 15, 2026
3 checks passed
@techtimo techtimo deleted the claude/automate-js-build-copy-VKLpZ branch April 15, 2026 10:27
techtimo added a commit that referenced this pull request Apr 15, 2026
…44)

* refactor: bundle all vendor deps into spotmap-map.js, drop copy-deps

Import Leaflet, all plugins, Font Awesome, and custom CSS directly in
src/map-engine/index.ts so webpack packs everything into the single
build/spotmap-map.js + build/spotmap-map.css output. This eliminates
the copy-deps.js script and the public/ vendor subdirectories entirely.

window.L is explicitly assigned after import so future Leaflet plugins
loaded as separate <script> tags still find the global, matching the
behaviour of the old enqueue-based approach.

Fixes a class of issues where WordPress caching/optimisation plugins
reorder or concatenate the previously separate Leaflet script tags and
break the dependency chain.

https://claude.ai/code/session_01AAsqtsybGk9VPJ4FmggxBC

* fix global var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant