Fork me on GitHub
#shadow-cljs
<
2019-12-09
>
gordonk02:12:24

Hi hopefully someone can help me out. I'm experimenting with shadow-cljs potentially to replace boot. I run shadow-cljs watch app (where app is browser target) . I receive the following errors

The required namespace "cljsjs.material-ui" is not available, it was required by "cljs_react_material_ui/core.cljs"
The required namespace "cljsjs.material-ui-svg-icons" is not available, it was required by "cljs_react_material_ui/icons.cljs"
I create the following cljsjs stubs.
(ns cljsjs.material-ui
  (:require ["material-ui" :as material-ui]))
and
(ns cljsjs.material-ui-svg-icons
  (:require ["material-ui-icons" :as material-ui-svg-icons]))
The build now completes successfully. I open up the app and see the following errors in the developer console.
failed to load cljs_react_material_ui.reagent.js ReferenceError: MaterialUI is not defined

failed to load cljs_react_material_ui.icons.js ReferenceError: MaterialUISvgIcons is not defined
I add the following symbols
(js/goog.exportSymbol "MaterialUISvgIcons" material-ui-svg-icons)

(js/goog.exportSymbol "MaterialUI" material-ui)
to their respective stubs, The result is that the MaterialUISvgIcons error disappears in the console but the MaterialUI error does not. Which I find confusing.

mhuebert10:12:35

@gordonk one thing you might try is material-ui/default

superstructor15:12:16

Trying to re-use .shadow-cljs compiler cache between CI builds and found that e.g. 1. rm -rf .shadow-cljs && lein shadow compile karma-test ~10-14s compile 2. lein shadow compile karma-test ~1s compile (i.e. the .shadow-cljs dir left as-is from 1.) 3. Tar up and extract the .shadow-cljs dir results in 10-14s compile again!

tar -cz -f cache.tgz -C .shadow-cljs . 
 rm -rf .shadow-cljs
 mkdir .shadow-cljs
 cd .shadow-cljs
 tar zxf ../cache.tgz
 cd ..
 lein shadow compile karma-test
4. lein shadow compile karma-test ~1s compile (i.e. the .shadow-cljs dir left as-is from 3.) What am I missing that is invalidating the cache ? The tar command used is what GitHub Actions cache action uses to cache files. This would speed up e.g. re-frame CI and all our internal builds by about 30%. @thheller

thheller16:12:56

@superstructor everything related to the source files invalidates the cache. so you also need to "cache" your .m2 maven downloads so that they don't change and also your JS deps in node_modules in case you use any

thheller16:12:37

and changing the timestamps of any of your actual source files too of course

Filipe Silva16:12:20

so any git clone busts it

Filipe Silva16:12:10

maybe <https://stackoverflow.com/a/55609950/2116927> would help?

Filipe Silva16:12:31

the repro above didn't actually use git clone though, I was just overall thinking of how I tried to do the same with GH actions...

Filipe Silva16:12:07

but if git clone will bust the cache for commited source files, and tar will bust the cache for uncommited source files

Filipe Silva16:12:57

then I guess the shadow-cljs cache doesn't do much good in CI?

thheller17:12:07

the timestamps of the cache files themselves don't matter

thheller17:12:09

just having cache for maven based files should already speed things up substantially and that should be easy to do

Hi17:12:09

why these examples launches with shadow-cljs but lacks repl? https://github.com/day8/re-frame/blob/master/docs/CodeWalkthrough.md

Filipe Silva17:12:42

@thheller in the example above, step 3 and 4, it looked like something during the processed of tarring and untarring the shadow-cljs cache busted it

superstructor18:12:16

Correct simply tarring the .shadow-cljs cache files dir, deleting it, then untarring it invalidates the cache. No git, .m2 or source file changes. Is that expected ? @thheller

superstructor18:12:17

@feikas sorry its not well documented but lein shadow supports any command shown by lein run -m shadow.cljs.devtools.cli --help e.g. lein do clean, shadow cljs-repl client

😲 4
superstructor18:12:55

In fact, when I get time I should do a PR to lein-shadow to call shadow.cljs.devtools.cli help directly. At the moment the output of lein shadow --help is not entirely helpful.

4
thheller20:12:20

@superstructor @filipematossilva maybe don't try to tar the entire .shadow-cljs dir. just do .shadow-cljs/builds

thheller20:12:58

maybe lein shadow does something? haven't checked what that does

Aleed21:12:02

if we're using shadow with react native, is there a way to target different platforms - i.e. in js you'd have to have separate file extensions like ios.js , but was hoping maybe we could use reader conditionals like we do for :clj and :cljs

lilactown21:12:38

shadow-cljs has support for custom reader conditionals

lilactown21:12:46

it does require you to have separate builds per platform, though

Aleed21:12:48

wonderful, thanks for the link

Aleed21:12:28

anyone able to run expo web with shadow-cljs? I'm following starter template online (https://github.com/PEZ/rn-rf-shadow) but getting a goog.globalEval not available error when I open browser window. opened up issue there, too: https://github.com/PEZ/rn-rf-shadow/issues/11

thheller21:12:17

@alidcastano that issue is fixed in 2.8.81

🙌 4
Aleed22:12:17

@thheller upgraded to that version but still seeing same error

thheller22:12:27

need to upgrade the deps.edn, the npm package doesn't matter too much

Aleed22:12:26

yea i had upgraded the npm package 😅 thanks