Fork me on GitHub
#shadow-cljs
<
2020-09-26
>
victorb09:09:44

The docs for :module-hash-names explains I should probably use the generated manifest.edn with it, but can't seem to find any ways of not having to manually (or write a script for it) replace the path in my index.html to the fingerprinted bundle. Is there no option for this?

victorb10:09:13

Ended up adding some sed and jet commands to my deploy file to workaround in the meantime. But would be happy to hear if this is build-in somewhere!

thheller10:09:47

I wrote a proof-of-concept a while ago that can do this

thheller10:09:50

:build-hooks
   [(shadow.html/copy-file
      "out/demo-browser/index.src.html"
      "out/demo-browser/public/index.html")]

thheller10:09:02

in your build config

thheller10:09:53

expects to find a <script src="/js/main.js"> if you build config has :asset-path "/js" :modules {:main ...}

thheller10:09:03

and will replace that with the hashed name

thheller10:09:55

or you could replace the bash file you have and write it entirely in clojure

thheller10:09:01

and use clj-run to trigger the function

victorb10:09:22

oooh, the build-hooks stuff is just what I was looking for! Thanks!

victorb10:09:12

if I had the time I'd send you a PR to add the build-hooks example to right after where it says "it gets a little bit more complicated to include them in your HTML" in the docs

victorb10:09:08

otherwise, cheers for shadow-cljs! Minimal hassle so far 🙏

yenda17:09:10

Is there a workaround for transit-cljs compilation warning besides turning warning as error to false in release builds?

thheller17:09:41

@yenda :warnings-as-errors {:ignore #{transit.*}} I believe?

yenda18:09:05

thanks, actually I realize it's not coming from transit-cljs but from this snippet in our code base

(deftype DefaultHandler []
  Object
  (tag [this v] "unknown")
  (rep [this v] (pr-str v)))

yenda18:09:15

Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)
{:warning :infer-warning, :line 8, :column 1, :msg "Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)"}
ExceptionInfo: Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)

thheller18:09:44

hmm yeah I don't know why that warns but had that in my own code

thheller18:09:02

didn't have time to look into it but (set! *warn-on-infer* false) is a quickfix until then 😉

yenda18:09:28

actually not sure if it's better or not but I got rid of it by typehinting

yenda18:09:36

(deftype ^js DefaultHandler []
  Object
  (tag [this v] "unknown")
  (rep [this v] (try
                  (str v)
                  (catch :default e
                    (when goog.DEBUG
                      (log/warn "Transit was unable to encode a value."))
                    "UNENCODED VALUE"))))