From 760387092df9c134abbf7e29d7f6335dc0e27fa5 Mon Sep 17 00:00:00 2001 From: Mateusz Starzec Date: Fri, 3 Aug 2018 07:47:51 +0200 Subject: [PATCH 1/5] Remove direct JS dependencies --- README.md | 19 +++++++++++++++++-- build.sbt | 7 ++----- example/build.sbt | 3 ++- example/project/Dependencies.scala | 4 ++++ example/project/build.properties | 2 +- example/project/plugins.sbt | 2 +- project/build.properties | 2 +- project/plugins.sbt | 2 +- 8 files changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9918489..a716941 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ Static types for the jQuery API for [Scala.js](http://www.scala-js.org/) program ## Usage -Add the following to your SBT build: +Add the following dependency to your SBT build: ```scala -libraryDependencies += "io.udash" %%% "udash-jquery" % "1.1.0" +libraryDependencies += "io.udash" %%% "udash-jquery" % "2.0.0" ``` then import the jQuery package: @@ -16,6 +16,21 @@ then import the jQuery package: import io.udash.wrappers.jquery._ ``` +Since version `2.0.0` the wrapper does not force JS dependency on jQuery. You have to +add it manually by: + * explicit link in your `index.html`. + ```html + + ``` + * [Scala.js dependency](http://www.scala-js.org/doc/project/dependencies.html). + ```scala + jsDependencies += + "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" + ``` + + ## Examples ```scala diff --git a/build.sbt b/build.sbt index 090b491..251534e 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ import org.scalajs.jsenv.selenium.SeleniumJSEnv name := "udash-jquery" inThisBuild(Seq( - version := "1.2.0", + version := "2.0.0", organization := "io.udash", scalaVersion := "2.12.6", crossScalaVersions := Seq("2.11.12", "2.12.6"), @@ -58,14 +58,11 @@ val commonJSSettings = Seq( ) libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "0.9.5", + "org.scala-js" %%% "scalajs-dom" % "0.9.6", "org.scalatest" %%% "scalatest" % "3.0.5" % Test, "com.lihaoyi" %%% "scalatags" % "0.6.7" % Test ) -jsDependencies += - "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" - lazy val root = project.in(file(".")) .enablePlugins(ScalaJSPlugin) .settings(commonJSSettings) diff --git a/example/build.sbt b/example/build.sbt index a6221fe..fe054fe 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -1,7 +1,7 @@ name := "jquery-demo" inThisBuild(Seq( - version := "1.2.0", + version := "2.0.0", organization := "io.udash", scalaVersion := "2.12.6", scalacOptions ++= Seq( @@ -31,6 +31,7 @@ val copyAssets = taskKey[Unit]("Copies all assets to the target directory.") val `jquery-demo` = project.in(file(".")).enablePlugins(ScalaJSPlugin) .settings( libraryDependencies ++= Dependencies.deps.value, + jsDependencies ++= Dependencies.jsDeps.value, /* move these files out of target/. */ Compile / fullOptJS / crossTarget := generatedDir, diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 48bac51..82f3448 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -9,4 +9,8 @@ object Dependencies { "io.udash" %%% "udash-core-frontend" % udashCoreVersion, "io.udash" %%% "udash-jquery" % udashJQueryVersion )) + + val jsDeps = Def.setting(Seq[JSModuleID]( + "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" + ) } \ No newline at end of file diff --git a/example/project/build.properties b/example/project/build.properties index c3e3abc..84d4f68 100644 --- a/example/project/build.properties +++ b/example/project/build.properties @@ -1 +1 @@ -sbt.version = 1.1.4 \ No newline at end of file +sbt.version = 1.2.0 \ No newline at end of file diff --git a/example/project/plugins.sbt b/example/project/plugins.sbt index 293d135..a6a5fe1 100644 --- a/example/project/plugins.sbt +++ b/example/project/plugins.sbt @@ -1,3 +1,3 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22") \ No newline at end of file +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.24") \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index c3e3abc..84d4f68 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.1.4 \ No newline at end of file +sbt.version = 1.2.0 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 953c2a1..9ffbb26 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,4 +2,4 @@ logLevel := Level.Warn libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.2.0" -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.24") From 2f2bfafa504fddb035fb7787aa2bcf2a4a0c16f5 Mon Sep 17 00:00:00 2001 From: Mateusz Starzec Date: Fri, 3 Aug 2018 08:02:49 +0200 Subject: [PATCH 2/5] Add JS dependency for tests --- build.sbt | 3 +++ example/project/Dependencies.scala | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 251534e..9cde657 100644 --- a/build.sbt +++ b/build.sbt @@ -63,6 +63,9 @@ libraryDependencies ++= Seq( "com.lihaoyi" %%% "scalatags" % "0.6.7" % Test ) +jsDependencies += + "org.webjars" % "jquery" % "3.3.1" % Test / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" + lazy val root = project.in(file(".")) .enablePlugins(ScalaJSPlugin) .settings(commonJSSettings) diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 82f3448..060c510 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -3,7 +3,7 @@ import sbt._ object Dependencies { val udashCoreVersion = "0.6.1" - val udashJQueryVersion = "1.2.0" + val udashJQueryVersion = "2.0.0" val deps = Def.setting(Seq[ModuleID]( "io.udash" %%% "udash-core-frontend" % udashCoreVersion, @@ -12,5 +12,5 @@ object Dependencies { val jsDeps = Def.setting(Seq[JSModuleID]( "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" - ) + )) } \ No newline at end of file From 2f1ab81bf2d811928250718098d69ef9a2f1a871 Mon Sep 17 00:00:00 2001 From: Mateusz Starzec Date: Fri, 3 Aug 2018 08:18:07 +0200 Subject: [PATCH 3/5] Fix example build --- example/project/Dependencies.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 060c510..1c72400 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -1,4 +1,5 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ import sbt._ object Dependencies { From db9f436772869c38b84bd07448994c9ad7a538af Mon Sep 17 00:00:00 2001 From: Mateusz Starzec Date: Fri, 3 Aug 2018 08:25:40 +0200 Subject: [PATCH 4/5] Publish only for the current Scala version for demo compilation --- .travis.yml | 2 +- example/build.sbt | 1 + example/project/Dependencies.scala | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 632188e..92b85a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,5 +23,5 @@ before_script: script: - sbt ++$TRAVIS_SCALA_VERSION test - - sbt ++$TRAVIS_SCALA_VERSION +publishLocal + - sbt ++$TRAVIS_SCALA_VERSION publishLocal - cd example && sbt ++$TRAVIS_SCALA_VERSION compile fullOptJS \ No newline at end of file diff --git a/example/build.sbt b/example/build.sbt index fe054fe..66c5314 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -4,6 +4,7 @@ inThisBuild(Seq( version := "2.0.0", organization := "io.udash", scalaVersion := "2.12.6", + crossScalaVersions := Seq("2.11.12", "2.12.6"), scalacOptions ++= Seq( "-feature", "-deprecation", diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 1c72400..44cffc7 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -11,7 +11,7 @@ object Dependencies { "io.udash" %%% "udash-jquery" % udashJQueryVersion )) - val jsDeps = Def.setting(Seq[JSModuleID]( + val jsDeps = Def.setting(Seq[org.scalajs.sbtplugin.JSModuleID]( "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" )) } \ No newline at end of file From adbaa2da80ea114a860d7c960ddac59dde78bb9e Mon Sep 17 00:00:00 2001 From: Mateusz Starzec Date: Fri, 3 Aug 2018 09:04:22 +0200 Subject: [PATCH 5/5] Readme improvement --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a716941..c62da25 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ add it manually by: integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"> ``` - * [Scala.js dependency](http://www.scala-js.org/doc/project/dependencies.html). + * or a [Scala.js dependency](http://www.scala-js.org/doc/project/dependencies.html). ```scala jsDependencies += "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js"