Is there a trick to picking up local Javascript files?

238 views
Skip to first unread message

Justin du coeur

unread,
Oct 13, 2014, 7:32:13 PM10/13/14
to scal...@googlegroups.com
I'd like to start using the mechanism described here for including Local Javascript Files -- I've been doing things with script tags, referencing the location of my javascript folder in Play, but would love to include the Javascript libraries in my tests.

I think I'm missing something, though.  I've copied one of my .js files into my resources directory (scalajs/src/main/resources, right next to scalajs/src/main/scala, so I assume this is right?), and added the line:

    jsDependencies += ProvidedJS / "jquery.manifest.js",

to my scalaJSSettings.  It runs okay, but the errors I'm getting are consistent with that file simply not being loaded.

Any ideas of what else might be needed?  The recipe sounds easy in the docs, but seems to just not be happening...

Justin du coeur

unread,
Oct 14, 2014, 9:33:54 AM10/14/14
to scal...@googlegroups.com
I've continued experimenting with this, but no luck -- tried adding the relevant directory explicitly to the unmanagedResourceDirectories in the ScalaJS subproject, but still no sign that the ProvidedJS is doing anything at all.  Does anyone have a working example that uses this mechanism, that I could look at?

Tobias Schlatter

unread,
Oct 15, 2014, 7:20:57 AM10/15/14
to scal...@googlegroups.com
What JS environment are you using? If you are using phantomJS, could you have a look at the HTML runners it generates? (type last in your sbt-shell, the PhantomJS environment will print the temp files it generates on the debug log).

Justin du coeur

unread,
Oct 15, 2014, 9:09:48 AM10/15/14
to Tobias Schlatter, scal...@googlegroups.com
On Wed, Oct 15, 2014 at 7:20 AM, Tobias Schlatter <schlatte...@gmail.com> wrote:
What JS environment are you using? If you are using phantomJS, could you have a look at the HTML runners it generates? (type last in your sbt-shell, the PhantomJS environment will print the temp files it generates on the debug log).

Honestly, my first step was trying to get this working in-browser, in the real running client: I'm trying to move away from hard-coded <script> tags to this instead.  (For various reasons, not least that I suspect this should load faster.)  I hadn't even gotten to the point of trying to exercise it in tests yet.

I'm not seeing any sign that adding the ProvidedJS line is doing anything at all, but I have no idea where I should be looking for signs of it.  (I'm not sure what the meaning of "included" is.  It is clearly *not* getting embedded in my fastopt.js file, if that's the intent.)

Sébastien Doeraene

unread,
Oct 15, 2014, 9:18:45 AM10/15/14
to Justin du coeur, Tobias Schlatter, scal...@googlegroups.com
Hi,

Oh, if it's for the browser, then you need to make sure that you have
skip in ScalaJSKeys.packageJSDependencies := false
in your build file, as is explained in Step 5 of the tutorial. And this creates another .js file that you need to add to your html page with a <script> tag. This is also explained in Step 5 (under the title Adding JavaScript libraries).

Cheers,
Sébastien

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-js/CAO26FW212r0dc126W9oAf__MxyLfDFfu0fqNWsQkN1KMX5%2Bjgw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Justin du coeur

unread,
Oct 15, 2014, 11:10:06 AM10/15/14
to Sébastien Doeraene, Tobias Schlatter, scal...@googlegroups.com
On Wed, Oct 15, 2014 at 9:18 AM, Sébastien Doeraene <sjrdo...@gmail.com> wrote:
Oh, if it's for the browser, then you need to make sure that you have
skip in ScalaJSKeys.packageJSDependencies := false
in your build file, as is explained in Step 5 of the tutorial. And this creates another .js file that you need to add to your html page with a <script> tag. This is also explained in Step 5 (under the title Adding JavaScript libraries).

Ahhh -- yes, that's the clue I was missing.  (Needed a bit more fiddling to get the file to land in the right place, but that's an artifact of the Play! skeleton, which does all kinds of funky SBT stuff.)  Seems to work as expected -- thanks!

Having the process divided across the docs like this (some in depending.html, some in tutorial.html) is a bit confusing; I'll add that as a to-do for a PR, to add a cross-reference so that folks at least realize they need to look back to the tutorial.
Reply all
Reply to author
Forward
0 new messages