How to troubleshoot JS dependencies between webjar

2019-07-11 03:31发布

问题:

I've been using scalajs-dom v 0.8.1 and trying to mix webjars within my SBT project. When I do this, I'm getting one final ambiguous JS reference that I can't figure out. I think it is between the webjars I want to use (that include jquery v 2.1.4) and scala-js. I tried using the ManifestFilters SBT filter but it does not seem to help (or I don't know the correct syntax). Does anyone have a useful way to debug these kinds of errors? (see below for SBT output when issuing the 'fastOptJS' task)

[error] - Ambiguous reference to a JS library: jquery.js
[error]   Possible paths found on the classpath:
[error]   - META-INF/resources/webjars/jquery/2.1.4/dist/jquery.js
[error]   - META-INF/resources/webjars/jquery/2.1.4/src/jquery.js
[error]   originating from: spJS:compile, spJS:compile

回答1:

Specifying the specific subpath for jquery.js should disambiguate when pulling down webjar dependencies.

jsDependencies += "org.webjars" % "jquery" % "2.1.4" / "dist/jquery.js"

see: https://github.com/scala-js/scala-js/issues/1496