erikerlandson/coulomb

cross-compile for scala.js

erikerlandson opened this issue · 16 comments

I know absolutely nothing about scala.js or its ecosystem.

If I'm lucky, sbt-crossproject would allow me to fake this.
https://github.com/portable-scala/sbt-crossproject

I could try to do this, I've done a bunch of scala.js projects and we may need coulomb

@cquiroz if you want to take a stab at it, please feel free! I'm hoping it's mostly additional targets in sbt, and corresponding in travis ci

It is blocked on spire that hasn't been released yet for scala.js 1.0

Looks like the "real" problem is the archival of machinist
typelevel/spire#888 (comment)

@cquiroz I believe spire 0.17.0-RC1 is building with scalaJS 1.x

Yes, I'm waiting for a release

scala-steward updated to spire 0.17.0-RC1, which I merged, so if you rebase from develop ScalaJS 1.x should in theory work now

Yes I'm updating the build, will send a PR soon

Actually I found a show stopper. coulomb uses WeakTypeTags which aren't available on scala.js. I'm not very familiar with them, I dont know if coulomb could use something else

I can try ClassTag
scala-js/scala-js#50 (comment)

Mostly I'm using them to provide default names based on the name of a type.

Another possible approach would be to not support defaults that require WeakTypeTag or TypeTag, or not support them in scala.js - the code would need some refactoring to support that kind of dual functionality.

Or possibly punt to macros. those are supported IIUC

Maybe a dedicated implicit GetTypeName, that could punt to a macro or just invoke WeakTypeTag. I was excited about getting rid of the scala-2.x macros and I'm not eager to bring them back, but maybe if they were only invoked for scala.js ... ?

Scala's support for "conditional compilation" is pretty awkward, but I see people do it.

If we are ultimately forced to use macros, this is nice and compact.
https://stackoverflow.com/a/15649874/3669757

@tpolecat sugested to use shapeless Typeable to get the names. Some uses are in libs that are jvm only like pureconfig thus we wouldn't need to change them

I can try todo it and make sure they'd run in scala.js

@tpolecat sugested to use shapeless Typeable to get the names.

Sounds like a good approach, shapeless is already a dependency. If it works, I'm happy to use it everywhere. I recently migrated everything to WeakTypeTag for consistency.

It might be worth using a shim GetTypeName in case this needs to be changed yet again in the future. GetTypeName could call Typeable for now.

closing with #97
QuantityParser and its deps are not supported in scalaJS in their current form, that will require a future redesign