Skip to content

Commit

Permalink
WIP switch to Scala 3; JS linking is not handled properly #51
Browse files Browse the repository at this point in the history
  • Loading branch information
v6ak committed Oct 2, 2023
1 parent 6593612 commit 40c82ca
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RUN \
rm sbt-$(cat /sbt-version).rpm && \
mkdir /project
WORKDIR /project
ENV SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xmx2G -Xms1G"

# This stage can be used for testing whether the build is compatible with fresh versions of JDK and NodeJS/NPM
FROM fedora:latest AS bleeding-edge
Expand Down
18 changes: 12 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import java.io.IOException

val appVersion= "1.0"

lazy val scalaV = "2.13.12"
lazy val scalaV2 = "2.13.12"

lazy val scalaV3 = "3.3.1"

val jqueryName: String = "jquery/2.1.4/jquery.js"

Expand Down Expand Up @@ -58,7 +60,7 @@ lazy val server = (project in file("server")).settings(
version := appVersion,
name := "zbdb-stats-server",
scalacOptions ++= Seq("-deprecation", "-feature"),
scalaVersion := scalaV,
scalaVersion := scalaV2,
scalaJSProjects := Seq(client),
scalaJSStage := FullOptStage,
Assets / pipelineStages := Seq(scalaJSPipeline),
Expand Down Expand Up @@ -116,7 +118,7 @@ lazy val server = (project in file("server")).settings(
jqPlot,
specs2 % Test
),
).enablePlugins(PlayScala, JSDependenciesPlugin, SbtWeb)//.dependsOn(sharedJvm)
).enablePlugins(PlayScala, JSDependenciesPlugin, SbtWeb, WebScalaJSBundlerPlugin)//.dependsOn(sharedJvm)

def toPathMapping(f: File): PathMapping = f -> f.getName

Expand All @@ -126,13 +128,13 @@ lazy val client = (project in file("client")).settings(
version := appVersion,
scalacOptions ++= Seq("-deprecation", "-feature"),
scalaJSStage := FullOptStage,
scalaVersion := scalaV,
scalaVersion := scalaV3,
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) },
scalaJSUseMainModuleInitializer := true,
Test / scalaJSUseMainModuleInitializer := false,
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "2.7.0",
"com.lihaoyi" %%% "scalatags" % "0.12.0",
"com.nrinaudo" %%% "kantan.csv" % "0.7.0",
),

// Some magic required for compatibility with running the website directly from SBT (using Play)
Expand All @@ -155,7 +157,11 @@ lazy val client = (project in file("client")).settings(
jqPlot / "jqplot.highlighter.min.js" dependsOn "jquery.jqplot.min.js",
"org.webjars.bower" % "console-polyfill" % "0.2.2" / "console-polyfill/0.2.2/index.js"
),
).enablePlugins(ScalaJSPlugin, JSDependenciesPlugin, ScalaJSWeb)//.dependsOn(sharedJs)
Compile / npmDependencies ++= Seq(
//"csv-parser" -> "3.0.0",
"csv-parse" -> "5.5.0",
),
).enablePlugins(ScalaJSPlugin, JSDependenciesPlugin, ScalaJSWeb, ScalaJSBundlerPlugin, ScalablyTypedConverterPlugin)//.dependsOn(sharedJs)

/*lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared")).
settings(scalaVersion := scalaV).
Expand Down
6 changes: 3 additions & 3 deletions client/src/main/scala/com/v6ak/zbdb/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ object Parser{
}

def parse(csvData: String, startTime: Moment, totalEndTime: Moment, maxHourDelta: Int, formatVersion: FormatVersion) = {
import kantan.csv._
import kantan.csv.ops._
val fullDataTable: IndexedSeq[IndexedSeq[String]] = csvData.trim.unsafeReadCsv[IndexedSeq, IndexedSeq[String]](rfc)
import typings.csvParse.browserEsmSyncMod.{parse => parseCsv}
val fullDataTable: IndexedSeq[IndexedSeq[String]] = parseCsv(csvData)
.asInstanceOf[js.Array[js.Array[String]]].map(_.toIndexedSeq).toIndexedSeq
val Seq(header1, header2, header3, dataWithTail @ _*) = fullDataTable.drop(formatVersion.headSize)
val (dataTable, footer) = formatVersion.tail.split(dataWithTail.dropWhile(_.head == "").toIndexedSeq)
footer.foreach{fl =>
Expand Down
4 changes: 4 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ addSbtPlugin("org.github.ngbinh" % "sbt-simple-url-update" % "1.0.4")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")

dependencyOverrides += "org.scala-lang.modules" %% "scala-xml" % "2.1.0"

addSbtPlugin("org.scalablytyped.converter" % "sbt-converter" % "1.0.0-beta43")

addSbtPlugin("ch.epfl.scala" % "sbt-web-scalajs-bundler" % "0.21.1")

0 comments on commit 40c82ca

Please sign in to comment.