shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
victorb 2020-09-26T09:39:44.063700Z

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?

victorb 2020-09-26T10:01:13.063800Z

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!

thheller 2020-09-26T10:41:47.064200Z

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

thheller 2020-09-26T10:41:50.064400Z

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

thheller 2020-09-26T10:42:02.064600Z

in your build config

thheller 2020-09-26T10:42:53.064800Z

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

thheller 2020-09-26T10:43:03.065Z

and will replace that with the hashed name

thheller 2020-09-26T10:43:55.065200Z

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

thheller 2020-09-26T10:44:01.065400Z

and use clj-run to trigger the function

victorb 2020-09-26T10:44:22.065800Z

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

victorb 2020-09-26T10:45:12.066Z

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

victorb 2020-09-26T10:46:08.066200Z

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

yenda 2020-09-26T17:34:10.067300Z

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

thheller 2020-09-26T17:58:41.067900Z

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

yenda 2020-09-26T18:04:05.068400Z

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

yenda 2020-09-26T18:04:15.068700Z

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)

thheller 2020-09-26T18:08:44.071200Z

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

thheller 2020-09-26T18:09:02.071700Z

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

yenda 2020-09-26T18:10:28.072200Z

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

yenda 2020-09-26T18:10:36.072500Z

(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"))))