scala-js / scala-js-cli

Command Line Interface for the Scala.js compiler and linker
BSD 3-Clause "New" or "Revised" License
5 stars 8 forks source link

Publish via coursier? #38

Open gzm0 opened 2 years ago

gzm0 commented 2 years ago

Follow-up from https://github.com/scala-js/scala-js-cli/pull/35#issuecomment-949943345

sjrd commented 2 years ago

I have at least a sort of proof of concept that coursier could entirely replace our assembly scripts. From an empty directory, the following sequence of commands can produce and run a test.js from a foo.scala, compiled with 2.12.15 and linked with the linker v1.7.1 and the cli v1.0.0 published under _2.13:

$ mkdir bin
$ cat > foo.scala <<'EOF'
object Foo {
  def main(args: Array[String]): Unit = {
    println(s"asdf ${1 + 1}")
    new A
  }

  class A
}
EOF
$ cs launch --scala 2.12.15 scalac:2.12.15 -- -classpath "$(cs fetch --scala 2.12.15 --intransitive org.scala-js::scalajs-library:1.7.1)" "-Xplugin:$(cs fetch --scala 2.12.15 --intransitive org.scala-js:scalajs-compiler_2.12.15:1.7.1)" -d bin foo.scala
$ cs launch org.scala-js:scalajs-cli_2.13:1.0.0 org.scala-js:scalajs-linker_2.13:1.7.1 -M org.scalajs.cli.Scalajsp -- bin/Foo\$.sjsir
module class Foo$ extends java.lang.Object {
  def main;[Ljava.lang.String;V(args: java.lang.String[]) {
    mod:scala.Predef$.println;Ljava.lang.Object;V(("asdf " +[string] 2));
    new Foo$A().<init>;V()
  }
  constructor def <init>;V() {
    this.java.lang.Object::<init>;V();
    mod:Foo$<-this
  }
}
$ cs launch org.scala-js:scalajs-cli_2.13:1.0.0 org.scala-js:scalajs-linker_2.13:1.7.1 -M org.scalajs.cli.Scalajsp -- bin/Foo\$A.sjsir
class Foo$A extends java.lang.Object {
  constructor def <init>;V() {
    this.java.lang.Object::<init>;V()
  }
}
$ cs launch --scala 2.13.6 org.scala-js::scalajs-cli:1.0.0 org.scala-js::scalajs-linker:1.7.1 -M org.scalajs.cli.Scalajsld -- -s -o test.js -mm Foo.main "$(cs fetch --scala 2.12.15 --intransitive org.scala-js::scalajs-library:1.7.1)" bin
$ node test.js 
asdf 2
gzm0 commented 5 months ago

FWIW: This seems to be the chain of forks of this repo that eventually leads into Scala CLI.

https://github.com/scala-cli/scala-js-cli https://github.com/VirtusLab/scala-js-cli