Fork me on GitHub
#shadow-cljs
<
2020-07-29
>
sova-soars-the-sora10:07:47

Well i'm stumped. I have a super simple component, optimizations make it not work. will try to slim it down to the bare essentials.

thheller11:07:52

happy to take a look if you make a reproducible example

sova-soars-the-sora12:07:14

thank you my man, guess what. rum doesn't know what to do with :on-submit .... instead, example code for rum uses

#?(:cljs 
 (defn- textarea-keydown [callback]
  (fn [e]
    (if (and (== (.-keyCode e) 13) ;; enter
             (not (.-shiftKey e))) ;; no shift
      (do
        (callback (.. e -target -value))
        (set! (.. e -target -value) "")
        (.preventDefault e))))))
to submit on a :textarea which it would appear solves my problem i think...

sova-soars-the-sora12:07:43

good news: clojurescript is the greatest again.

grounded_sage16:07:51

Not sure if it is how I am running shadow or the cljs side. But I am getting undeclared var on macro’s when I run shadow-cljs watch app. But if I paint up a repl and connect to browser environment the macros seems to work fine.

thheller16:07:28

hard to tell without seeing code 😛

Eric Ihli19:07:13

Don't see much in the docs about source maps other than the config option that defaults to true during development. I'm getting an exception and it's reporting line 600+ in a 200-line file. Curious if this means I have something mis-configured or it I'm not understanding when source-maps come into play. My assumption was that when an exception occurred, I could click on the link in the dev console and it would take me to the clojurescript file, not the compiled javascript file. That's not the case. Instead, when I click on the line in the exception, bitstamp.js:631, it opens a new tab in Firefox and I get an alert that the line can't be found. I try typing in a line that I know exists and it still can't be found. In fact, the tab opens to view-source: but it's an empty page. No code lines. Nothing. Not sure what the expected behavior is because I've never known my environment to work any other way. But this feels wrong. It's a fairly barebones project.

{:dev-http {8008 ["classpath:public"]}
 :nrepl {:port 9999
         :middleware []}
 :deps true
 :builds
 {:main {:target :browser
         :output-dir "resources/public/js/main"
         :asset-path "js/main"
         :modules {:main {:entries [com.owoga.bitstamp]
                          :init-fn com.owoga.bitstamp/init}}
         :devtools {:repl-init-ns cljs.user
                    :console-support false
                    :after-load com.owoga.bitstamp/refresh
                    :repl-pprint true}}}}

Eric Ihli19:07:14

The file does exist and it does look like it has source map annotations.

➜  my-project tail resources/public/js/main/cljs-runtime/com.owoga.bitstamp.js
com.owoga.bitstamp.refresh = (function com$owoga$bitstamp$refresh(){
taoensso.timbre._log_BANG_.cljs$core$IFn$_invoke$arity$10(taoensso.timbre._STAR_config_STAR_,new cljs.core.Keyword(null,"info","info",-317069002),"com.owoga.bitstamp",null,330,new cljs.core.Keyword(null,"p","p",151049309),new cljs.core.Keyword(null,"auto","auto",-566279492),(new cljs.core.Delay((function (){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["Re-rendering root."], null);
}),null)),null,1062859293);

return reagent.dom.render.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [com.owoga.bitstamp.order_book], null),document.getElementById("order-book"));
});
goog.exportSymbol('com.owoga.bitstamp.refresh', com.owoga.bitstamp.refresh);

//# sourceMappingURL=com.owoga.bitstamp.js.map

thheller20:07:05

maybe try setting :devtools {:loader-mode :script}

thheller20:07:57

or maybe just :asset-path "/js/main". relative paths are problematic sometimes if you use any kind of push-state routing or so

Eric Ihli13:07:36

Just confirmed it is loader-mode :script that fixes it. Tried each individually and together. Get success with just loader-mode script.

dehli23:07:46

hello! is it possible to have shadow watch a release build? when building with traditional clj, you could do:

(require '[cljs.build.api :as b])
(b/watch "src"	
         {:main 'handlers.core	
          :output-dir "out/"	
          :output-to "build/js/main.js"	
          :optimizations :simple	
          :target :nodejs})

dpsutton23:07:23

That is running optimizations simple. Seems to defeat the purpose? It’s not really a release build at that point.