Fork me on GitHub
#clojurescript
<
2021-03-13
>
blak3mill3r00:03:41

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

blak3mill3r00:03:43

jar -tvf file_name.jar

blak3mill3r00:03:36

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

blak3mill3r00:03:43

and that DOM node isn't there

blak3mill3r00:03:09

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

blak3mill3r00:03:53

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

spangler05:03:53

Yeah! It's definitely in the jar

spangler06:03:44

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

spangler06:03:46

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

spangler06:03:52

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

spangler06:03:40

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

spangler06:03:19

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

spangler06:03:23

Kind of baffling

spangler06:03:33

Also: only in the uberjar, not in dev

spangler07:03:41

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

spangler07:03:09

extreme number of layers going on here

Carlo10:03:16

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

anonimitoraf10:03:02

Call hierarchy is supported with clojure-lsp

Carlo10:03:10

thanks @UR37CBF8D! 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?

anonimitoraf11:03:12

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

Carlo11:03:33

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

anonimitoraf12:03:32

Cool Yea, I get an error too

anonimitoraf12:03:54

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                    

Harold22:03:04

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-himik22:03:45

You shouldn't mix CLJS build and backend classpaths.

p-himik22:03:06

Not only in production, but in dev as well.

Harold22:03:39

That's an interesting thought.

Harold22:03:32

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-himik22:03:41

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-himik22:03:05

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

Harold22:03:51

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

Harold22:03:14

Thank you for these very helpful thoughts. 🙇

👍 3
Harold22:03:31

wow, cut my jar in half @U2FRKM4TW 👏 - I'd like to subscribe to your newsletter.

p-himik22:03:36

:D Just forward the word of separate profiles.

Harold22:03:47

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

Harold22:03:45

65% size reduction now.

👍 6