Fork me on GitHub
#shadow-cljs
<
2018-09-22
>
lilactown00:09:24

I'm still running into instances where it's not picking up my defspec after switching to the cljs.test/run-all-tests

lilactown01:09:15

I ended up adding the hack to the clojure.test.check defspec macro

Jakub Holý (HolyJak)06:09:32

Hello! I have noticed that https://shadow-cljs.github.io/docs/UsersGuide.html#_repl_2 says to use :devtools {:repl-init-ns my.app while https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL says to use :nrepl {:init-ns my.repl}. Are these two the same thing or unrelated? Thanks!

thheller06:09:25

one is for the nrepl CLJ connection and the other is for the build CLJS repl

👍 4
lilactown16:09:48

I’m trying to get started with evaluating some code using cljs.js, but for some reason I can’t use any cljs.core vars

lilactown16:09:21

this is what I’m doing right now:

(defonce !results (atom nil))

(defn print-results [results]
  (reset! !results results))

(cljs/eval-str
 (cljs/empty-state)
 "(def asdf 1)"
 'visual-spec.eval-test
 {:eval cljs/js-eval}
 print-results)

thheller16:09:14

your first time using self-hosted?

thheller16:09:29

you need to "bootstrap" the entire thing and load the analyzer data

lilactown16:09:53

do I need to watch the :bootstrap-support build or just compile it once?

thheller16:09:15

either works. it doesn't support any REPL or live reloading anyways

lilactown16:09:49

do I need to call boot/init on each reload of my code? or is it just called once and then I can keep calling compile-it?

thheller16:09:08

depends on how you manage your state?

lilactown16:09:35

I guess, is there any reason I wouldn’t call boot/init on each hot reload?

thheller16:09:06

I don't know how you manage your state and cannot answer that

thheller16:09:14

you can absolutely call it all the time

thheller16:09:27

but generally I doubt that thats useful

thheller16:09:31

unless your index changes often

lilactown16:09:03

I’m trying to figure out why I would care how my state is managed based on using the shadow-cljs bootstrapper

lilactown16:09:13

what’s “index” in this context?

thheller16:09:43

> The :bootstrap build itself will generate an “index” with useful information for the compiler.

thheller16:09:57

the boostrapper itself doesn't manage any state

thheller16:09:03

(defonce compile-state-ref (env/default-compiler-env))

thheller16:09:09

this is the state that is important

lilactown16:09:11

sorry I skimmed it 😛

thheller16:09:02

if your bootstrap support build doesn't change (eg. you don't watch it) then you probably only need to call boot/init once

thheller16:09:07

I don't do any self-host development myself so I can't really recommend what the best approach would be

thheller16:09:17

no idea if you'd want to reset the compiler-env on every reload or not

lilactown16:09:50

gotcha. I understand now. thank you

lilactown18:09:46

would there be some reason that a build with :module-loader true and then trying to bootstrap would be incompatible?

thheller18:09:06

it depends. self-host can be tricky that way

thheller18:09:12

it won't be aware of module loader at all

lilactown18:09:19

what I’m seeing is that if I add a module that depends on shadow.cljs.bootstrap.browser, it immediately breaks all of my modules

lilactown18:09:45

/assets/js/cljs-runtime/shadow.module.main.append.js:4 Uncaught (in promise) TypeError: Cannot read property 'env' of undefined
    at eval (/assets/js/cljs-runtime/shadow.module.main.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:2188)
    at loadPending (main.js:2957)
    at main.js:2990

thheller18:09:26

ah. the shadow.cljs.boostrap.env ns may have been moved

thheller18:09:32

it must always be in the default module

thheller18:09:18

try adding it to your default module

thheller18:09:25

the one that everything else depends on

lilactown18:09:01

yep. adding [shadow.cljs.bootstrap.env] to the requires in my main module immediately fixed all of my modules

Jakub Holý (HolyJak)18:09:47

Hello! I get this in my trivial browser app, in Chrome Console: > main.js:1 Uncaught ReferenceError: SHADOW_ENV is not defined where main.js is a module compiled by hdow cljs. Any idea why that could be?

thheller18:09:21

hmm do you use more than one module?

Jakub Holý (HolyJak)18:09:02

Yes, do:

:modules {:shared {:entries []}
          :main {:entries [app.main] :depends-on #{:shared}}
          :brand {:entries [app.templates.brand] :depends-on #{:shared}}}

Jakub Holý (HolyJak)18:09:34

(I am trying to create a separate bundle for my "home" page and my "brand" page so each loads faster)

thheller18:09:44

you must load the shared before main

Jakub Holý (HolyJak)18:09:54

uh, just realized that 🙂 Thanks a lot!

Jakub Holý (HolyJak)18:09:56

BTW what does > assets/index.html(please link it to target/index.html) looks like: in the Begginner Guide mean? Should I ln -s ../assets/index.html inside target or what?

Jon16:09:10

I should fix...

Jon16:09:02

I'm changing it to "copy". do you think it being easier to understand?

thheller19:09:11

@holyjak I can't find that anywhere in the guide? what are you referring to? https://shadow-cljs.github.io/docs/UsersGuide.html?