PurpleKingdomGames / tyrian

Elm-inspired Scala UI library.
https://tyrian.indigoengine.io/
MIT License
351 stars 26 forks source link

Parcel loses track of source maps #44

Open davesmith00000 opened 2 years ago

davesmith00000 commented 2 years ago

I suspect all that's happening is that parcel keeps moving things around during the build and the browser can't keep up.

There's some suggestion here that we might be able to tell parcel where to look - but my initial stab at this wasn't very fruitful.

https://parceljs.org/features/targets/#sourcemap

davesmith00000 commented 2 years ago

I'm not going to work on this right now.

I had no luck finding an obvious solution using Parcel, but I did have some success with webpack 5, using the scalajs-friendly-source-map-loader webpack plugin.

However you can't use it with the dev server because it complains about paths, you have to build it, and run a static server from the dist folder. Speculate that it might work in webpack 4 maybe? The path warnings seem to be a new thing, but what do I know?

Here is the commit on a branch: https://github.com/PurpleKingdomGames/tyrian/commit/3577283df81391672c468d8718cd9165bf0e3906

In the screenshot below, you can see a tyrian app, running an embedded indigo game, and the profiler is merrily telling us that this bit of the code came from GameLoop.scala:53:4.

image

Clicking on the hyperlinked GameLoop.scala:53:4 will show you the real Scala code, and give you the times spent in running the code there.

Webpack is a lot more hassle than Parcel however, and the experience was far from smooth. So it needs another attempt. It may even be worth writing a Parcel plugin?