Fork me on GitHub
#clojurescript
<
2019-01-09
>
Eccentric J03:01:54

If I want to create an npm module users can install as a CLI and just use, which shadow-cljs build target should I use?

lilactown05:01:27

probably :node-script

Eccentric J05:01:01

Thanks, I did read that URL first but was unclear to me.

thheller09:01:47

@jayzawrotny https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-script or :npm-module depending on your needs. :node-script is simpler and probably what you want.

WhoNeedszZz06:01:08

What's the best way to read an EDN file in ClojureScript given that slurp is unavailable?

WhoNeedszZz15:01:03

I realized I was being silly here because I was trying to hide a public key from the repo thinking it was a secret key. I'm still curious though should the need arise what to do here.

Eccentric J06:01:44

fs/readFileSync + read-string?

mfikes12:01:40

If it is amenable to compile time, you could do it with a macro. (Avoid doing that in a library, because it is incompatible with :aot-cache, but it should be OK in application code.)

sova-soars-the-sora16:01:54

Good Day everyone. Just recently the latest version of Nonforum was released. It's built on ClojureScript with Rum, Sente, and Accountant, and a little bit of Clojure to have a server. Check it out! it's a fresh start so all the cool aliases are still available. https://www.nonforum.com

Eccentric J16:01:57

I use that project.clj below then run lein repl and I get a fatal error:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at clojure.main.<clinit>(main.java:20)
Caused by: Syntax error compiling at (org/httpkit/server.clj:1:1).
        at clojure.lang.Compiler.load(Compiler.java:7647)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:463)
        at clojure.lang.RT.load(RT.java:428)
        at clojure.core$load$fn__6824.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:1789)
        at figwheel_sidecar.components.figwheel_server$eval18541$loading__6706__auto____18542.invoke(figwheel_server.clj:1)
        at figwheel_sidecar.components.figwheel_server$eval18541.invokeStatic(figwheel_server.clj:1)
        at figwheel_sidecar.components.figwheel_server$eval18541.invoke(figwheel_server.clj:1)
 
any insight as to why it’s combusting?

WhoNeedszZz16:01:52

I can't say why it's not working, but I can recommend using shadow-cljs since you are using npm packages

Eccentric J16:01:00

I’m working on a lein-template that provides both a figwheel and a shadow-cljs variation so unfortunately I gotta do the leg work and learn it.

kwladyka17:01:00

Here you can find full example how to use figwheel-main + cljs + npm dependencies https://github.com/kwladyka/form-validator-cljs/tree/doc

kwladyka17:01:44

Oh and everything besides of solution with shadow-cljs and figwheel-main suc** IMO 🙂

kwladyka17:01:51

Only this 2 matter IMO

👍 1
dpsutton16:01:24

@jayzawrotny you've got some fundamental incompatibilities in your project.clj due to a migration from tools.nrepl -> nrepl/nrepl. Some things that stick out: i think your figwheel sidecar is very outdated. I think its up to 0.5.17 now? com.cemerick/piggieback 0.2.2 should be cider/piggieback 0.3.10 (possibly 11?) and the nrepl middleware to wrap cljs repl should use cider.piggieback/wrap-cljs-repl. Also, since you are specifying 2.8.3 for lein, any dependency that uses tools.nrepl will likely poison your setup

Eccentric J16:01:51

Thanks, this is the thorough ass kicking I needed! What should I be specifying for lein, 2.0.0?

dpsutton17:01:04

latest is 2.8.3

dpsutton17:01:05

it's kinda annoying right now because some low level stuff has been migrated out of core-contrib and there's a bit of churn right now

dpsutton17:01:29

and chas stepped away from clojure so nrepl and cider orgs inherited the piggieback and nrepl repos

Eccentric J17:01:53

I remember some of the discussion around that. It’s unfortunate.

Eccentric J17:01:11

Great, it’s working now thanks!

dpsutton17:01:32

the docstring for sort-by in clojure includes "guaranteed to be stable" and this is absent from clojurescript. I suppose this is intentionally absent and I should not rely on this property? *clojurescript-version* => "1.9.946"

dpsutton17:01:44

i suppose this is telling: ;; matching Clojure's stable sort, though docs don't promise it

WhoNeedszZz17:01:40

Is there an equivalent to https://clojuredocs.org for CLJS?

joshmiller19:01:05

I’m having an issue where nothing in my externs file is being reflected in my advanced compilation build. Is there a place to start to try to debug that? Adding an obviously non-existent file to my :externs vector in the compiler options doesn’t generate a warning, for example.

manutter5119:01:10

are you using lein/cljsbuild?

mfikes19:01:30

One quick thing to check is add :verbose to see if your compiler options are being used at all (https://clojurescript.org/reference/compiler-options#verbose)

joshmiller19:01:00

Cool, trying that

joshmiller19:01:55

Yeah, looks like the compiler options are being picked up, and my externs file is included in that vector.

dnolen19:01:08

@joshmiller did you hand write the externs?

dnolen19:01:28

it's pretty common for people to not write these properly

dnolen19:01:39

Google Closure accepts a very strict syntax

joshmiller19:01:09

Ok, I’ll look into that. These are hand-written for a first-party JS dependency, so I might have screwed that up.

dnolen19:01:43

@joshmiller are you aware that we can generate externs automatically for you now?

dnolen19:01:53

currently it does mean the file needs to be part of the build as a foreign library

dnolen19:01:59

however that will change probably after the next release

joshmiller19:01:08

Vaguely, so I can give that a shot as well.

dnolen19:01:45

one common misconception about externs is that you can write stuff like

dnolen19:01:54

var api = {"foo" ...};

dnolen19:01:56

doesn't work

dnolen19:01:04

no object literals

dnolen19:01:06

no strings

Eccentric J20:01:20

If you’re writing a cljs cli what is the recommended approach for cli arg parsing?

Eccentric J20:01:41

Using the clojure cli tools lib or an npm module like yargs?

dnolen20:01:45

the api for a ClojureScript one will probably be more idiomatic

Eccentric J20:01:52

Oh right, the npm one would return a js array\object not a clj vec\map. Thanks!

souenzzo21:01:56

I think that's a loop/recur problem. Not direct related to core.async

souenzzo21:01:07

One-line reproduce.

clj -Srepro -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0"} org.clojure/clojurescript {:mvn/version "1.10.439"}}}' -m cljs.main --repl-env node -e '(defmacro myloop [bindings & body] `(loop ~bindings [email protected])) (myloop [] (recur))'

souenzzo19:01:04

Bump. There is a issue about that?

lilactown19:01:42

consider posting this in #cljs-dev