Fork me on GitHub

hey everyone, I am having a problem with the Closure compiler and I am not sure if this is a bug or not. If I pass a node.js library through it the output code is no longer valid (i.e. with nodejs target it removes certain symbols which are required so it complains about it being undefined later on). However if I use webpack to bundle it into a single js file and then give it to the Closure compiler it works properly (with browser target). Is this a bug in the node.js parsing ? should I report it or am I doing something wrong :thinking_face: ?


@U0LJU20SJ You can try changing the :optimizations level to :simple


I didnt even set an optimization level and from what I see in the documentation it defaults to :none which is why I am wondering about it


I have a clojurescript project that pretty much defines Interfaces only. But then I have one function (defn add-renderer [kw func] ...) that is used by other projects in order to add renderers to the application. Now my Problem is that the implementation of add-renderer brings along all kind of dependencies. So I would like to implement that function in the main application and in the interface project just define it via (define add-renderer). Is this possible? I guess I cannot override the namespace to add the implementation. Any ideas?


How are the main and interface projects communicating with another? Is the interface one a library being used by the main one?


So basically I have a Notebook app that renders Notebooks


Then I have the Renderable project which defines the Interfaces and this function


And then I have UI Plugin projects that define tenderers that only reference Renderable


1. Renderable: (interfaces and add-renderer) has no dependencies


2. UI Plugin: refer to Renderable


3. Notebook: refer Renderable and UI Plugin


I also have a Dynamic clojurescript bundler, so if this idea works then I will have to change structure to:


1. Renderable


2. RenderableImpl


3. UI Plugin


4. Notebook


You could make add-interface dynamic and define it with your actual implementation from the main application. I think it'd look something like this:

;; make dynamic var in interface library
(def ^:dynamic *add-interface* (fn [& _] (prn "Oops! Must overwrite add-interface")))

;; in other parts of project

(defn add-interface [] (prn "rebound"))

(binding [*add-interface* add-interface]
  (*add-interface*)) ;; prints 'rebound'

(*add-interface*) ;; prints "Oops!..."


if you weren't in Clojurescript I'd suggest taking a look at however, I don't think the equivalent function is in cljs.


I think the cleanest solution could be to avoid re-binding vars, and just pass the add-renderer function into your library as an argument.

(defn my-add-renderer [] ...)

(interface.lib/some-function my-add-renderer ...)


I like your last idea! I just have to figure out a way to determine when a library was loaded. Basically the UI Plugins register Keyword / function combinations that extended normal hickup Syntax. Currently they do so in the project itself. So if I change the interface to (available-renderers kw func) then this could be called by the Notebook.


The first approach I don't think will work.. because the rebinding appears not to be available globally.. and my UI Plugins need to call the register function directly. So I guess they always see the mock implementation


If anybody might find it useful, basically dead code finder for cljs I put together last week. Pretty much in testing stage, got some good results on larger codebases. Would appreciate feedback shall you give it a try on your project!