Fork me on GitHub

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)


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.


@maleghast This is Google Closure complaining


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


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


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


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.


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.


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


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?


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


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


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


the problem is simple


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


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


I should have tried that first before committing my code


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


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


check your dep tree


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


@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)


@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.


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


@maleghast aren’t you using tools.deps?


yes, I see you are


clj -h is your friend


@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.


clj -Stree


will show you the dep tree


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


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


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)


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


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"


(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 :)


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


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


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...


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


you can do this with an exclusion


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


(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)


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.


@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...


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


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


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


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


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


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


@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.


Gotta go, my dinner is getting cold 🙂


all’s well that ends well 🙂