Fork me on GitHub
#shadow-cljs
<
2020-06-19
>
cjpotusse00:06:15

Hello! I am trying to use the react-bootstrap-table2 ’Export CSV’ functionality and struggling with the dependencies syntax - specifically, how to require ToolkitProvider, CSVExport, and ExportCSVButton. Any tips? import ToolkitProvider, { CSVExport } from 'react-bootstrap-table2-toolkit'; const { ExportCSVButton } = CSVExport;

cjpotusse12:06:01

Thank you. Doing the following gets me access to ToolkitProvider and CSVExport but I’m not sure how to get ExportCSVButton out of CSVExport. ["react-bootstrap-table2-toolkit" _:refer_ (CSVExport) _:default_ ToolkitProvider]

thheller12:06:08

(.-ExportCSVButton CSVExport)

currentoor00:06:31

I'm trying to work on a react native app on an android device via USB but having a lot of trouble. I've disabled fast refresh and don't see an option for live reload or hot code reload in the debug menu. I'm on the latest shadow-cljs release (2.10.12) The app is able to load and make requests to my laptop. But whenever I update some code the app crashes instead of refreshing. If I try connecting to the app's repl I get this (using intelliJ)

Connecting to remote nREPL server...
Clojure 1.10.1
(shadow/repl :pos-bare)
To quit, type: :cljs/quit
=> [:selected :pos-bare]
1
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
In the build section I see the connected runtimes keep getting droped and new ones are created. The logs are also consistent
#17 ready!
#18 ready!
#19 ready!
#21 ready!
Any idea what would cause the connected runtimes to keep getting dropped like that? Also this same code works on my friend's laptop so seems like something specific to my setup.

currentoor02:06:55

just verified, repl connecting to an emulator works fine it's just the device that's broken

currentoor03:06:21

also verified i can make requests from the device to the server, but for some reason the runtimes still get dropped

(js/setInterval #(async/go
                   (let [response (async/<! (http/get ""))]
                     (log/spy :warn response)))
  1000)

currentoor03:06:30

I also followed the instructions here, with the --verbose option i see the ip address is correct and in react-native log-android I don's see anything informative about why the runtime is getting dropped. Just the following

[20:23:16] I | ReactNativeJS ▶︎ #8 ready!
[20:23:39] I | ReactNativeJS ▶︎ #9 ready!
[20:24:05] I | ReactNativeJS ▶︎ #10 ready!
[20:24:28] I | ReactNativeJS ▶︎ #11 ready!
[20:24:52] I | ReactNativeJS ▶︎ #12 ready!
https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native

thheller07:06:42

@currentoor that looks odd but the timing appears to be the ping/pong timeout

currentoor19:06:50

i wounder if perhaps i have a defective device

currentoor19:06:25

i tried connecting a websocket from device to my laptop and it kept dropping and re-establishing the connection

currentoor19:06:05

that said, why does shadow establish a new runtime every time instead of re-connecting the old one?

thheller07:06:57

if the runtime doesn't respond to pings for about ~20sec it will be kicked by the relay

thheller07:06:18

the relay is sending a ping every 5sec when idle and the runtime is supposed to respond

thheller07:06:22

not sure why it wouldn't?

thheller07:06:44

but I also never tested this on an actual device before

thheller07:06:05

you can try setting :log {:level :debug} in shadow-cljs.edn but that will likely just confirm that it is indeed kicking because of ping timeout

thheller07:06:14

not why the client isn't responding

Casey10:06:58

o/ 'lo there I'm writing a custom target for a resource constrained environment and am trying to figure out the proper compiler options to enable dead code elimination, but disable renaming and whitespace removal. So the code remains readable, but dead code is removed.

Casey10:06:34

I want this in devel mode. the problem is a basic hello world script is 1.5MB.

Casey10:06:14

I suspect if I could get a hold of the underlying CompilerOptions object, I could call setRemoveDeadCode(true) on it when using optimizations :none

thheller11:06:50

@ramblurr this isn't going to work for development code

thheller11:06:09

:optmizations :none literally means "do not call the closure compiler at all"

thheller11:06:42

what are you doing exactly? I mean for which environment is this?

Casey11:06:19

Ah 😕 I didn't know that.

Casey11:06:08

I'm writing a target for the game http://screeps.com

Casey11:06:18

The code players right is ES6, but not in a DOM nor a node-like environment. I started with the graaljs target, and customized it. However there is a 2MB code limit on player code, and just cljs+goog is 1.5MB.

Casey11:06:22

Hm, maybe i can filter out the unneeded goog modules in the flush step.

thheller11:06:01

hmm does it support ESM?

thheller11:06:58

do you have a JS example?

thheller11:06:57

ah looks like commonjs. why not :node-library?

Casey11:06:28

No ESM support unfortunately. It supports a limited require that has no support for folders.

thheller11:06:29

this might not be node but that doesn't really matter

thheller11:06:04

use :node-library and shadow-cljs release while shadow-cljs server is running

thheller11:06:13

that will make everything small enough so size isn't an issue

thheller11:06:38

or maybe :npm-module works too

thheller11:06:04

compile might work for that one but you'll be approaching the size limits pretty fast

Casey11:06:56

Yea, I got it working at first with :node-library (or was it node script? don't remember), in dev and release modes. But in this game you'll need to react on the fly to things happening in the world, and it is very useful to see the un-minified code. You'll often react to some event in game by patching the deployed code, then later bringing those changes back into your codebase.

Casey11:06:42

:release / advanced optimizations makes that all but impossible.

thheller11:06:54

hmm does it support websockets? might be fun to get in there and use the REPL to tune stuff 😛

thheller11:06:15

you could try :simple with :pretty-print

thheller11:06:29

but that'll also be close to the max size

Casey11:06:37

the official game doesn't, but, since its open source, i'm working on a patch to the server to allow WS. That would be useful for testing outside the main official server.

Casey12:06:52

getting a repl is one of my goals, it would be tons of fun (even if not on the main server)

thheller12:06:15

:simple with just cljs.core is about 1mb. not sure how much code the game code ends up being but that might be fine?

thheller12:06:04

:target :esm would be by far the best option for this .. shame they don't support it 😛

Casey12:06:52

Oooh, yea cljs.core is the heavy item here, not the extra goog libraries

erik12:06:42

what is the proper way of creating a DevTools page when developing a Chrome extension?

erik12:06:49

devtools_page in the manifest needs to point to an .html page, so I generate an ESM module and then manually include it in that .html page?

thheller12:06:19

yeah. you can also just use a :browser build though

erik12:06:01

great, will try out both

mkarp12:06:12

@thheller Just tried the shadow’s Inspect feature — works great! Thank you :star-struck:

👍 6
Casey12:06:41

@thheller do you know of any writeups regarding how the cljs repl works?

kwrooijen12:06:46

Hello, how do I include dependencies for specific builds? e.g. I want to add re-frisk to my :dev build, but not in my :prod build?

pithyless13:06:49

@thheller not sure how to debug this, but I think there may be some kind of race-condition bug. With the newest  `malli.registry/type` code (that checks for a setting via closure-defines), once in a while (but only after a shadow-server restart) I see the `{:type "default"}` exception (i.e. a missing closure-defines option), but it Just Works™ if I "force compile" the build once in the shadow UI.

pithyless13:06:59

^ Testing with shadow 2.10.10

thheller14:06:57

what is a {:type "default"} exception?

pithyless15:06:34

so, it looks like (goog-define type "default") is returning "default" - malli will throw an exception; then I "force compile", type is no longer "default" but "custom" and malli continues without errors

pithyless15:06:05

where I'm setting in shadow-cljs.edn: :closure-defines {malli.registry/type "custom"}

thheller15:06:06

hmm no clue.

thheller15:06:46

there is some kind of bug that I haven't figured out when switching between compile->watch

thheller15:06:17

maybe thats also present in watch->watch. I have no clue what is happening but it results in a compile error. so unlikely to be related to your problem

pithyless15:06:20

ok, it's not a showstopper 🙂 If I figure out how to reproduce it I'll post an issue. Cheers!

pithyless15:06:13

for now I've only seen it when starting server -> first watch; (if that helps narrow it down)

thheller15:06:02

would be good to have something reproducible 🙂

David Pham13:06:59

Hello, I have some trouble with the shadow-cljs modules: I have a google closure error saying 1. Do you know what this would be?

David Pham13:06:18

oh I think I got it, there is an error in cljs.spec.alpha when calling gen...

thheller14:06:20

@kevin.van.rooijen classpath doesn't matter just always include it. and then add re-frisk via :preloads.

kwrooijen14:06:57

The JS doesn't get included if I don't :require it manually?

kwrooijen14:06:35

Makes sense, thanks!

Casey15:06:17

> The goog: prefix currently only works for ES6 file. require("goog:cljs.core") does not work. There's no way to call cljs from js then when ESM isn't available?

thheller15:06:50

:npm-module or :node-library

Casey15:06:43

re the repl docs: that is a nice high level explanation. To implement a repl for screeps, I'd need to be able to implement #3 Transfer Out and #6 Transfer Back using something besides web sockets... vanilla http requests

thheller15:06:05

It is unlikely that you need to implement that since there already is an impl for websockets

thheller15:06:48

but I don't know enough about the screeps runtime and what it can do

Casey15:06:16

There are no websockets. from inside the game i can read/write json to a memory location, from outside the game I can read/write to that memory location using an HTTP GET/POST.

Casey15:06:50

I'll dive into the impl and check it out.

thheller15:06:52

thats the node client impl

thheller15:06:50

browser has a bunch more stuff but the core impl is the same

thheller15:06:17

thats how it all works together