0

I would like to use sbt-web and scala-js to create a webjar. So far I have added the artifactPaths of the scala-js artifacts to the mappings in Assets. This does work if I call fastOptJS and the files show up in the correct webjar location.

However, I would like to have the assets generated upon compile. The problem is, that I get circular dependencies whenever I add a task dependency on fastOptJS here. I can not add fastOptJS to resourceGenerators or sourceGenerators, neither can I add a dependency to compile because of the circular dependencies.

It is not an option to trigger fastOptJS from another project.

Is there a solution to this?

Martin Ring
  • 5,404
  • 24
  • 47
  • Note, that this is not a duplicate of "How can scala-js integrate with sbt-web?" because that question is talking about multi project setups – Martin Ring Feb 10 '16 at 08:41
  • Could you show what you have tried, which results in circular dependencies? – sjrd Feb 10 '16 at 09:06
  • @sjrd there are many options to get the circular dependency. The main problem ist that `fastOptJS` and `fullOptJS` depend on `fullClasspath` which is only available after everything is done. So adding e.g. `fastOptJS` to `resourceGenerators in Assets` will lead to circular dependency. – Martin Ring Feb 10 '16 at 09:16
  • Oh. Are you trying to put the Scala.js project in the *same* sbt project as the sbt-web project? That's never going to work. You cannot do this. You need a separate sbt project for the Scala.js code. – sjrd Feb 10 '16 at 09:52
  • @sjrd but it does work already when i call fastOptJS manually. the main problem is, that i can not add fastOptJs to the resourceGenerators because it depends on fullClasspath. I just want scalajs code and css and html and so on in one project. I don't like client assets in the server project. – Martin Ring Feb 10 '16 at 10:03
  • It's just not how it's supposed to work. The generation of .js code *needs* `fullClasspath`. There's a reason it depends on it. Even if `compile` was made to emit .js code, then `compile` would need `fullClasspath`. There is just no way around that. If you don't like client assets in the server project, then you need 3 projects: one server, one assets, and one Scala.js client. – sjrd Feb 10 '16 at 16:42

0 Answers0