diff --git a/src/main/scala/cloud/golem/GolemScalaPlugin.scala b/src/main/scala/cloud/golem/GolemScalaPlugin.scala index a4697c0..315f8f8 100644 --- a/src/main/scala/cloud/golem/GolemScalaPlugin.scala +++ b/src/main/scala/cloud/golem/GolemScalaPlugin.scala @@ -6,8 +6,21 @@ import sbt.plugins.JvmPlugin object GolemScalaPlugin extends AutoPlugin { object autoImport { - lazy val golemScalaWitPath = settingKey[File]("Path to the wit file") - lazy val golemScalaPackageName = settingKey[String]("Package name") + lazy val golemScalaOutputDirectory = SettingKey[File]( + "golemScalaOutputDirectory", + "Output directory", + KeyRanks.Invisible + ) + lazy val golemScalaWitPath = SettingKey[File]( + "golemScalaWitPath", + "Path to the wit file", + KeyRanks.Invisible + ) + lazy val golemScalaPackageName = SettingKey[String]( + "golemScalaPackageName", + "Package name", + KeyRanks.Invisible + ) lazy val witBindgen = taskKey[Unit]("Runs golem-scalajs-wit-bindgen to generate WIT bindings") lazy val component = diff --git a/src/main/scala/cloud/golem/GolemScalaPluginInternal.scala b/src/main/scala/cloud/golem/GolemScalaPluginInternal.scala index 108c60e..02d55e3 100644 --- a/src/main/scala/cloud/golem/GolemScalaPluginInternal.scala +++ b/src/main/scala/cloud/golem/GolemScalaPluginInternal.scala @@ -14,6 +14,7 @@ private[golem] object GolemScalaPluginInternal { lazy val baseSettings: Seq[Setting[?]] = Def.settings( + golemScalaOutputDirectory := target.value / "dist", golemScalaWitPath := (ThisBuild / baseDirectory).value / "wit", golemScalaPackageName := "main", witBindgen := { @@ -36,6 +37,8 @@ private[golem] object GolemScalaPluginInternal { lazy val scalaJsSettings: Seq[Setting[?]] = Def.settings( scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) }, + Compile / fullLinkJS / scalaJSLinkerOutputDirectory := golemScalaOutputDirectory.value, + Compile / fastLinkJS / scalaJSLinkerOutputDirectory := golemScalaOutputDirectory.value, libraryDependencies += "cloud.golem" %% "golem-scala-macros" % Versions.macros ) diff --git a/src/sbt-test/golem-scala/example1/test b/src/sbt-test/golem-scala/example1/test index fb5bbf1..a1e038a 100644 --- a/src/sbt-test/golem-scala/example1/test +++ b/src/sbt-test/golem-scala/example1/test @@ -1,12 +1,12 @@ > +clean > +fullLinkJS -$ exists target/scala-2.12/root-opt/main.js -$ exists target/scala-2.12/root-opt/main.js.map -$ exists target/scala-2.13/root-opt/main.js -$ exists target/scala-2.13/root-opt/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map > +clean > +fastLinkJS -$ exists target/scala-2.12/root-fastopt/main.js -$ exists target/scala-2.12/root-fastopt/main.js.map -$ exists target/scala-2.13/root-fastopt/main.js -$ exists target/scala-2.13/root-fastopt/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map diff --git a/src/sbt-test/golem-scala/example2/test b/src/sbt-test/golem-scala/example2/test index fb5bbf1..a1e038a 100644 --- a/src/sbt-test/golem-scala/example2/test +++ b/src/sbt-test/golem-scala/example2/test @@ -1,12 +1,12 @@ > +clean > +fullLinkJS -$ exists target/scala-2.12/root-opt/main.js -$ exists target/scala-2.12/root-opt/main.js.map -$ exists target/scala-2.13/root-opt/main.js -$ exists target/scala-2.13/root-opt/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map > +clean > +fastLinkJS -$ exists target/scala-2.12/root-fastopt/main.js -$ exists target/scala-2.12/root-fastopt/main.js.map -$ exists target/scala-2.13/root-fastopt/main.js -$ exists target/scala-2.13/root-fastopt/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map +$ exists target/dist/main.js +$ exists target/dist/main.js.map