soundscape-community / soundscape-web-client

Intelligent navigation on any platform
MIT License
2 stars 2 forks source link

JS Webpacking #13

Closed mlammon11 closed 2 days ago

mlammon11 commented 3 months ago

Reason:

Changes:

steinbro commented 3 months ago

I played around with this, and made a few meaningful changes:

  1. There are two separate JS entrypoints, for index.html and replay_gpx.html, so I updated the webpack config accordingly.
  2. I changed the instructions for running the dev server, to use a tool that builds and live-updates the webpack bundle.
  3. I removed the stubs for Leaflet and Turf, in favor of import statements in the specific JS files where they're used. This feels a lot cleaner, as the mysterious global variable L in visual/map.js is now clearly traceable to an import.

There are still a few major show-stoppers here:

  1. The bundles are 800+ KB, which the webpack dev server warns is much larger than recommended (244 KB). The whole point of using webpack was to improve performance, so I was very surprised to see that the current configuration may actually make things worse!
  2. Using a single minified bundle makes stack traces a lot harder to interpret. There might be a way to fix this with sourcemaps or the like, but it's definitely important at this stage in active development to maintain easy debug-ability.

I had assumed that webpack would have sensible defaults that suited our needs. Apologies that this is turning out to be more complicated than anticipated :(

steinbro commented 2 days ago

We started using vite as a build tool, which makes this PR moot. Thanks for your help!