This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-17
Channels
- # beginners (70)
- # boot (4)
- # cider (16)
- # clara (6)
- # cljdoc (21)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (73)
- # clojure-finland (2)
- # clojure-nl (6)
- # clojure-russia (35)
- # clojure-sg (1)
- # clojure-spec (14)
- # clojure-uk (146)
- # clojurebridge (2)
- # clojurescript (128)
- # cryogen (2)
- # cursive (20)
- # datomic (27)
- # emacs (6)
- # events (8)
- # figwheel-main (57)
- # fulcro (46)
- # hoplon (3)
- # hyperfiddle (2)
- # immutant (3)
- # jobs (6)
- # jobs-discuss (15)
- # juxt (2)
- # off-topic (33)
- # parinfer (2)
- # portkey (4)
- # protorepl (1)
- # re-frame (4)
- # reagent (78)
- # ring-swagger (45)
- # schema (6)
- # shadow-cljs (167)
- # spacemacs (2)
- # specter (13)
- # tools-deps (6)
Anyone with a link to a good tutorial on how to debug CLJS? I've tried it in dev tools och chrome but I can't set breakpoints everywhere
@coderdanger I don't have a tutorial for you but cljs-devtools
is an essential tool. Optionally, consider dirac
Be sure to compile with source maps. Breakpoints etc, should all work.
for CLJS macros, can we use this syntax [cljs.core.async.macros :refer [go]]
or do we still need to do require-macros
?
use (:require [cljs.core.async :refer (go)])
. the :require-macros
is no longer required (assuming you are using a somewhat recent core.async
version)
nice that works perfectly. thank you
will it still block execution of whatever form it's in until the take has been completed?
once you go async everything is async. there is absolutely no blocking IO in Browser JS engines.
that would be a way to do it yes. what is "best" entirely depends on what you are actually doing and how you program is structured. not something that can be answered simply.
well, I need to wait on (do-async-operation) before proceeding with another async operation which depends on the first
@iagwanderson, on macOS inside of a tmux, you need to do a set-option -g default-command "reattach-to-user-namespace -l fish"
to access os resources.
@clashthebunny thanks! works fine now. o/
:thumbsup:
@restenb why go-loop?
Hello, I am looking for a way to import node modules from clojurescript. I'm tried using lein-npm
. The node modules are downloaded in the right folder (at the root of my compiled js folder) but I don't know how to import them. Anyone could guide me? Thanks.
Hmm yes I could do that I guess. I was wondering if there was a more clojure idiomatic way.
https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
you could also check out macchiato https://macchiato-framework.github.io/
I was looking into that but it doesn't really play well with lein-npm
because it would require another additional field than :npm
in the project map
besides, I have multiple compilation targets, and it doesn't feel right to use npm-deps
for each of them
if you just want to use a couple of node modules you should just include them as :npm-deps and use (node/require ...)
if you want a proper Node server with direct clojurescript capability, I would recommend macchiato
I'm getting node undefined
with (:require [cljs.node as node])
what am I doing wrong?
(ns xxx
(:require
[re-frame.core :as re-frame]
[xxx.subs :as subs]
[clojure.string :refer [join]]
[cljs.nodejs :as node]
))
If you target browser then it’s not possible to include nodejs
Imo you should include the dependency in the compiler section. Then simply require it from js form
Or use cljsjs
What tool do you use?
problem with including it in project.clj
is I have multiple builds. It seems to me that I would have to include the deps in every build.
I mean figwheel, shadow, lumo?
Ok what Clojurescript version do you use?
There are multiple ways we can actually handle that problem don’t worry ;)
Project.clj is a normal clj file. You can define you dependencies there then use it in you builds.
I've actually tried defining the deps before defproject:
(def npm-deps
{:react-youtube "7.6.0"})
And what’s the problem?
here is the error I got:
------ Figwheel Configuration Error ------
The key :npm-deps at (:cljsbuild :builds 0 :compiler) has a non-conforming value: npm-deps
It should satisfy one of: Map | false?
/home/void/wp/pasteurdaniel/project.clj:38:20
33 :output-to "resources/public/js/app.js"
34 :output-dir "resources/public/js/out"
35 :asset-path "js/out"
36 :source-map-timestamp true
37 :preloads [devtools.preload]
38 :npm-deps npm-deps
^--- The value at key :npm-deps doesn't conform
39 :install-deps true
40 :external-config {:devtools/config {:features-to-install :all}}
41 }}
42
43 {:id "min"
What clojurescript version you are using?
@kwcharllie379 [org.clojure/clojurescript "1.10.238"]
Try ~npm-deps or 'npm-deps
Let me check it
I’m having a bit of trouble using node’s http.request method, throwing an error that a listener argument is a function (at bottom of snippet). Anyone have experience with the http.request js interop?
@jayzawrotny In your example, request-params
is a ClojureScript map. You probably want to pass a JavaScript object, right?
Put a #js
in front of it, and also in front of the ClojureScript map value for "headers"
Also @jayzawrotny request
appears to take options as its first argument, and a callback as its second argument.
Unless I’m mistaken this call pattern appears to be documented https://nodejs.org/api/http.html#http_http_request_url_options_callback
Hrm.
cljs.user=> (require '[http :refer [request]])
nil
cljs.user=> (set! *print-fn-bodies* true)
true
cljs.user=> request
#object[request "function request(options, cb) {
return new ClientRequest(options, cb);
}"]
Yeah, if you open the history disclosure you can see that that v10.9.0 has “allow both url and options to be passed to http.request()
`
I think Lumo is based on Node 8
Ah ok, that’s how I understood it. Though I’m unclear why it--- Oh. I’m running Node 9.11.2 😞
But, to be clear, installing Node 10 won’t change it. Lumo doesn’t use Node. It is Node in the sense that it is a binary built based on Node 8.
@qle-guen Did you manage to require the react-youtube? I cannot even require it
Tried require also lodash library but I am receiving error module is not defined
It seems that npm-deps should be considered very beta feature
1. is there a way to start a CLJS repl without a deps.edn file (using -Sdeps)? couldn't get it to work in my ~60s of trying 2. how do I start a rebel-readline CLJS repl?
clj -Sdeps "{:deps {com.bhauman/figwheel-main {:mvn/version \"0.1.7\"}}}}" -m figwheel.main
@lilactown you can get a plain repl with clojure -Sdeps '{:deps {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}}' -m rebel-readline.cljs.main
documented here https://github.com/bhauman/rebel-readline/tree/master/rebel-readline-cljs
I think the critical thing I was missing is that the dependency map passed to -Sdeps has to be in a top-level {:dep ...}
:face_with_rolling_eyes:
I was also struggling to find the rebel-readline-cljs docs so that's a big help too 👍
@qle-guen I'm sorry but I don't know how to help you. Tried everything. I'm more comfortable with targeting nodejs rather then browser.
@clashthebunny that starts a Nashorn REPL
Gotcha!
@lilactown do you mean without the building stuff?
you should be able to use just the REPL part - but I would ask for details in #figwheel-main
I’m atm mainly interested in using rebel-readline with a browser CLJS REPL, just like how
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"}}}' -m cljs.main
starts oneI can’t tell if rebel-readline requires the figwheel-main REPL as well to function in a browser
@lilactown https://github.com/bhauman/rebel-readline/tree/master/rebel-readline-cljs#usage
@bhauman am I missing something where it explains how to use a Chrome browser runtime instead of Nashorn?
@lilactown ^ if you look at the above code and pass a browser repl-env instead of a nashorn repl-env