[Update: see latest comment to see npm
is identified as the source of the problem]
I’ve spent the last few afternoons when I have time trying to get ScalablyTyped setup on my scalajs project copied from sjrd’s vitejs template. I’ve looked at the docs, but there is always some mistake in the build.sbt, or someone suggests me to remove things like Compile
in Compile / npmDependencies
while the docs say to include it.
At this point my build.sbt appears to have no errors, but it now results in my entire codebase breaking as it uses scala 3’s whitespace indentation. Things like
class Foo:
val s = 5
are now breaking because it expects { }
instead of :
This is my Metals output
INFO logging to files /Users/john/projects/game/.metals/metals.log
INFO Started: Metals version 1.4.2 in folders '/Users/john/projects/game' for client Cursor 1.93.1.
Initializing Scala Debugger
...
WARN no build target for: /Users/john/projects/game/src/Main.scala
INFO no build target found for /Users/john/projects/game/src/Main.scala. Using presentation compiler with project's scala-library version: 2.12.19
INFO no build target found for /Users/john/projects/game/src/Main.scala. Using presentation compiler with project's scala-library version: 2.12.19
I assume something in my build.sbt
is incorrect and so rendering it unusable by Metals entirely, causing it to default to Scala 2.
this is my build.sbt
import org.scalajs.linker.interface.ModuleSplitStyle
lazy val game = project.in(file("."))
.enablePlugins(ScalaJSPlugin)
.enablePlugins(ScalablyTypedConverterPlugin)
.settings(
scalaVersion := "3.6.2",
Compile / npmDependencies := Seq(
"@types/three" -> "0.171.0"
),
Compile / scalaSource := baseDirectory.value / "src/",
scalacOptions ++= Seq(
"-language:experimental.namedTuples"
),
scalaJSUseMainModuleInitializer := true,
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.CommonJSModule)
.withModuleSplitStyle(
ModuleSplitStyle.SmallModulesFor(List("game")))
},
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.8.0",
)
this is my project/plugins.sbt
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("org.scalablytyped.converter" % "sbt-converter" % "1.0.0-beta44")
I am helpless at this point. Can someone please tell me what simple thing I have wrong in the build.sbt?