This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-19
Channels
- # aws-lambda (1)
- # babashka (3)
- # beginners (97)
- # cider (20)
- # clojure (9)
- # clojure-spec (8)
- # clojure-uk (9)
- # clojurescript (25)
- # core-async (2)
- # cryogen (7)
- # cursive (4)
- # fulcro (9)
- # graalvm (14)
- # graphql (8)
- # luminus (2)
- # off-topic (18)
- # pathom (3)
- # re-frame (1)
- # reagent (4)
- # shadow-cljs (36)
- # spacemacs (1)
- # vscode (2)
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?
And then I have UI Plugin projects that define tenderers that only reference Renderable
I also have a Dynamic clojurescript bundler, so if this idea works then I will have to change structure to:
You could make add-interface
dynamic and define it with your actual implementation from the main application.
https://lambdaisland.com/blog/2019-12-09-advent-of-parens-9-dynamic-vars-clojurescript
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 https://clojuredocs.org/clojure.core/intern 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 ...)
Thanks @UCQL6E7PY
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 https://github.com/stacksideflow/cljs-yagni, 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!