@spangler is it possible that your HTML resource isn't included in the uberjar?
jar -tvf file_name.jar
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
and that DOM node isn't there
it seems like there is no DOM element with the id organism
maybe try in your javascript console document.getElementByID("organism")
?
Yeah! It's definitely in the jar
Just checked, document.getElementByID("organism")
returns the DOM node
Right, so when (rdom/render [#'game-page] (.getElementById js/document "organism"))
gets called, that DOM node does not exist
which means it's being loaded at the wrong time?
But that script tag is at the bottom of the body.... I left it there from the original luminus template
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
Kind of baffling
Also: only in the uberjar, not in dev
Okay, I fixed it, though I'm not totally sure how
extreme number of layers going on here
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
Call hierarchy is supported with clojure-lsp
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?> 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?
@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
Cool Yea, I get an error too
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
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?
You shouldn't mix CLJS build and backend classpaths.
Not only in production, but in dev as well.
That's an interesting thought.
I use lein
. Maybe I need to have some profiles (or something) so that the clojurescript dep doesn't end up in the uberjar (!)
Yep, at least one profile - for CLJS building. Use it without profiles for running the backend and with that profile to build/watch CLJS.
Of course, it would mean that the CLJS build/watch step will be run on a different JVM.
I believe that is already the case, this project uses fighweel.main
with lein trampoline
for the local dev env.
Thank you for these very helpful thoughts. ๐
wow, cut my jar in half @p-himik ๐ - I'd like to subscribe to your newsletter.
:D Just forward the word of separate profiles.
For sure I will! I just cleaned up a bunch of :exclusions
/ dependency conflicts too.
The profiles will be fruitful and multiply.
65% size reduction now.