Fork me on GitHub
#shadow-cljs
<
2018-12-14
>
justinbarclay16:12:14

So I've run into a problem with requiring an npm module, "auth0-js", that the files it produces aren't named the way that shadow-clj expects. Instead of being "auth0-js.js", the files are just called "auth0.js". https://github.com/auth0/auth0.js/blob/master/package.json Are there any work -a-rounds for this?

thheller16:12:43

@emoarmy not sure what you mean. it doesn't matter to shadow-cljs at all.

thheller16:12:07

(:require ["auth0-js" :as ajs])

justinbarclay16:12:05

Ok, sorry. I'm going to look into this more on my end. It looks like I was misreading an error message.

justinbarclay18:12:07

I think I’ve found my issue… I have a require statement as such:

(ns 
  (:require ["auth0-js" :as ajs]))
But when I run shadow-cljs watch frontend This error pops up in my console: "shadow.js.js:87 shadow-cljs - failed to load module$node_modules$auth0_js$dist$auth0_min" I think what’s happening is that the “auth0-js” is getting converted to “auth0_js”, but npm doesn’t follow the naming convention where a - translate to a folder structure with an _. I’ve got a repo here to recreate the issue: https://github.com/justinbarclay/auth0-js-bug

thheller19:12:42

@emoarmy the error has absolutely nothing to do with the generated filename

thheller19:12:14

it just tells you that it failed to load that file because of some error that occured while loading the file

thheller20:12:03

cannot read property lib of undefined is that error

thheller20:12:00

try :js-options {:variable-renaming :local} in your build config

thheller20:12:42

auth0-js will always be renamed to auth0_js since auth0-js is auth0 - js in javascript since - is an operator

justinbarclay20:12:02

Awesome! That worked wonderfully, thank you for your time!

justinbarclay20:12:59

Is this config used directly by the closure compiler? I’m wondering where else I should be looking next time I run into an issue like this

thheller20:12:02

normally you shouldn't need any of those options. the defaults should work. I know for a fact that setting this :variable-renaming :local will break other JS libs

thheller20:12:13

but yes that is a closure compiler option when transforming the JS code