clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
blak3mill3r 2021-03-13T00:00:41.318Z

@spangler is it possible that your HTML resource isn't included in the uberjar?

blak3mill3r 2021-03-13T00:00:43.318200Z

jar -tvf file_name.jar

blak3mill3r 2021-03-13T00:01:36.319200Z

I don't know luminous but that message seems familiar... when trying to mount the root component with reagent to some container DOM node... a <div id="myapp"></div> for example

blak3mill3r 2021-03-13T00:01:43.319400Z

and that DOM node isn't there

blak3mill3r 2021-03-13T00:03:09.320500Z

it seems like there is no DOM element with the id organism

blak3mill3r 2021-03-13T00:03:53.320900Z

maybe try in your javascript console document.getElementByID("organism") ?

2021-03-13T05:59:53.321800Z

Yeah! It's definitely in the jar

2021-03-13T06:01:44.322300Z

Just checked, document.getElementByID("organism") returns the DOM node

2021-03-13T06:02:46.322800Z

Right, so when (rdom/render [#'game-page] (.getElementById js/document "organism")) gets called, that DOM node does not exist

2021-03-13T06:02:52.323100Z

which means it's being loaded at the wrong time?

2021-03-13T06:03:40.323700Z

But that script tag is at the bottom of the body.... I left it there from the original luminus template

2021-03-13T06:04:19.324200Z

as far as I can tell that's where it's supposed to go, and should ensure the DOM is loaded before the script is run

2021-03-13T06:04:23.324400Z

Kind of baffling

2021-03-13T06:04:33.324700Z

Also: only in the uberjar, not in dev

2021-03-13T07:47:41.325400Z

Okay, I fixed it, though I'm not totally sure how

2021-03-13T07:49:09.326200Z

extreme number of layers going on here

william 2021-03-13T10:19:16.327100Z

is there a tool you would recommend to explore a cljs codebase in general? I would find helpful a tool that showed me the call graph of a function I'm invoking

anonimitoraf 2021-03-13T10:20:02.327200Z

Call hierarchy is supported with clojure-lsp

william 2021-03-13T10:32:10.327600Z

thanks @nicdaoraf! I found the command lsp-treemacs-call-hierarchy, that shows me the hierarchy of who's calling my function successfully (what they call the incoming call hierarchy). The documentation also says that I could get the outgoing call hierarchy (who my function calls) by using the universal argument. But in that case I get the error:

Mar 13, 2021 5:27:17 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 11 more
Caused by: java.lang.UnsupportedOperationException
	at org.eclipse.lsp4j.services.TextDocumentService.callHierarchyOutgoingCalls(TextDocumentService.java:534)
	... 16 more
can you use the outgoing call hierarchy successfully in your cljs projects?

anonimitoraf 2021-03-13T11:06:12.327800Z

> The documentation also says that I could get theย `outgoing`ย call hierarchy (who my function calls) by using the universal argument How do I do this?

william 2021-03-13T11:43:33.328Z

@nicdaoraf it depends on your emacs setup: if you are using spacemacs or doom-emacs, you want SPC u M-x lsp-treemacs-call-hierarchy, if you are using regular emacs C-u is used to activate the universal argument, and then trigger the command as you do usually

anonimitoraf 2021-03-13T12:04:32.328200Z

Cool Yea, I get an error too

anonimitoraf 2021-03-13T12:04:54.328400Z

Mar 13, 2021 11:03:46 PM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError                                                                                                                                                                                          
SEVERE: Unable to invoke no-args constructor for class org.eclipse.lsp4j.CallHierarchyOutgoingCallsParams. Registering an InstanceCreator with Gson for this type may fix this problem.                                                                                          
java.lang.RuntimeException: Unable to invoke no-args constructor for class org.eclipse.lsp4j.CallHierarchyOutgoingCallsParams. Registering an InstanceCreator with Gson for this type may fix this problem.                                                                      
    at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:226)                                                                                                                                                                             
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:210)                                                                                                                                                            
    at com.google.gson.Gson.fromJson(Gson.java:888)                                                                                                                                                                                                                              
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.fromJson(MessageTypeAdapter.java:329)                                                                                                                                                                          
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.parseParams(MessageTypeAdapter.java:249)                                                                                                                                                                       
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:119)                                                                                                                                                                              
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:55)                                                                                                                                                                               
    at com.google.gson.Gson.fromJson(Gson.java:888)                                                                                                                                                                                                                              
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:119)                                                                                                                                                                               
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:114)                                                                                                                                                                               
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:193)                                                                                                                                                                        
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)                                                                                                                                                                                
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)                                                                                                                                                                        
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)                                                                                                                                                                                                   
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)                                                                                                                                                                                                                  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)                                                                                                                                                                                           
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)                                                                                                                                                                                           
    at java.lang.Thread.run(Thread.java:834)                                                                                                                                                                                                                                     
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)                                                                                                                                                                                           
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)                                                                                                                                                                          
Caused by: java.lang.reflect.InvocationTargetException                                                                                                                                                                                                                           
    at java.lang.reflect.Method.invoke(Method.java:566)                                                                                                                                                                                                                          
    at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:50)                                                                                                                                                                                           
    at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:223)                                                                                                                                                                             
    ... 19 more                                                                                                                                                                                                                                                                  
Caused by: java.lang.IllegalArgumentException: Class org.eclipse.lsp4j.CallHierarchyOutgoingCallsParams is instantiated reflectively but was never registered. Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection                                      
    at com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.hubErrorStub(SubstrateAllocationSnippets.java:247)                                                                                                                                                         
    at sun.misc.Unsafe.allocateInstance(Unsafe.java:840)                                                                                                                                                                                                                         
    ... 22 more                    

Harold 2021-03-13T22:21:04.331100Z

Hi! Hope everyone is well. I'd like to shrink my uberjar that goes into our production deployment, and I just noticed that a decent chunk of the .jar is .class files related to the Google Closure javascript compiler. The fully compiled/optimized .js is already fully built in the jar. Would it make snese/is it possible to not include Google Closure stuff in the final jar?

p-himik 2021-03-13T22:21:45.331300Z

You shouldn't mix CLJS build and backend classpaths.

p-himik 2021-03-13T22:22:06.331500Z

Not only in production, but in dev as well.

Harold 2021-03-13T22:23:39.331700Z

That's an interesting thought.

Harold 2021-03-13T22:24:32.331900Z

I use lein. Maybe I need to have some profiles (or something) so that the clojurescript dep doesn't end up in the uberjar (!)

p-himik 2021-03-13T22:25:41.332100Z

Yep, at least one profile - for CLJS building. Use it without profiles for running the backend and with that profile to build/watch CLJS.

p-himik 2021-03-13T22:26:05.332300Z

Of course, it would mean that the CLJS build/watch step will be run on a different JVM.

Harold 2021-03-13T22:26:51.332500Z

I believe that is already the case, this project uses fighweel.main with lein trampoline for the local dev env.

Harold 2021-03-13T22:27:14.332800Z

Thank you for these very helpful thoughts. ๐Ÿ™‡

๐Ÿ‘ 1
Harold 2021-03-13T22:37:31.333100Z

wow, cut my jar in half @p-himik ๐Ÿ‘ - I'd like to subscribe to your newsletter.

p-himik 2021-03-13T22:40:36.333300Z

:D Just forward the word of separate profiles.

Harold 2021-03-13T22:44:47.333500Z

For sure I will! I just cleaned up a bunch of :exclusions / dependency conflicts too. The profiles will be fruitful and multiply.

Harold 2021-03-13T22:46:45.333800Z

65% size reduction now.

๐Ÿ‘ 2