I can use jQuery from Scala.js quite well:
jsDependencies += "org.webjars" % "jquery" % "2.2.1" / "jquery.js" minified "jquery.min.js"
Now I would like to use <a href="https://github.com/mishoo/UglifyJS" rel="nofollow">UglifyJS</a> and its webjar structure seems a bit different. There seems to be no minified js file, and even the main file which probably contains the complete library looks different, it has no
.js extension and it starts with following lines:
#! /usr/bin/env node // -*- js -*- "use strict"; var UglifyJS = require("../tools/node");
Can this webjar be used from Scala.js at all, and if it can, how? I have tried following, but it did not work:
jsDependencies += "org.webjars" % "uglifyjs" % "2.7.4" / "bin/uglifyjs"
With this line SBT error was:<blockquote>
[error] (test:resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries could not be resolved:
[error] - Missing JS library: bin/uglifyjs
[error] originating from: scalafromjs:test, scalafromjs:compile</blockquote> Answer1:
Uglify is published as
uglifyjs. Also, a webjar was not created for version 2.7.4, however there is one for 2.7.5.
You can easily request automatic creation of a webjar for 2.7.4 in a few clicks on <a href="http://www.webjars.org/npm" rel="nofollow">http://www.webjars.org/npm</a> if you need it that specific version.
If you go to the webjars website and search for "uglify-js", you'll see the dependency config you need to use:
"org.webjars.npm" % "uglify-js" % "2.7.5" (plus the file you want).
<strong>Note that as of 0.6.14 Scala.js supports npm modules using <a href="https://scalacenter.github.io/scalajs-bundler/getting-started.html" rel="nofollow">scalajs-bundler</a></strong>.
That new system is by far superior to webjars – you have ALL npm modules and versions available, no need to trigger creation yourself (wait till you get into webjar dependencies!), no need to wait for the index to be updated, etc.