Fork me on GitHub
#shadow-cljs
<
2021-09-24
>
Michaël Salihi07:09:42

Before start to writing a script, is Shadow-cljs manage to clean up the output directory (remove all cljs-runtime, etc) after releasing an app?

thheller07:09:19

you mean like rm -rf public/js? no it does not

Michaël Salihi07:09:40

Not really. I mean when releasing process run, is there already an option to remove production useless files/directories like cljs-runtime before deploying. This dir size is over 60Mb for my project.

Michaël Salihi07:09:08

In public/js/cljs-runtime

thheller07:09:30

I just run rm and then shadow-cljs release app

Michaël Salihi07:09:58

I think I saw a few things going on about this a while ago.

thheller07:09:00

rimraf from npm is also useful. shadow-cljs itself does not have anything to delete stuff

thheller07:09:33

sure you can write a hook if you really must do that from within shadow-cljs but I don't see the point personally so there is nothing

Michaël Salihi07:09:40

Yeah write a hook would be overkill. 🙂 Thanks

ishodge09:09:46

is it possible to use d3-graphviz with shadow, and if so would that require any additional configuration for compiling wasm? i’m getting an error that localhost:8080/js/graphvizlib.wasm is not found, and further warnings that wasm streaming compile failed: TypeError: WebAssembly: Response has unsupported MIME type 'text/plain' expected 'application/wasm' and falling back to ArrayBuffer instantiation .

thheller14:09:15

shadow-cljs does not support compiling or bundling wasm. something its enough to manually copy the wasm file to some location though

thheller14:09:29

can't say for that lib. don't know what it looks like

ishodge14:09:16

i see, thanks!

metehan13:09:53

shadow-cljs can't find the namespace I put all info together. any idea what may cause the problem? (message was long moved to thread)

metehan13:09:36

[email protected]:~/dev/react-native/scforward$ npx shadow-cljs watch app
shadow-cljs - config: /home/r/dev/react-native/scforward/shadow-cljs.edn
shadow-cljs - server version: 2.15.10 running at 
shadow-cljs - nREPL server started on port 34207
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "" is not available.

####### Folder structure ####### 
├── react-native
│   ├── android
│   ├── ios
│   ├── app
│   ├── App.js
│   ├── app.json
│   ├── babel.config.js
│   ├── index.js
├── shadow-cljs.edn
├── src
│   ├── scforward
│   │   └── app.cljs
│   └── test
└── yarn.lock

####### shadow-cljs.edn ####### 
{:dependencies
 [[reagent "0.8.0-alpha2"]]

 :source-paths
["src/scforward" "src/test"]
 
 :builds
 {:app
  {:target :react-native
   :init-fn 
   :output-dir "react-native/app"
   :js-options {:js-package-dirs ["react-native/node_modules"]}}}}

###### src/scforward/app.cljs ####### 
(ns 
  (:require
    [shadow.react-native :refer (render-root)]
    ["react-native" :as rn]
    [reagent.core :as r]))

;; must use defonce and must refresh full app so metro can fill these in
;; at live-reload time `require` does not exist and will cause errors
;; must use path relative to :output-dir

(defonce splash-img (js/require "../assets/shadow-cljs.png"))

(def styles
  ^js (-> {:container
           {:flex 1
            :backgroundColor "#fff"
            :alignItems "center"
            :justifyContent "center"}
           :title
           {:fontWeight "bold"
            :fontSize 24
            :color "blue"}}
          (clj->js)
          (rn/StyleSheet.create)))

(defn root []
  [:> rn/View {:style (.-container styles)}
   [:> rn/Text {:style (.-title styles)} "Hello!"]
   [:> rn/Image {:source splash-img :style {:width 200 :height 200}}]])

(defn start
  {:dev/after-load true}
  []
  (render-root "scforward" (r/as-element [root])))

(defn init []
  (start))

thheller14:09:40

your :source-paths needs to be adjusted

metehan14:09:08

thank you it's solved

myguidingstar16:09:42

any tips to migrate away from :libs (aka Google closure style ns) to shadow-cljs?

thheller18:09:49

just put it into your classpath and use it?

thheller18:09:05

if you named everything correctly it just works without additional config