Fork me on GitHub
#shadow-cljs
<
2018-12-19
>
flyboarder00:12:20

@thheller thanks, I thought so - tracked it down. im just pinning what shadow-cljs uses for deps moving forward

kenny00:12:36

Trying to get a new project set up with shadow-cljs. I always forget, what am I supposed to do when I see this message?

No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
After running (shadow.cljs.devtools.api/nrepl-select :app).

jstaab00:12:26

If it's a browser app opening the app in the browser does that for me if I recall correctly

kenny00:12:38

I see all of this output in the console:

shadow-cljs - config: /home/kenny/Forks/bide/shadow-cljs.edn  cli version: 2.7.9  node: v6.2.2
WARNING: The org.clojure/clojurescript dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility.
shadow-cljs - starting ...
Dec 18, 2018 4:14:27 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Dec 18, 2018 4:14:27 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - server version: 2.7.9
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 33453
shadow-cljs - nREPL server started on port 9009
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (141 files, 1 compiled, 0 warnings, 1.27s)
I tried connecting to the url in that output http://localhost:9630 but that doesn't help.

jstaab00:12:59

What's your build target?

jstaab00:12:20

You need to visit it before you call nrepl-select I believe, did you try it in that order?

kenny00:12:25

My guess is that's not the correct URL I need to visit. It's not clear what the right URL is though.

kenny00:12:52

https://shadow-cljs.github.io/docs/UsersGuide.html#_connect_the_javascript_environment > For example, for browser development, browse to http://localhost:8080. Where does that URL come from?

jstaab00:12:25

Does 9630 run your app or the shadow cljs console thing?

kenny00:12:32

The console.

jstaab00:12:31

Oh ok, you do need to connect to your app. I feel like I usually see another line in there that shows your app's port

jstaab00:12:55

I usually run shadow-cljs server and shadow-cljs watch app separately if that's any help

kenny00:12:24

All I get from running the former is this:

shadow-cljs server
shadow-cljs - config: /home/kenny/Forks/bide/shadow-cljs.edn  cli version: 2.7.9  node: v6.2.2
shadow-cljs - connected to server
server already running

jstaab00:12:28

Unfortunately, I haven't yet been able to grok shadow's source code so I'm still in black box land, though getting a bit better

jstaab00:12:58

The watch command implicitly starts a server, I just remember being confused by some odd behavior

kenny00:12:05

I have a browser based library that I'd like to open a REPL for -- there's no "app" in the traditional sense.

jstaab00:12:01

Interesting, do you have any modules specified in your shadow-cljs.edn?

jstaab00:12:08

Maybe just paste that file

kenny00:12:21

{:source-paths ["src"]
 :dependencies [[org.clojure/clojurescript "1.10.339" :scope "provided"]]
 :nrepl        {:port 9009}
 :builds       {:app {:target   :browser
                      :modules  {:main {:entries [bide.core]}}}}}

jstaab00:12:16

No output-dir huh

jstaab00:12:22

I got the sense that was required, is there a default?

kenny00:12:45

No idea. If it was required, I'd expect shadow-cljs to tell me that.

jstaab00:12:10

I've noticed it's pretty tolerant to bad configuration though

jstaab00:12:18

Though this one seems like a show stopper

jstaab00:12:57

Yeah, from the docs: https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL

shadow-cljs - HTTP server for ":app" available at 

kenny00:12:38

Why is that line not there for me?

jstaab00:12:59

Couldn't tell ya

jstaab00:12:05

Did you try adding an output-dir?

jstaab00:12:17

All the examples seem to have one, I know it's used for test builds etc

kenny00:12:39

Pretty sure it has a default given it created a public directory in my project.

jstaab00:12:49

ok, that sounds familiar

jstaab00:12:43

Add http-port to your config

jstaab00:12:28

Actually I'm not sure if that would do it, but you might try playing with the server options

kenny00:12:20

I added all of the :devtools stuff

{:source-paths ["src"]
 :dependencies [[org.clojure/clojurescript "1.10.339" :scope "provided"]]
 :nrepl        {:port 9009}
 :builds       {:app {:target   :browser
                      :modules  {:main {:entries [bide.core]}}
                      :devtools {:http-root    "public"
                                 :http-port    3000
                                 :http-handler shadow.http.push-state/handle}}}}
then created an index.html and added script tag that loads the main.js file. That seems like a mighty high barrier to starting a browser REPL 🙂 It'd be cool to see that process simplified for cases like this.

jstaab00:12:59

For sure, though compare to lein-cljsbuild, which is not much simpler, and significantly magicker

jstaab00:12:06

Is it working for you then?

jstaab00:12:32

Nice! Sorry my process was so slow; @thheller could have gotten you sorted much faster, I'm still learning 🙂

kenny00:12:03

Thanks for the help. This seems like it'd make a fantastic addition to the docs. I'll make a note and, if I have time this weekend, submit a PR.

👍 4
kenny00:12:29

Any idea if you can get hot reload of js files?

thheller11:12:31

what do you mean? actual .js files?

kenny00:12:47

It appears any change to a js file requires a browser reload to be picked up.

jstaab00:12:12

Hmmm sounds plausible, maybe you could hack it by establishing your own file watcher and calling a rebuild function

jstaab00:12:23

Haven't had that problem myself

pepe10:12:57

Hi. After upgrading to 2.7.9 my release build fails with this error:

TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
    at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2902)
    at Function.cljs.core.key__GT_js.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:2897)
    at mdc.615F7DC4.js:2901
    at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2904)
    at Function.cljs.core.clj__GT_js.cljs$core$IFn$_invoke$arity$variadic (mdc.615F7DC4.js:2906)
    at Object.cljs.core.clj__GT_js (mdc.615F7DC4.js:2899)
    at Object.sablono.interpreter.attributes (back-office.9160B910.js:2201)
    at Object.sablono.interpreter.element (back-office.9160B910.js:2203)
    at Object.sablono.interpreter.interpret_vec (back-office.9160B910.js:2204)
    at cljs.core.PersistentVector.sablono$interpreter$IInterpreter$interpret$arity$1 (back-office.9160B910.js:2205)
    at Object.sablono.interpreter.interpret (back-office.9160B910.js:2187)
    at Function.<anonymous> (back-office.9160B910.js:9408)
    at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$3 (mdc.615F7DC4.js:1400)
    at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1399)
    at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1422)
    at $class$$jscomp$6_mixins$$ (back-office.9160B910.js:2685)
    at fh (back-office.9160B910.js:112)
    at qg (back-office.9160B910.js:140)
    at rg (back-office.9160B910.js:141)
    at Jd (back-office.9160B910.js:153)
    at Sa (back-office.9160B910.js:152)
    at sg (back-office.9160B910.js:150)
    at Hb (back-office.9160B910.js:148)
    at Ag (back-office.9160B910.js:165)
    at Qe (back-office.9160B910.js:165)
    at sc.render (back-office.9160B910.js:214)
    at back-office.9160B910.js:169
    at yg (back-office.9160B910.js:164)
    at Od (back-office.9160B910.js:169)
    at Object.render (back-office.9160B910.js:216)
    at Object.rum.core.mount (back-office.9160B910.js:2702)
    at Object.my_trees.frontend.back_office.app.start (back-office.9160B910.js:9443)
    at Object.my_trees.frontend.back_office.app.init (back-office.9160B910.js:9448)
    at (index):1

aisamu12:12:06

Have you tried clearing node_modules? We observed a bunch of weird errors updating to 2.7.8 that went away with an rm -rf...

pepe12:12:27

it didn't help

😕 4
pepe10:12:21

It is with the :optimizations :simple

pez11:12:32

@pepe what happens with advanced compilation?

pepe11:12:01

Same error just cryptic 🙂.

thheller11:12:44

@pepe not sure. probably something changed in cljs 1.10.439

pepe11:12:09

Ok. Is there direction you can direct me for investigation please? It seems it has something to dy with keyword creation

thheller11:12:00

not sure. probably hook up JS debugger with pause of exception and try to figure out whats happening

thheller11:12:13

what is undefined when it shouldn't be

pepe14:12:25

It is very strange $keyword_fn$$ is undefined in the clj->js function definition.

pepe15:12:23

Which should be name

pepe15:12:31

And it is on third or fourth time the function is called.

aisamu12:12:06
replied to a thread:Hi. After upgrading to 2.7.9 my release build fails with this error: TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2902) at Function.cljs.core.key__GT_js.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:2897) at mdc.615F7DC4.js:2901 at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2904) at Function.cljs.core.clj__GT_js.cljs$core$IFn$_invoke$arity$variadic (mdc.615F7DC4.js:2906) at Object.cljs.core.clj__GT_js (mdc.615F7DC4.js:2899) at Object.sablono.interpreter.attributes (back-office.9160B910.js:2201) at Object.sablono.interpreter.element (back-office.9160B910.js:2203) at Object.sablono.interpreter.interpret_vec (back-office.9160B910.js:2204) at cljs.core.PersistentVector.sablono$interpreter$IInterpreter$interpret$arity$1 (back-office.9160B910.js:2205) at Object.sablono.interpreter.interpret (back-office.9160B910.js:2187) at Function.&lt;anonymous&gt; (back-office.9160B910.js:9408) at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$3 (mdc.615F7DC4.js:1400) at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1399) at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1422) at $class$$jscomp$6_mixins$$ (back-office.9160B910.js:2685) at fh (back-office.9160B910.js:112) at qg (back-office.9160B910.js:140) at rg (back-office.9160B910.js:141) at Jd (back-office.9160B910.js:153) at Sa (back-office.9160B910.js:152) at sg (back-office.9160B910.js:150) at Hb (back-office.9160B910.js:148) at Ag (back-office.9160B910.js:165) at Qe (back-office.9160B910.js:165) at sc.render (back-office.9160B910.js:214) at back-office.9160B910.js:169 at yg (back-office.9160B910.js:164) at Od (back-office.9160B910.js:169) at Object.render (back-office.9160B910.js:216) at Object.rum.core.mount (back-office.9160B910.js:2702) at Object.my_trees.frontend.back_office.app.start (back-office.9160B910.js:9443) at Object.my_trees.frontend.back_office.app.init (back-office.9160B910.js:9448) at (index):1

Have you tried clearing node_modules? We observed a bunch of weird errors updating to 2.7.8 that went away with an rm -rf...

pepe12:12:38

@aisamu no, I will try. Thank you

koala punch12:12:33

hi, i’m having problems connecting to shadow-cljs repl from cursive

koala punch12:12:43

its trying to run cljs commands in a clj repl

koala punch12:12:50

even though i changed the dropdown, anyone else have this?

thheller12:12:06

the dropdown doesn't mean anything

koala punch12:12:13

btw thheller, it’s a fantastic tool 🙂

thheller12:12:33

in the clj repl you must select the cljs repl of the build

koala punch12:12:44

ah i have to piggyback like in figwheel?

thheller12:12:45

by calling (shadow.cljs.devtools.api/repl :the-build)

thheller12:12:58

that will automatically switch the cursive dropdown as well

koala punch12:12:42

is that in the docs somehwere?

thheller12:12:02

probably not prominent enough but yeah it is

koala punch12:12:30

i couldn’t find it

koala punch12:12:50

is there a trick so i don’thave to type it every time?

thheller12:12:34

create a repl command in cursive and bind it to a key

koala punch12:12:50

excellent, it’s all working now

koala punch12:12:52

calva works out of the box

koala punch12:12:56

cursive seems more fiddly

thheller12:12:59

@achikin does it not also need some Decimal global or so?

thheller12:12:26

@christopher.paul calva as additional support for shadow-cljs. cursive does not (yet)

koala punch12:12:43

yea i noticed 🙂

achikin12:12:38

@thheller it only requires js/Decimal.noConflict in a form of a function.

thheller13:12:19

@achikin right;. but you are not calling that fn so it probably should be (js/goog.exportSymbol "Decimal.noConflict" decimal-js/noConflict)

achikin13:12:49

@thheller as far as I can see from the sources of funcool/decimal

(def ^:static +decimal+ (js/Decimal.noConflict))
(def ^:dynamic *decimal* +decimal+)
I need to provide a function, which can be called by decimal.core

thheller13:12:36

but you are just removing the noConflict call basically

thheller13:12:49

since all you provide is something that returns Decimal

achikin13:12:25

noConflict does basically the same

thheller13:12:50

(js/goog.exportSymbol "Decimal" decimal-js) might also work?

achikin13:12:07

Let me try both of your solutions.

thheller13:12:32

should stay as close as possible to the original without changing semantics

thheller13:12:39

granted I don't know anything about the package

achikin13:12:05

> (js/goog.exportSymbol "Decimal" decimal-js) might also work? I'm not sure about this one because noConflict depends on the global environment of javascript...

achikin13:12:35

I've tried some more simple solutions and it appears that noConflict remains empty...

thheller13:12:39

ah ok. it thats not always available thats fine I guess

achikin13:12:27

I'm not very much into js, and this looks confusing for me

achikin13:12:31

// Export.
  if (typeof window !== 'undefined') {
      globalScope = window;
  } else if (typeof global !== 'undefined') {
      globalScope = global;
  }
  if (!globalScope) {
    globalScope = typeof self != 'undefined' && self && self.self == self
      ? self : Function('return this')();
  }

  noConflict = globalScope.Decimal;
  Decimal.noConflict = function () {
    globalScope.Decimal = noConflict;
    return Decimal;
  };

  globalScope.Decimal = Decimal;
})(this);

achikin13:12:49

I think in my case it sets globalScope.Decimal properly, but not globalScope.Decimal.noConflict

achikin13:12:58

And as soon as funcool tries to access noConflict instead of the Decimal directly - that does not always work properly...

pepe14:12:25

It is very strange $keyword_fn$$ is undefined in the clj->js function definition.

lilactown19:12:08

there’s no way to reference an edn file in the source path, is there?

thheller19:12:54

probably better to load it at runtime. otherwise a macro can do that although not recommended.