bloop link is not able to link Scala.js projects without a main class. It reports the following error:
> bloop link root
[E] No main classes defined in project 'root'
However, Scala.js projects do not always need to have a main class: for instance, a valid use-case is to have no main class, but have methods with @JSExport annotations in order to export functionality to JavaScript code.
Reproduction
I created a simple project with a small build.sbt config:
Bug description
bloop link
is not able to link Scala.js projects without a main class. It reports the following error:However, Scala.js projects do not always need to have a main class: for instance, a valid use-case is to have no main class, but have methods with
@JSExport
annotations in order to export functionality to JavaScript code.Reproduction
I created a simple project with a small
build.sbt
config:The project only contains a single Scala file, which
JSExport
s a single hello world function:If I run
sbt fastOptJS
, sbt produces a bundle from which JS code can import things:Running
bloop compile root
works as expected, butbloop link root
produces the following output:Here is the generated Bloop configuration:
```json { "version": "1.4.0", "project": { "name": "root", "directory": "/home/maxime/code/tmp", "workspaceDir": "/home/maxime/code/tmp", "sources": [ "/home/maxime/code/tmp/src/main/scala-2.12", "/home/maxime/code/tmp/src/main/scala", "/home/maxime/code/tmp/src/main/java", "/home/maxime/code/tmp/target/scala-2.12/src_managed/main" ], "dependencies": [ ], "classpath": [ "/home/maxime/.sbt/boot/scala-2.12.10/lib/scala-library.jar", "/home/maxime/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.12/1.1.0/scalajs-library_2.12-1.1.0.jar" ], "out": "/home/maxime/code/tmp/.bloop/root", "classesDir": "/home/maxime/code/tmp/.bloop/root/scala-2.12/classes", "resources": [ "/home/maxime/code/tmp/src/main/resources", "/home/maxime/code/tmp/target/scala-2.12/resource_managed/main" ], "scala": { "organization": "org.scala-lang", "name": "scala-compiler", "version": "2.12.10", "options": [ "-Xplugin:/home/maxime/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-compiler_2.12.10/1.1.0/scalajs-compiler_2.12.10-1.1.0.jar" ], "jars": [ "/home/maxime/.sbt/boot/scala-2.12.10/lib/jline.jar", "/home/maxime/.sbt/boot/scala-2.12.10/lib/jansi.jar", "/home/maxime/.sbt/boot/scala-2.12.10/lib/scala-xml_2.12.jar", "/home/maxime/.sbt/boot/scala-2.12.10/lib/scala-reflect.jar", "/home/maxime/.sbt/boot/scala-2.12.10/lib/scala-library.jar", "/home/maxime/.sbt/boot/scala-2.12.10/lib/scala-compiler.jar" ], "analysis": "/home/maxime/code/tmp/target/streams/compile/bloopAnalysisOut/_global/streams/inc_compile_2.12.zip", "setup": { "order": "mixed", "addLibraryToBootClasspath": true, "addCompilerToClasspath": false, "addExtraJarsToClasspath": false, "manageBootClasspath": true, "filterLibraryFromClasspath": true } }, "java": { "options": [ ] }, "test": { "frameworks": [ { "names": [ "org.scalacheck.ScalaCheckFramework" ] }, { "names": [ "org.specs2.runner.Specs2Framework", "org.specs2.runner.SpecsFramework" ] }, { "names": [ "org.specs.runner.SpecsFramework" ] }, { "names": [ "org.scalatest.tools.Framework", "org.scalatest.tools.ScalaTestFramework" ] }, { "names": [ "com.novocode.junit.JUnitFramework" ] } ], "options": { "excludes": [ ], "arguments": [ ] } }, "platform": { "name": "js", "config": { "version": "1.1.0", "mode": "debug", "kind": "none", "emitSourceMaps": false, "jsdom": false, "toolchain": [ ] }, "mainClass": [ ] }, "resolution": { "modules": [ { "organization": "org.scala-lang", "name": "scala-library", "version": "2.12.10", "configurations": "default", "artifacts": [ { "name": "scala-library", "path": "/home/maxime/.sbt/boot/scala-2.12.10/lib/scala-library.jar" }, { "name": "scala-library", "classifier": "sources", "path": "/home/maxime/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.10/scala-library-2.12.10-sources.jar" } ] }, { "organization": "org.scala-js", "name": "scalajs-library_2.12", "version": "1.1.0", "configurations": "default", "artifacts": [ { "name": "scalajs-library_2.12", "path": "/home/maxime/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.12/1.1.0/scalajs-library_2.12-1.1.0.jar" }, { "name": "scalajs-library_2.12", "classifier": "sources", "path": "/home/maxime/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.12/1.1.0/scalajs-library_2.12-1.1.0-sources.jar" } ] }, { "organization": "org.scala-lang", "name": "scala-library", "version": "2.12.10", "configurations": "optional", "artifacts": [ { "name": "scala-library", "path": "/home/maxime/.sbt/boot/scala-2.12.10/lib/scala-library.jar" }, { "name": "scala-library", "classifier": "sources", "path": "/home/maxime/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.10/scala-library-2.12.10-sources.jar" } ] } ] }, "tags": [ "library" ] } } ```.bloop/root.json