This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-22
Channels
- # announcements (2)
- # beginners (42)
- # calva (2)
- # cider (13)
- # clara (2)
- # cljdoc (1)
- # cljs-dev (8)
- # clojure (118)
- # clojure-australia (1)
- # clojure-europe (3)
- # clojure-finland (2)
- # clojure-italy (42)
- # clojure-japan (1)
- # clojure-nl (2)
- # clojure-spec (26)
- # clojure-uk (58)
- # clojurescript (83)
- # cursive (6)
- # data-science (2)
- # datomic (13)
- # devcards (2)
- # duct (9)
- # figwheel-main (4)
- # fulcro (11)
- # graphql (51)
- # jobs (1)
- # juxt (14)
- # kaocha (1)
- # off-topic (24)
- # re-frame (65)
- # reagent (4)
- # reitit (19)
- # remote-jobs (8)
- # shadow-cljs (50)
- # specter (3)
- # speculative (1)
- # vim (5)
- # yada (50)
@orestis there is something in the shadow-cljs devtools you might be interested in also. I never finished it but it is capable of compiling code on demand. if you have a running watch
for a browser build try this in the browser console
shadow.cljs.devtools.client.browser.compile("(prn :foo)", function(result) { console.log(result); })
basically the compile function lets you request a compile on the server and you'll get the raw compilation results
saw you asking about self-hosted stuff and that is pretty close without any of the self-hosted parts
limited to dev builds with a running watch of course but I was planning to use it to embed a REPL into the page directly and stuff
but you can also do full self-host stuff if you want https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html
I want to be able to show a textarea that people can type hiccup, and render it as it happens. Amazingly, you can go some way towards that using just cljs.reader/read
and get some EDN back, that reagent will happily try to render — but in this case symbols get turned into strings, while I want to look them up in my actual build.
eg. :js "cljs.core.prn.call(null,new cljs.core.Keyword(null,"foo","foo",1268894036))"
I’m trying
(shadow.browser/compile "(inc 1)"
(fn [result]
(let [src (get-in result [:actions 0 :js])
res (js/goog.globalEval src)]
(js/console.log src "=" res))
))
And I see printed: ((1) + (1)) – "=" – undefined
— I would expect to see a 2 somewhere.
If I surround the (inc 1)
with a prn, I do see 2 printed, so I think it’s something to do with JS not having expressions?
try to compile (fn [] (inc 1))
that should give you back a function you can call to get the actual result
Hm, that errors with: SyntaxError: Unexpected token '.'. Expected an opening '(' before a function's parameter list.
Cool stuff though! This would fit my use case very nicely. I hope to be able to demonstrate/document that somewhere when it’s finished.
I’m confused with how to update shadow-cljs — I do npm upgrade -g shadow-cljs
and I did see
$ npm update -g shadow-cljs
/Users/orestis/.nvm/versions/node/v10.15.0/bin/shadow-cljs -> /Users/orestis/.nvm/versions/node/v10.15.0/lib/node_modules/shadow-cljs/cli/runner.js
+ [email protected]
updated 1 package in 12.434s
— but when invoking shadow-cljs again I still see 2.7.16…anyone already have this problem Error: clojure is not defined
using :target :npm-module
? I'm using webpack too
@orestis the global install is not relevant if you have (which you should) a version local in your project
@leocardosoti which version are you on?
@orestis yes, pretty much only for CLI convenience but otherwise unnecessary. it will always use the version installed in your project
@thheller latest
it is most likely related to something using clojure.string
(or similar clojure.*
) directly without a require for it
but the latest version should have relaxed that requirement as long as it was required somewhere
yeap, this is an example: https://github.com/Day8/re-frame/blob/v0.9.4/src/re_frame/interceptor.cljc#L19
but okay i'll try to update everything
ensure that you have the latest version and restarted the server process after updating (eg. the watch
)
okay, thanks!