Fork me on GitHub
#shadow-cljs
<
2020-04-25
>
thheller06:04:29

@rberger your http2 problem also popped up in a stackoverflow question. it appears this is a bug in shadow-cljs. the aws package is using browser overrides in a way I thought weren't allowed but I guess they are. will look into fixing that soon.

Spaceman12:04:38

I have a problem with shadow-cljs:

repl/invoke error SyntaxError: Unexpected token '.'
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (browser.cljs:184)
    at eval (browser.cljs:187)
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (env.cljs:117)
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (browser.cljs:187)
    at shadow$cljs$devtools$client$browser$handle_message (browser.cljs:240)
    at eval (env.cljs:196)
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (env.cljs:184)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (env.cljs:197)
    at WebSocket.eval (browser.cljs:340)
shadow$cljs$devtools$client$browser$repl_error	@	browser.cljs:173
shadow$cljs$devtools$client$env$repl_call	@	env.cljs:138
shadow$cljs$devtools$client$browser$repl_invoke	@	browser.cljs:187
shadow$cljs$devtools$client$browser$handle_message	@	browser.cljs:240
eval	@	env.cljs:196
shadow$cljs$devtools$client$env$process_next_BANG_	@	env.cljs:184
shadow$cljs$devtools$client$env$process_ws_msg	@	env.cljs:197
eval	@	browser.cljs:340
This error sometimes occurs when I attempt to load a function in cider, and I find it hard to reach the underlying problem.

thheller12:04:00

well what did you eval?

Spaceman12:04:52

Probably not helpful:

(deftest cart-show-on-click-test
  (db-refresh)
  (user/click-cart-btn)
  (is @sub/cart-shown?)
  )

thheller12:04:16

you can check the browser network tab

thheller12:04:21

the websocket connection

thheller12:04:36

that will contain the message with the code that was eventually eval'd

thheller12:04:50

would help to have that. seems like it may have generated some bad code?

Spaceman12:04:17

Where is the message and code in the network tab?

thheller12:04:11

network tab, filter WS, should be one. then click "messages", there should be multiple

thheller12:04:43

there should be a :type :repl/invoke message

thheller12:04:15

white background is messages coming from the server so would be one of those

Spaceman12:04:12

I see the error message. How do I find the code generated when the function is evaluated?

thheller12:04:41

the message containing :repl/invoke will also have a :js key

thheller12:04:42

thats the code

Spaceman12:04:59

Thanks. I know the underlying problem now.

thheller12:04:11

and what would that be? 😛

Spaceman12:04:24

I had showed you a truncated version of the deftest. The original deftest uses an undefined function. It would be better if shadow can make undefined-kind errors explicit.

thheller12:04:58

I don't know how you got it to generate invalid code

thheller12:04:24

using undefined things should generate warnings and fail with a different kind of error as well

Spaceman12:04:36

Note that the function was defined before and the deftest was fine then.

thheller12:04:21

I don't have enough information so if you want to share the actual code and the actual generated bad code I can take a look

Spaceman12:04:56

That map contains a msg key whose value says:

Use of undeclared Var dom/img-id
How about the msg key's value were shown in the console directly?

thheller12:04:46

it should be. your editor might just not be showing it. mine does.

thheller12:04:51

cljs.user=> (+ 1 foo)
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:6
 Use of undeclared Var cljs.user/foo
--------------------------------------------------------------------------------
##NaN

Spaceman12:04:31

Oh, I didn't know that the message shows in the repl. How about it were shown in the browser console too?

Spaceman12:04:53

By the way, I have required the dom namespace but using dom/img-id gives that dom is not defined.

thheller12:04:38

please be more precise in the reporting of stuff you did

thheller12:04:56

"I have required dom" does not mean anything to me

Spaceman12:04:59

Sorry, I meant I have this

(:require [vendo.workspaces.dom :as dom])
But
dom/img-id
in this namespace gives:
dom is undefined

thheller12:04:50

because if you do this at the REPL (:require [vendo.workspaces.dom :as dom]) you are literally doing a keyword lookup of the vector

thheller12:04:57

this is not how you do a require in the REPL

thheller12:04:07

that require form is only valid inside of ns

thheller12:04:26

otherwise at the REPL you do (require '[vendo.workspaces.dom :as dom])

Spaceman12:04:26

This is in a file

thheller12:04:01

I really want to help you but you are making this incredibly difficult

thheller12:04:17

every time you ask something and post a small snippet of code and I never get the full picture

thheller12:04:31

it is in a file where?

thheller12:04:41

did you eval that ns?

Spaceman12:04:23

Yes it's in the namespace. Yes, I eval'd the namespaces

Spaceman13:04:33

Now I get REPL command timed out

thheller13:04:36

and in your REPL you are in that namespace? not cljs.user?

Spaceman13:04:27

I'm in cljs.user

Spaceman13:04:27

And the keybinding for switching the repl to the current buffer's namespace isn't working anymore.

thheller13:04:05

maybe restart the REPL ... it could have gotten confused by too many errors

Spaceman13:04:52

Yes, after restarting, I could change the repl's namespace to the namespace where I'm using dom, but the error persists

Spaceman13:04:30

Now suddenly it doesn't 🙂

thheller13:04:35

did you require or eval the ns before trying to switch to it?

Spaceman13:04:21

I meant, now the error is gone. Problem solved.

Spaceman13:04:59

Thanks for your help

thheller12:04:25

otherwise you are on your own

dazld13:04:00

hey @thheller - do you have a WIP branch somewhere with yesterday's CLJS release? wondering if it fixes a couple of inference warnings we've been seeing

dazld13:04:16

just wondering, not a biggie 😉

thheller13:04:09

I released 2.8.102 with the new CLJS version if that is what you are asking?

dazld13:04:40

oh, awesome, thank you for quick work!

dazld13:04:48

will take it for a spin

thheller13:04:22

curious about the inference warnings you are seeing though?

dazld13:04:07

it was on the protocols - one moment

dazld13:04:39

apparently this was fixed on this release, going to try it out

thheller13:04:21

hmm did you have this issue in shadow-cljs? I fixed that years ago for this case?

thheller13:04:05

or at least I thought I did

dazld13:04:47

think it's just in the advanced builds

dazld13:04:05

there was something funky and stateful going on too

dazld13:04:27

the warning would pop up on first build, but on subsequent builds it wouldn't appear - not a shadow thing this, afaict

dazld14:04:55

sadly not.

dazld14:04:04

I've updated the repro case 😞

Spaceman18:04:56

has anyone used jest with clojurescript? How did you install it? After I install it using npm install jest and add "test":"jest" in package.json, I expect keywords like "expect" to work:

(.toBeInTheDocument (expect (.getByText screen "Some Component")))
But I get that expect is undefined. js/expect gives undefined as well. How to get jest to work with clojurescript?

Patrick Truong19:04:04

Random shadow-cljs background question: what does ana stand for? That is the folder that stores all the Clojure dependencies. Thanks for entertaining my curiosity 🙂

lilactown19:04:34

analyzer would be my guess

👍 8
thheller19:04:58

yeah thats the analyzer cache

👍 4
thheller19:04:44

@pshar10 jest is not compatible. it expects to process and rewrite the JS files directly but doesn't understand the CLJS output format

Spaceman19:04:31

@thheller how about this library? Its src is in typescript though. Do you think this can be used?

Spaceman19:04:31

I tried it but it didn't work though. Is it because it's .ts and not .js?

thheller19:04:58

"this library"?

thheller20:04:02

thats fake ... it just moves the globals to a secondary namespace

thheller20:04:31

it doesn't change how jest functions. its not gonna work with CLJS

Spaceman23:04:17

how to separate production and development environment variables in shadow-cljs?

Spaceman23:04:29

Something that works similarly to having an :uberjar map and a :dev map in the project.clj for clojure, and then specifying the source paths for each?