This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-02
Channels
- # beginners (26)
- # bitcoin (1)
- # boot (9)
- # boot-dev (5)
- # cider (26)
- # cljs-dev (1)
- # clojure (190)
- # clojure-finland (1)
- # clojure-italy (42)
- # clojure-nl (20)
- # clojure-russia (3)
- # clojure-sanfrancisco (1)
- # clojure-serbia (1)
- # clojure-spec (50)
- # clojure-uk (16)
- # clojurescript (62)
- # core-async (4)
- # cryogen (1)
- # cursive (6)
- # datascript (1)
- # datomic (36)
- # duct (6)
- # editors (6)
- # emacs (14)
- # graphql (3)
- # leiningen (30)
- # off-topic (21)
- # om (7)
- # parinfer (13)
- # portkey (56)
- # re-frame (2)
- # reagent (2)
- # shadow-cljs (58)
- # vim (1)
- # yada (3)
@pri also you can take a look at https://github.com/pesterhazy/presumably/blob/master/posts/double-bundle.md Not the same as built In support. But a potential alternative.
Thanks @mikerod @emccue, will do. I hoped cljs core to have smoother Js module integrationāinstead we have a dozen repls and libs forking out flavors and the documentation is still broken.
Your hopes may soon be fulfilled: https://gist.github.com/mfikes/e6673df98da49b8a87ffadbf3dea8cf4
Yeah, if you see an issue, filing a JIRA with a minimal repro would help. (Perhaps this is easy to do given that an example on the site appears to be busted.)
Maybe instead of crapping on busy people working hard, you could try helping. Or just being kind.
I'm trying to assign a function call as the value of an html attribute. E.g. something like <div onlogin="someFunction();"></div>
My first thought to do this in cljs is something like this: [:div {:onlogin #(someFunction)}]
but that unfortunately renders as <div onlogin="function() { someFunction(); }"></div>
which does not work
The only success I've had getting this to work correctly is if I write this gross hack: [:div {:onlogin "full.path.to.someFunction();"}]
. I haven't tested it with minification yet but I very much doubt it would work
The namespace is required
Hmm, I guess the core of what I'm asking is, if #(some-function)
compiles to function () { some-function(); }
, then what do I need to do to get (function () { some-function(); })();
instead?
Ah, because I'm not trying to invoke it at the moment when the html is being rendered
Hmm, no luck. That just resulted in a named anonymous function instead: <div onlogin="function path$to$some-function() { ... }"></div>
I guess I'll be more specific about my problem. I'm trying to integrate the facebook sdk with my re-frame app: https://developers.facebook.com/docs/facebook-login/web
I want to use the official facebook login button and the example they give is
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
it looks like they expect literal javascript as a string that they can call exec()
on
(defn state-ful-with-atom []
[:div {:on-click #(swap! click-count inc)}
"I have been clicked " @click-count " times."])
So, compiling with NodeJS as target.
clj -m cljs.main --watch src --target node --output-to resources/server/main.js -c landing-page.core
This worked fine until I decided to require ["fs" :refer [readFileSync]]
. Now it throws
Caused by: clojure.lang.ExceptionInfo: No such namespace: fs
So I created a project.clj
and configured the same deps and options as above, and ran lein cljsbuild
. This works just fine, it pulls in the fs
module from Node without complaining.
Any ideas as to what might make clj
fail to find fs
?@henrik Try adding --output-dir
/`-d` option
@juhoteperi Cheers, but same difference Iām afraid.
So, these are my cljsbuild
options:
:cljsbuild {
:builds {:dev {:source-paths ["src"]
:compiler {:main "landing-page.core"
:output-to "resources/server/main.js"
:output-dir "out"
:target :nodejs
:optimizations :none
:source-map true
:pretty-print true}}}})
As compared to:
clj -m cljs.main --watch src --target node --output-dir out --output-to resources/server/main.js -c landing-page.core
@henrik Sounds like the same as https://dev.clojure.org/jira/browse/CLJS-2724
@mfikes @henrik That issue needs probably more information because this works with some tools with NodeJS target (e.g. Lein https://github.com/reagent-project/reagent/blob/master/prerender/sitetools/prerender.cljs#L15)
Iāve started my repl using the node env from a terminal, but it doesnāt seem to be āconnectedā b/c I get that the existing functions are undeclared after I call in-ns
This was the command I ran clj -m cljs.main --repl-env node
from the project directory (at the level that deps.edn lives).
@dehli what exactly are you trying to do?
When I run that command I get this
$ clj -m cljs.main --repl-env node
cljs.user=> (+ 1 3)
I assumed that if I ran the repl from the project root it would require the namespaces for that project
of course. i was asking if you were familiar with the difference between essentially declaring yourself in a namespace (`in-ns`) and loading/requiring to make sure that namespace is populated
Ahhh, sorry I misunderstood. Not really š But Iām reading through this: https://clojurescript.org/reference/repl
if you give that a prefix argument it will also put you in that ns as well. this chord is baked into my muscle memory
Thanks! Iāll give that a go. So can you eval cljs functions and eval them from within emacs?
absolutely. just like there's a cider-jack-in
there's a cider-jack-in-clojurescript
and you get all the same goodies