Fork me on GitHub
#shadow-cljs
<
2018-09-26
>
mattly00:09:35

yeah I saw that one

mattly00:09:53

I might just stay with cljsjs for this one anyway

thheller07:09:50

@mattly that is just a warning that the dynamic require won't be resolved. do you get an actual related error?

thheller07:09:22

also looks like the language-service thing is meant to run in node? are you sure that its supposed to work in the browser?

thheller07:09:08

which cljsjs package is that? or which npm package for that matter? codemirror-graphql?

mattly17:09:43

@thheller the cljsjs package I'm using on the lein version of the project is [cljsjs/graphiql "0.9.3-0"]

mattly17:09:04

and that pulls in codemirror

mattly17:09:43

anyway IDK what's going on with it necessarily, but when I pull in the "graphiql" npm module via (:require ["graphiql" :default GraphiQL]) I get some other compilation errors. Which I assumed to be related to the warning.

thheller17:09:31

depends. what errors do you get?

thheller17:09:59

I can try myself later

mattly17:09:00

hm, I'm having different errors this morning

thheller17:09:43

it compiles and loads fine for me. do I have so call something to trigger the error?

mattly17:09:35

I was getting an error attempting to mount the GraphiQL react componnet

thheller17:09:51

["graphiql" :as GraphiQL]

thheller17:09:54

its not a default export

mattly17:09:36

now I'm getting Uncaught ReferenceError: process is not defined for React's prop-types module

mattly17:09:32

which, I have a very similar app working otherwise and I'm not seeing any material differences in their shaddow-cljs.edn files

thheller17:09:30

@mattly which version are you on?

mattly17:09:05

of shadow-cljs? react?

thheller17:09:10

shadow-cljs

mattly17:09:26

looks like 2.6.6 according to package.json

thheller17:09:35

I have prop-types in my current build so that should work

mattly17:09:51

yeah I think something else is going on here

mattly17:09:06

here's the full list of errors

thheller17:09:07

the global is not defined stands out. which index.js is that?

mattly17:09:28

cljs-runtime

thheller17:09:56

full path please. cljs-runtime contains all compiled files 😉

mattly17:09:12

I apparently only get it on mouseover

thheller17:09:37

you can click it on the console

thheller17:09:08

are you doing any kind of special config for your build? or any other hackery?

mattly17:09:08

yes and then it opens the file but doesn't show me the path

mattly17:09:22

this was straight-up copied from a working project

mattly17:09:40

ok here we go

thheller17:09:43

right click the tab for the source file and copy link

mattly17:09:55

js/cljs-runtime/node_modules/crypto-browserify/index.js

thheller17:09:38

do you use multiple :modules maybe?

mattly17:09:51

... or perhaps js/cljs-runtime/node_modules/buffer/index.js

thheller17:09:00

hmm no those all work fine

thheller17:09:38

since I can import graphiql, react, react-dom just fine it must be something in your setup

thheller17:09:01

ok so its not the config

thheller17:09:19

your html only loads /js/main.js correct?

mattly17:09:31

double-checking on that

mattly17:09:53

emacs is crapping for me right now and I can't quit it yet because of work in-flight on another project

mattly17:09:23

yes, that is the only JS loaded by the html

thheller17:09:28

and there are no other <script> tags that do anything weird? 🙂

mattly17:09:02

nope – only script tags in the doc are the ones loaded by closure

mattly17:09:58

my hunch now is it's some unspoken peer dep of react

thheller17:09:31

do you get warnings on build about npm version conflicts?

thheller17:09:55

can you maybe trim some requires? try adding them one-by-one until it breaks? react-dom,react,graphql,graphiql all work fine for me

thheller17:09:49

check the public/js/cljs-runtime/module$node_modules$object_assign$index.js file please

mattly18:09:23

stripped my main ns down to nothing, no errors

mattly18:09:35

I'm going to slowly start bringing them back in

thheller18:09:14

check the file please. that is where _assign comes from that makes the others fail

thheller18:09:24

just want to check if that file is maybe not what its supposed to be

thheller18:09:11

its minified so it'll look like a mess. just paste it.

thheller18:09:36

ok so thats definitely not correct

mattly18:09:57

perhaps I should just try removing public/js and start over?

thheller18:09:22

did you try {:js-provider :closure} at one point?

mattly18:09:32

yeah I think so

mattly18:09:42

... and then removed it

thheller18:09:51

yeah but that output is from that

😱 4
mattly18:09:03

ok I'm going to clean that directory

thheller18:09:11

don't know why that doesn't get overwritten though

thheller18:09:58

is node_modules maybe on your :source-paths?

mattly18:09:41

OK I'm back to where I was yesterday

mattly18:09:05

with requiring GraphiQL

thheller18:09:01

and those are?

mattly18:09:13

I have this now: (:require ["graphiql" :as GraphiQL]

mattly18:09:32

(js/console.log GraphiQL) does the expected thing and prints the function

mattly18:09:35

...and after changing things like GraphiQL.Toolbar to GraphiQL/Toolbar it works as expected

mattly18:09:39

so it was a require/import problem

mattly18:09:02

GraphiQL's docs tell you to import GraphiQL from 'graphiql'; and so I took this line form the ES6 to require table: import defaultExport from "module-name"; (:require ["module-name" :default defaultExport])

thheller18:09:38

yeah thats icky because it depends on how the package is actually bundled on their end

mattly18:09:49

which seems on par with my experiences so far with node module documentation

mattly18:09:36

anyway, thanks a lot

thheller18:09:38

I kinda want to do what webpack does for this so it works more consistently

mattly18:09:50

yeah, that makes sense

thheller18:09:57

but that might break code for some people so I don't like doing that 😛

thheller18:09:13

also CLJS doesn't officially support :default yet ...

jstaab22:09:53

Hey all, quick question for a relative beginner. How do you usually connect to shadow-cljs' repl (either the socket or nREPL). I'm trying to use unravel localhost port but it seems to be detecting my clj namespaces, not my cljs ones. Also, there's no js namespace. Is there a way to tell it I'm on js? Or, even preferably, is there a way to use rebel-readline with shadow-cljs?

justinlee22:09:13

@jstaab you’ve connected to a clj namespace. from there, type (shadow/nrepl-select :my-app) and I think that’ll bump you into the cljs repl

ClashTheBunny22:09:25

You can access any javascript from cljs.

jstaab22:09:42

Ok, if I do (shadow.cljs.devtools.api/nrepl-select :client) I get

IllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set  clojure.lang.Var.set (Var.java)
        clojure.lang.Var.set (Var.java)
        shadow.cljs.devtools.api$nrepl_select.invokeStatic (api.clj)
        shadow.cljs.devtools.api$nrepl_select.invoke (api.clj)
        shadow.cljs.devtools.api$nrepl_select.invokeStatic (api.clj)
        shadow.cljs.devtools.api$nrepl_select.invoke (api.clj)
        user$eval14469.invokeStatic (unrepl-session)
        user$eval14469.invoke (unrepl-session)
        clojure.lang.Compiler.eval (Compiler.java)
        clojure.lang.Compiler.eval (Compiler.java)
        clojure.core$eval.invokeStatic (core.clj)

ClashTheBunny22:09:10

What is the client build id?

jstaab22:09:58

My shadow-cljs.edn has :builds {:client {...}}, so client? Or the build id something else?

ClashTheBunny22:09:26

No, that seems right.

ClashTheBunny22:09:34

What's the target of that build id?

jstaab22:09:39

If I do (shadow.cljs.devtools.api/nrepl-select :app) I get [:no-worker :app]

jstaab22:09:50

{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]]
 :builds {:client
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"
   :modules {:main {:entries [portal.client.core]}}
   :devtools
   {:http-root "public"
    :http-port 8700}}}}

ClashTheBunny22:09:54

And you have a browser connected?

jstaab22:09:19

Ooh hey maybe that's it, I had a different repl connected, just a sec

ClashTheBunny22:09:47

What if you run (shadow/repl :client)? Is it possible you're trying to bind from a non-nrepl?

jstaab22:09:49

hmm nope I connected to the right port, same thing

jstaab22:09:03

no such namespace shadow

ClashTheBunny22:09:28

do :repl/quit to exit the current repl and try again?

jstaab22:09:55

Are you assuming rebel or unravel? That looks like a rebel command

ClashTheBunny22:09:10

It's a shadow-cljs command.

jstaab22:09:11

In rebel, here's what I get:

user=> (shadow.cljs.devtools.api/nrepl-select :client)
ClassNotFoundException shadow.cljs.devtools.api  java.net.URLClassLoader.findClass (URLClassLoader.java:381)

ClashTheBunny22:09:37

How did you connect rebel to shadow-cljs?

jstaab22:09:07

clj -m rebel-readline.main for rebel, (haven't figured out how to connect to nrepl/socket repl yet); unravel localhost 57282 for unravel, that's the socket repl port

ClashTheBunny22:09:52

What command did you use to start shadow?

jstaab22:09:01

shadow-cljs watch client

ClashTheBunny22:09:43

I usually start it with shadow-cljs clj-repl and then I bounce into the different repls.

jstaab22:09:46

Huh, ok I'll give that a try. Does that command give you a repl directly or do you still have to connect? I thought I had tried that

jstaab22:09:26

Oh hey it does work

jstaab22:09:11

Ok, maybe a bit closer, now I get:

[1:0]~shadow.user=> (shadow/nrepl-select :client)
[:no-worker :client]

jstaab22:09:34

Does watch client have to be running at the same time?

ClashTheBunny22:09:04

You have to connect a browser, which does require a build (shadow/once :client)

ClashTheBunny22:09:12

Or (shadow/watch :client)

ClashTheBunny22:09:05

When you connect your browser, it will allow you to connect to the cljs repl.

jstaab22:09:59

Okay, closer:

rlwrap shadow-cljs clj-repl
shadow-cljs - config: /Users/jstaab/Desktop/cc/portal/shadow-cljs.edn  cli version: 2.6.10  node: v8.4.0
shadow-cljs - starting ...
Sep 26, 2018 3:29:46 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Sep 26, 2018 3:29:46 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :client available at 
shadow-cljs - server version: 2.6.10
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 59883
shadow-cljs - nREPL server started on port 59885
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[1:0]~shadow.user=> (shadow/watch :client)
[:client] Configuring build.
[:client] Compiling ...
:watching
[1:0]~shadow.user=> [:client] Build completed. (162 files, 1 compiled, 0 warnings, 8.57s)

[1:0]~shadow.user=> (shadow/nrepl-select :client)
IllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set  clojure.lang.Var.set (Var.java:223)

jstaab22:09:16

I am connected to the app

jstaab22:09:58

And the server at 9630, still getting the same thing

ClashTheBunny22:09:21

Does (shadow/repl :client) work?

ClashTheBunny22:09:49

Maybe you need to do (shadow/nrepl-select :client) from within nrepl? Have you connected nREPL?

jstaab22:09:57

Got it, I did what the docs said here https://shadow-cljs.github.io/docs/UsersGuide.html#cljs-repl and it worked this time

jstaab22:09:04

Not sure why I wasn't able to get it to go before

ClashTheBunny22:09:09

Not in nrepl or in nrepl?

jstaab22:09:59

Not sure what you mean. I wasn't able to connect to the nrepl from a differnt client (I still get the root binding error on unravel)

jstaab22:09:21

I guess you're the guy to talk to

ClashTheBunny22:09:00

No, I'm just a user. Would love to plug them together, though!

jstaab22:09:16

Me too, rebel is really nice

jstaab22:09:32

Do you use any external repl or just rlwrap with shadow-cljs' built-in repl?

ClashTheBunny22:09:03

rlwrap and built-in

jstaab22:09:32

alrighty, I guess that's where I'm at too then. Thanks for your help!

lilactown23:09:33

it sounds like an issue when using unravel / socket REPL

lilactown23:09:38

might be worth opening an issue

lilactown23:09:27

I typically use Emacs' CIDER or Cursive's integrated REPL personally, which all use nREPL