Add js library from npm as dependency to Play 2.0 app
I'm trying to add react-grid-layout to my play 2.0 web app. Firstly, I found web jar for this library and add it to build.sbt. So my sbt looks like as follows:
libraryDependencies ++= Seq( jdbc, cache, ws, specs2 % Test, "org.webjars" %% "webjars-play" % "2.4.0-1", "org.webjars" % "react" % "0.14.0", "org.webjars" % "marked" % "0.3.2", "org.webjars" % "jquery" % "2.1.4", "org.webjars.npm" % "react-grid-layout" % "0.9.1" )
In routes I have
GET /webjars/*file controllers.WebJarAssets.at(file)
All the libraries except react-grid-layout were successfully installed to target/web/web-modules directory. So, I guess the problem is with npm org.webjars.npm .
What should I do to install every js library correctly?
James explains it in the following github issue.
Deployment is manual for all libraries and their dependencies. But this is something that anyone can do with NPM & Bower WebJars. I think a good / easy first step with this is to present a list of missing transitive dependencies when a deployment finishes. That would make it easy for someone to walk through the tree to manually deploy everything.
He later adds:
It is possible that the WebJar you are trying to use is failing because of missing transitive dependencies. This usually happens when libraries are missing required metadata so they can't be imported into Maven Central. It is an unfortunate situation but there isn't much we can do to fix it. The alternative is to use Classic WebJars instead. Info on creating Classic WebJars: http://www.webjars.org/contributing
Check the full github issue linked above for the full conversation.