ClojureScript-Lib and my ClojureScript on the same page

Suppose I have a small web application and want to use a third-party library that comes with an already compiled version of ClojureScript.

As a user of this library, I have to include this generated Javascript file in my HTML page.

<script src="/javascript/gen/lib.js" type="text/javascript"> 

So far so good. Everything is working fine.

But since my web application needs some kind of external magic, I wanted to include my own ClojureScript. So I wrote a couple of lines, compiled them in Javascript and added another line in the HTML header:

 <script src="/javascript/gen/lib.js" type="text/javascript"> <script src="/javascript/gen/my-stuff.js" type="text/javascript"> 

This is where it gets ugly. I get this error in javascript console:

Error: Namespace "goog.debug.Error" already declared.

After an error in this error, I get several pages that claim that I cannot use several Google Closure Compiled things on one page. See SO: Multiple ClojureScript Files on One Page

So how do I solve this situation? On the one hand, I already have a Google Closure compiled lib, and on the other, my ClojureScript stuff. How can I get one (or two) compiled Javascript files?

Would it be easier if this third-party lib provided an uncompiled version of ClojureScript?

+4
source share
1 answer

Yes, it would be easier if a third-party library provided an uncompiled version of ClojureScript. Then you will require it and use it from your code and compile it all together. The ClojureScript compiler, requiring each dependency once (even common dependencies) and the Google Closure compiler, will perform its optimization throughout the code.

Try to find the library in Clojars or pack it as a jar to use from the existing ClojureScript setting. (If the library is open source, give us a link and we will help you)

0
source

All Articles