Fork me on GitHub
#shadow-cljs
<
2018-06-07
>
thheller06:06:14

@spieden (:require ["semantic-ui-react" :as sem]) sem/Button.Group

wilkerlucio14:06:54

@thheller hello man, how you doing? question, how does work the part of shadow that you can click on a warning and it opens on the editor? I'm looking at the sources and see that it triggers something on the server to do it, can you tell me how that works?

wilkerlucio14:06:33

and you know if it's possible for me to do something similar strait in the browser? for context, I'm creating a devcards alternative, and I would like to jump to the card source from a button in the page

thheller14:06:38

can't do it straight in the browser no. it basically just does a xhr and the server then executes via the shell https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/web/api.clj#L55-L86

thheller14:06:36

since the browser can't just randomly start applications it must go through the server

wilkerlucio14:06:20

gotcha, so I think I'll make this "shadow-only" and I can just leverage your xhr call

thheller14:06:20

could also export this to something more generic and figwheel could do the same

thheller14:06:20

ie. you call (when-let [open js/OpenFileInEditor] (open "some/file.cljs" 10 1))

thheller14:06:45

and shadow-cljs/figwheel just export the js/OpenFileInEditor

richiardiandrea15:06:58

Looked at the issue and the PR and left some comment there, I think there is value...but the target can be made generic - say :lambda-fn - and the metadata dropped - easy to write anyways`. Will try to come up with a PR today and probably I will ask you more questions on how to package everything, node_modules included, in a single file

richiardiandrea15:06:44

@thheller ^ and thanks 😉

spieden16:06:22

@thheller worked, thanks!

wilkerlucio18:06:42

@thheller trying to use the open-file, but not working, I guess I might be sending the wrong path, what the path need to be relative to?1

thheller18:06:05

should be absolute I think

thheller18:06:11

or relative to the project root

wilkerlucio18:06:07

I'm getting the info out of (meta &form), but the path there seems relative to its own source path, do you know if I can get the absolute path there somehow?

thheller18:06:23

try shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1) in the console

thheller18:06:05

hmm good question. I don't think you can get to the actual file

thheller18:06:26

I got annoyed by leaking /home/thheller/code/shadow-cljs/src/... or other absolute paths into the compiled output

thheller18:06:03

so now it only has access to the classpath path

thheller18:06:35

I could add another open-classpath fn that maps the classpath path to an absolute path and opens that

wilkerlucio18:06:22

gotcha, I couldn't make it work, I tried manually asking for the shadow file

wilkerlucio18:06:32

the editor gets focused, but the correct file isn't opened

wilkerlucio18:06:43

I tried relative to project and absolute

thheller18:06:22

this doesn't work? shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1)

wilkerlucio18:06:05

on the js console this line doesn't work at all

wilkerlucio18:06:07

shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1)
VM52189:1 Uncaught TypeError: Cannot read property 'open_file' of undefined
    at <anonymous>:1:26

wilkerlucio18:06:32

ah, was msising client: shadow.cljs.devtools.client.hud.open_file("shadow-cljs.edn", 1, 1)

wilkerlucio18:06:45

but still, not focusing the correct file

thheller18:06:13

do you have :open-file-command setup correctly?

wilkerlucio18:06:21

yeah, when I click from a warning it works

wilkerlucio18:06:52

ups, or at least was working early, for some reason seems like that isn't working now either

wilkerlucio18:06:57

let me try restarting shadow

wilkerlucio18:06:57

now it's not working anymore, even on warnings =/

wilkerlucio18:06:14

I have this on ~/.shadow-cljs/config.edn

wilkerlucio18:06:16

{:open-file-command
 ["idea" :pwd "--line" :line :file]}

wilkerlucio18:06:29

strange, I''m sure it worked earlier

thheller18:06:56

maybe your editor is confused? it is working fine for me

wilkerlucio18:06:28

maybe, I'll try restarting it

wilkerlucio18:06:34

still the same, I'll give up on that for now, not that important

oscar19:06:36

I'm finding that running shadow-cljs via "clojure" (with a deps.edn file) results in a process that never exits.

thheller19:06:15

does it hang or what do you mean?

oscar19:06:35

If I do a release, it successfully builds and then hangs.

oscar19:06:55

I converted my deps.edn to a project.clj and running under lein I don't have the same issue.

oscar19:06:14

It looks like any action that shells out to the clojure process never returns. I can put together an example repo in a couple hours if you want.

oscar19:06:39

$ yarn shadow-cljs clj-eval "(println \"hello\")"
yarn run v1.7.0
warning package.json: No license field
$ /home/oscar/Projects/penny-profit/redux/node_modules/.bin/shadow-cljs clj-eval '(println "hello")'
shadow-cljs - config: /home/oscar/Projects/penny-profit/redux/shadow-cljs.edn  cli version: 2.3.36  node: v10.4.0
shadow-cljs - starting via "clojure"
hello
nil

oscar19:06:24

And it just hangs without returning to the prompt

wilkerlucio19:06:18

had you tried without yarn? I used with deps.edn before, didn't had this issue, also there is a strange thing about the 130 status code return, I wonder if that + yarn is getting you in this place

thheller19:06:43

yeah check which process actually doesn't exit. is it really the java process sticking around?

thheller19:06:56

yarn -> node (shadow-cljs) -> clojure (bash) -> java . could be any one of them

oscar20:06:14

Substituting npx for yarn yields the same results.

oscar20:06:59

It looks like java isn't exiting. I'll try to make a simplest-case repo.

oscar21:06:05

Oh! One of my dev namespaces starts an http server. That's probably what's keeping the process alive. When I switched to lein, I didn't include my dev path. Thanks for the help!

oscar21:06:39

Yeah. That was it.