Fork me on GitHub
#clojurescript
<
2018-05-10
>
maleghast17:05:05

Hello All... Anyone seen this or something like it and able to give me any pointers on what to do about it - code builds on my local machine, but when I updated the repo on the remote machine to demo for my colleagues this happened when I tried to build my ClojureScript...

ERROR: JSC_DUPLICATE_EXTERN_INPUT. Duplicate extern input: file:/home/ec2-user/.m2/repository/cljsjs/react/15.5.4-0/react-15.5.4-0.jar!/cljsjs/react/common/react.ext.js at (unknown source) line (unknown line) : (unknown column)

maleghast17:05:44

App built before - this seems to be because of adding recharts or leaflet (via cljsjs) into the dependencies for the app as that is the only real change apart from code that clearly parses / runs, in that my local machine has no trouble with it.

mfikes17:05:30

@maleghast This is Google Closure complaining

maleghast17:05:20

Yeah, I figured, but I don't understand why when the same code is compiling on my local machine

mfikes17:05:44

Hrm. All I can say is, not enough info to provide any help IMHO.

maleghast17:05:51

That's fair, but I really don't know what info I could supply that would help...

maleghast17:05:44

My honest confession is that my actual__ understanding of the tooling around the Java and Google Closure underpinnings of Clojure and ClojureScript is next to non existent.

maleghast17:05:21

Most of the time that is not a problem - I stick to well-trodden paths, popular libraries and I stick to as stable versions of things as I can find.

maleghast17:05:02

However... Sometimes I really cannot avoid but use something a little more obscure, and the problem is almost always a "works on my machine, not on the server" problem

justinlee17:05:24

i’m going to make a wild guess that react is being included twice because you added a cljsjs library that probably required a different version. does lein deps-tree (or whatever that command is) show any conflicts?

justinlee17:05:45

i only say that because it seems to happen a lot of with cljsjs

maleghast17:05:15

Here's where I make another admission - I'm using clojure.tools and it's my first outing without the leiningen or boot "safety-net"

maleghast17:05:04

I tried running the production build on my local machine and I get the same error, so I am going to assume that the "dev-mode" build is less strict and / or less optimised and that's why it's working

dnolen17:05:22

the problem is simple

dnolen17:05:42

externs are provided twice, but you’re saying that advanced builds locally are working for you?

maleghast17:05:06

@dnolen - No, I've just tried the advanced build locally and that fails

maleghast17:05:17

I should have tried that first before committing my code

dnolen17:05:29

what @lee.justin.m suggested is the right thing to look at

maleghast17:05:33

I am pretty sure that "dev-mode" does not use the advanced optimisations

dnolen17:05:00

check your dep tree

maleghast17:05:29

OK, going to have to figure out how to do that without Lein / Boot... *goes off to Google*

justinlee17:05:30

@maleghast the other thing you can do is just add exclusions to the new cljsjs things you included. (I’m not sure how to do that with your setup because I use shadow-cljs, but somehow you should be able to exclude react and react-dom which should fix this problem if that’s what it is)

maleghast17:05:31

@lee.justin.m - Thanks that may well solve the issue, though in the same vein I am going to figure out how I do that in a deps.edn file, 'cos this is all new to me.

maleghast17:05:16

I am pretty sure that it's a dependency from recharts that is doubling up the externs, so I will start there.

dnolen17:05:54

@maleghast aren’t you using tools.deps?

dnolen17:05:03

yes, I see you are

dnolen17:05:07

clj -h is your friend

maleghast17:05:09

@dnolen - Er, yes... I am building on top of the new verison of juxt/edge and it uses the new deps tools from 1.9 and has not Boot or Leiningen anywhere near it.

dnolen17:05:17

clj -Stree

dnolen17:05:23

will show you the dep tree

maleghast17:05:39

Ok, thanks - my Google-fu was failing me...

dnolen17:05:58

no need to google, the docs are there with -h flag

maleghast17:05:31

yeah, I am a bad Unix person; I find the docs one gets on the command line hard to follow / grok (gosh this thread is turning into a Geek Confessional)

maleghast17:05:48

OK, I think I have it... ReCharts uses cljsjs/react-with-addons 15.5.4-0 Reageant (0.7.0) uses cljsjs/react 15.5.4-0 They must be clashing with one another, right?

Alex Miller (Clojure team)17:05:29

they have different lib names so both will be included

maleghast17:05:32

I see that, but I think that the former uses the same externs file as the latter, hence the error message that started all of this (^^) referring to "cljsjs/react/common/react.ext.js"

maleghast18:05:05

(edited above to show the libraries / deps I actually meant to show)

Alex Miller (Clojure team)18:05:24

well you’re past my knowledge at that point :)

maleghast18:05:08

Well past my own, Sir - I am all about the guesswork at this point.

maleghast18:05:40

I think__ that I need to figure out how to exclude one of them so that the error goes away under advanced compilation.

maleghast18:05:39

My other thought is that a newer version of the ReCharts package on cljsjs might__ have different, more compatible deps... I am going to go and look at that too...

dnolen18:05:16

@maleghast just remove the react dep, react-with-addons is enough

dnolen18:05:23

you can do this with an exclusion

maleghast18:05:12

ok the react dep is from Reagent, so I need an exclusion on that ?

maleghast18:05:18

(FWIW, updating the ReCharts dep does allow it all to build, but I am concerned that ReCharts latest version is based on React 16.x and that makes me nervous when my Reagent version is 0.7.0 so React 15.x)

justinlee18:05:09

I don’t think reagent 0.7.0 will work with react 16, but 0.8.0 has been released, so if you wanted to try to bump to react 16, you could try that. I suspect many react libraries will work even if you upgrade react out from under them. You definitely need to keep adding exclusions until you only include one version of react. Probably the most straightforward is to let reagent include what it needs and then exclude react from all of your libraries.

maleghast18:05:34

@lee.justin.m - Yeah, the problem is that the older version of ReCharts I was using relied on react-with-addons, so excluding that because it was not playing nice with react in advanced compilation would not work at all...

maleghast18:05:47

I am going to try bumping Reagent up to 0.8.0 as well and see if that works as that will take my core / foundational React up to 16.x and then as you say I can exclude react from anything that deps on 15.x on the basis that they should be able to get what they need from 16.x

justinlee18:05:35

i don’t know enough about the addons package to know if you can get recharts to work on react 16

justinlee18:05:49

it seems like addons has been deprecated and split into other modules

justinlee18:05:18

you might actually have a better chance of letting recharts be the master of ceremonies and exclude react from everything else (including reagent)

justinlee18:05:45

i’m assuming here that cljsjs/react-with-addons includes react. hard to tell without downloading and inspecting

justinlee18:05:13

this is where i make my obligatory nudge towards shadow-cljs which eliminates these woes

maleghast18:05:55

@lee.justin.m - Updating ReCharts and Reagent removes the issue and my app runs as expected. I think I will go with that; seeing as Reagent 0.8.0 is stable I should probably be building on it anyway. Thanks for the help, I think if things were not ok under Reagent 0.8.0 I would absolutely go the route you just described ^^ Also, thanks @dnolen for demystifying the deps tree stuff - I appreciate that a LOT.

maleghast18:05:02

Gotta go, my dinner is getting cold 🙂

justinlee18:05:31

all’s well that ends well 🙂