Fork me on GitHub
#clojurescript
<
2018-08-01
>
thiru00:08:20

@bhauman Figured out a way to have separate REPLs for CLJ and CLJS.. not perfect but good enough for now:

thiru00:08:06

1) Start Clojure REPL, e.g.: clojure -m figwheel.main --build dev repl

thiru00:08:30

2) Launch a separate terminal and use leiningen to connect to existing REPL, e.g.: lein repl :connect nrepl:127.0.0.1:1234 (replacing 1234)

thiru00:08:51

3) Start figwheel-main from second REPL, e.g.: (figwheel.main/start "dev")

thiru00:08:46

@bhauman If you feel it's useful enough to include in the figwheel-main lib I can create a pull request

bhauman00:08:05

I'm not getting what you are doing here

bhauman00:08:23

why do you need to have figwheel running twice?

bhauman00:08:44

that seems bad

thiru00:08:53

Oops sorry.. the first step should be: (clojure -m rebel-readline.main)

bhauman00:08:04

oh that makes more sense

bhauman00:08:17

and you start a nrepl server in the this clojure main process?

thiru00:08:44

Oh yes in my first instance.. (missing lots of steps!) 🙂

thiru00:08:08

The only caveat(s) is having to leiningen for CLJS and no rebel-readline in CLJS

bhauman00:08:48

are you using this from vim?

bhauman00:08:55

or only in the terminal?

thiru00:08:08

These are separate terminals but connected to it with one Vim instance (fireplace)

thiru00:08:48

So three terminals altogether: Vim, Clojure REPL, ClojureScript REPL + Figwheel

bhauman00:08:28

oh I gotcha

bhauman00:08:45

fireplace talks to the terminal repls?

bhauman00:08:08

or is fireplace connecting to the nREPL server?

thiru00:08:50

fireplace is talking through nREPL and Piggieback

bhauman00:08:36

and fireplace doesn't provide a REPL inside the editor?

thiru00:08:28

Not really.. there's a very, very limited one-line evaluator.. they call it the Quasi-REPL.. it sucks

thiru00:08:06

For Common Lisp Vim has slimv. It has an excellent REPL built-in. But the Clojure interop isn't great so I use fireplace

bhauman00:08:00

OK this setup is cool, because I think it will work with vscode and with VIM

bhauman00:08:26

now that I understand how it works, I think I can come up with an interesting solution

bhauman00:08:30

too bad rebel-readline doesn't work over nREPL yet

bhauman00:08:56

but that will come in the future

thiru00:08:00

Right - yup I like having the REPLs separate

bhauman00:08:35

actually I can't think of a better way to do this right now, you kinda have to choose with repl you want to work with rebel-readline

thiru00:08:56

I guess there's no way to somehow combine lein repl :connect ... and lein trampoline run -m rebel-readline.main?

bhauman00:08:08

but you could make it so that the cljs repl gets rebel-readline instead of the clojure repl

thiru00:08:45

Yup good point I can

thiru00:08:27

Probably a better idea for now as I'll be using ClojureScript much more heavily

bhauman00:08:46

yeah If you want to write this up that would be great

thiru00:08:25

Yup no prob

bhauman00:08:36

probably with rebel-readline in the cljs repl

thiru00:08:01

which doc file should it sit in?

bhauman00:08:21

put it in the docs/docs directory as a separate file

bhauman00:08:49

and just ensure that it is last

bhauman00:08:32

If you are familiar with github pages development, you can use it jekyll serve from the docs directory

thiru00:08:08

ok cool will try that

👍 4
Mickey J Winters04:08:14

I'm having an issue with npm-deps where goog is saying undefined name to path for a dependency of the module I'm trying to use. I've tested my project.cljs with react and left pad and it works fine. any advice on where to go from here?

Mickey J Winters04:08:25

also here is my project.cljs and source if you want to check it out https://gist.github.com/mjrb/1903851fe692656329d5d9eb33205b01

joshkh12:08:31

has anyone experienced in web dev cljs and bidi been successful using a prefix in their url routes, such as a #?

fabrao12:08:35

Hello all, I need to define a javascript function in clojurescript env. I tried to use ^:export but it includes the namespace before. Is that possible to define without namespace?

thheller12:08:35

@fabrao you can do (ns your.ns) (defn some-fn [] ...) (js/goog.exportSymbol "theFunction" some-fn)

thheller12:08:55

that would create a global theFunction() in JS

fabrao12:08:27

@thheller Thanks, I´ll try it

Mickey J Winters16:08:44

@mfikes thanks for that, but I'd need to use the sdk package to login and get a client to get a mongo connection

Mickey J Winters16:08:04

Right now my work around is to use yarn and foreign libs to access the stuff. Id probably have to write externs regardless if I used foriegn libs or npm-deps right?

justinlee16:08:32

someone correct me if i’m wrong, but, in theory, libraries that get included via :npm-deps get run through the closure compiler. if they survive that process, they’ll get minified along with the cljs code and you shouldn’t need externs. it isn’t clear how much js code can really survive closure compilation, however, so you may need to futz with externs after all. for :foreign-libs included libraries, I’d turn on automatic inference if I were you. I think it works pretty well now. If you are using a lot of npm stuff, I’d further recommend you use shadow-cljs as your build tool instead. including npm packages and inferring externs works very smoothly with it.

Mickey J Winters16:08:08

Thanks I'll look into shadow

dnolen17:08:40

npm deps work fine with ClojureScript

dnolen17:08:57

there’s no reason to use another tool other matter of taste/preference

dnolen17:08:46

ClojureScript has externs inference so you don’t have to write externs

dnolen17:08:13

you just have to write a bit of boilerplate glue that shadow-cljs elides - but this hardly matters in long term projects IMHO

dnolen17:08:34

You should avoid :npm-deps unless you want to live on the cutting edge - or want to help advance that feature

Mickey J Winters17:08:06

@dnolen I followed that guide and that's how I currently got the project working, but when I tried to turn on adnvanced compilation (with infer externs) it said window.Ld was not defined or something which sounds like something weird happened with the externs

Mickey J Winters17:08:52

For context and if anyone is interested I'm working on a cljs library for mongodb stitch (a serverless platform that gives you secure client side db access)

Mickey J Winters17:08:48

(and also server side function and integrations with other services)

dnolen17:08:55

@www.w.com123 that doesn’t sound like an externs problem

dnolen17:08:03

it sounds like you passed index.js into your build somehow

dnolen17:08:28

did you get the guide working by itself without modification?

dnolen17:08:23

I’ve tried it with fairly non-trivial stuff - React Datepicker etc. and I haven’t run into any issues myself

worlds-endless18:08:49

Google login (https://developers.google.com/identity/sign-in/web/sign-in) instructs to redefine the global onSignIn function to get the information after they've signed in. From browser console, this works from me; but how can I redefine this global function from my cljs file?

justinlee18:08:05

@worlds-endless just use goog.object/set on js/window:

(goog.object/set js/window "thing" "foo")
=> nil
(goog.object/get js/window "thing")
=> "foo"

worlds-endless19:08:18

Thanks, @lee.justin.m. Turns out it was even easier: (set! js/onSignIn on-google-signin)

worlds-endless19:08:40

(which is probably the same thing under the hood)

justinlee19:08:06

people often suggest using goog.object/set, though I’m not sure what if any difference there is to just using set!

worlds-endless19:08:49

That's an interesting question; if goog.object/set is better than set!, I wonder why it isn't just rewritten as an alias?

justinlee19:08:44

for example, in the docstring of aset, it suggests using goog.object/set instead of just using set!. i’m not quite sure why

lilactown19:08:26

there's some weird malarkey that happens when closure starts optimizing

lilactown19:08:04

AFAIK the rule of thumb is: 1. Object made & set through interop syntax, can use interop syntax 2. Object made by other JS? Use goog.object

jsa-aerial21:08:13

I'm trying to update a set of CLJSJS packages. I run boot on the build.boot and it seems to 'complete', including buiding deps.clj, writing the pom stuff and writing the jar. But I can't find the poms or jar. Anyone know where this stuff is written or what otherwise may be wrong?? Thanks!

jsa-aerial04:08:11

to answer my own question - this appears to be a boot thing. If you simply specify the package task nothing is actually written (despite messages indicating otherwise). You need to specify boot package install target to actually write the stuff out so that you can then test it

jsa-aerial04:08:11

to answer my own question - this appears to be a boot thing. If you simply specify the package task nothing is actually written (despite messages indicating otherwise). You need to specify boot package install target to actually write the stuff out so that you can then test it