An sbt plugin for rewriting @JSImport
s at linking time in your Scala.js application, à la importmap
. This offers an interesting alternative to using bundlers such as Webpack or Vite: instead, you can lean into browsers' native support for ES Modules while loading your dependencies directly from CDNs such as jsdelivr.
addSbtPlugin("com.armanbilge" % "sbt-scalajs-importmap" % "0.1.0")
enablePlugins(ScalaJSImportMapPlugin)
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.ESModule))
scalaJSImportMap := { (rawImport: String) =>
if (rawImport.startsWith("@shoelace-style/shoelace"))
"https://cdn.jsdelivr.net/npm/" + rawImport
else
rawImport
}