These are chat archives for webjars/webjars

13th
Jul 2017
Eric Reichert
@ereichert
Jul 13 2017 01:08
Hi. I'm working with an existing Play application that has previously used webjars without issue. Today I added a dependency on request ("org.webjars.npm" % "request" % "2.81.0"). I wrote the code I needed to get started. Tried to load the application and no joy. In the Chrome console I get a list of JS libs that aren't loading. After investigating it looks like there are bunch of transitive dependencies that aren't loading. So I took a look in target/web/node-modules/main/webjars and the transitive dependencies aren't there either. Which explains why they aren't being loaded. I've never run into this issues with webjars so could this be a problem specific to the request webjar?
James Ward
@jamesward
Jul 13 2017 02:58
You didn't get an sbt build error where transitive deps could not be found?
it's possible that there are missing transitives but the build should not have allowed the app to run in that case
Other possibility is that the transitives exist but the loading of them via commonjs / requirejs / whatever isn't setup correctly.
The tendency with node libraries is to use a module loader to load deps. which is a pain in the web app case.
i think most node devs now use webpack to deal with this
Eric Reichert
@ereichert
Jul 13 2017 13:08
@jamesward I'm back at this today. You're right about the loader being misconfigured for some of the transitive deps. I'm using systemjs and must be doing something wrong. I'm having to do some insane mapping; read the console to see what's not loading, find the entry point for that lib, configure it in the systemjs config.
But even with that, it appears some of the deps are missing and I'm not seeing a build error.
I'll finish this mapping nonsense and see what's up after that.
James Ward
@jamesward
Jul 13 2017 14:53
Yeah, sometimes libs produce a packed / web friendly version. Not sure if that is the case with request. If not, it is definitely painful.
Eric Reichert
@ereichert
Jul 13 2017 14:57
I just posted the following to systemjs's gitter to see if there's a way to change the default behavior which would help tremendously.
Hi. I'm using webjars with the Play Framework. The JS libs are available at "libs/<lib_name>/<lib_name>.js". I have set baseURL to "libs" and defaultExtension = true. That leaves the maps looking like "lib_name": "lib_name/lib_name" because the default systemjs uses (effectively) is just "lib_name": "lib_name.js". Is there a way to change the default behavior so that systemjs will automatically prepend the directory name?
That still wouldn't fix the transitive deps issue I think exists but it would cut down on the boilerplate.