This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-26
Channels
- # aws (1)
- # beginners (50)
- # boot (32)
- # chestnut (2)
- # cider (14)
- # clara (23)
- # cljs-dev (131)
- # cljsrn (44)
- # clojure (133)
- # clojure-belgium (3)
- # clojure-denmark (4)
- # clojure-dev (6)
- # clojure-italy (4)
- # clojure-nl (2)
- # clojure-russia (95)
- # clojure-spec (59)
- # clojure-uk (14)
- # clojurescript (157)
- # cursive (26)
- # data-science (1)
- # datomic (160)
- # devops (5)
- # dirac (80)
- # emacs (2)
- # graphql (2)
- # jobs (2)
- # lein-figwheel (1)
- # lumo (9)
- # off-topic (151)
- # onyx (2)
- # parinfer (2)
- # pedestal (5)
- # perun (2)
- # re-frame (60)
- # reagent (3)
- # remote-jobs (1)
- # test-check (3)
- # uncomplicate (11)
- # yada (1)
cljs.repl> *cljs-verbose*
WARNING: Use of undeclared Var cljs.repl/*cljs-verbose* at line 1 <cljs repl>
trying to get :repl-verbose going, using boot-cljs-repl, with no luck. anybody know how?
Hey, I’m in the process of setting up a development environment for a Chrome extension based on the sample https://github.com/binaryage/chromex-sample — the project uses figwheel which is great, but is configured to not setup a ClojureScript repl… I’m wondering if there is a way to get the REPL working too, or there is some reason why the REPL can’t be supported in that environment…
@mobileink 👍 for the interop guide! let us know when you open the PR to clojurescript-site, so we can comment
Question about figwheel: I'm noticing that I need to Shift-Reload in Chrome a lot because I'm seeing stale builds. Anyone seen caching issues like that?
@pesterhazy i get that because non-compilation bugs screw either the react state or my app state up 🙈
happens very often when refactoring. i guess autosave in Emacs is partly at fault
hm. that sounds like a different issue
I get the problem even if I restart lein figwheel
i do occasionally have to (reset-autobuilds)
in the FW repl
ah interesting
but I think the problem is with browser caches, not Figwheel's cache
I see "200 OK (from disk cache)" in Chrome network tab
not sure why Chrome thinks it can safely cache those files
just enable it https://github.com/binaryage/chromex-sample/blob/master/project.clj#L79
@darwin thanks for the update… I’m continuing down this path. I’ve enabled the REPL using :repl true
and I get
Launching ClojureScript REPL for build: background
...
Prompt will show when Figwheel connects to your application
if you run goog.require("figwheel.connect.build_background")
manually in background context (or popup context) it starts working
if you look at resources/unpacked/compiled/main.js
, you will see document.write("<script>if (typeof goog != \"undefined\") { goog.require(\"figwheel.connect.build_background\"); }</script>");
which was generated by :figwheel true I assume
but for chrome extension we don’t use main.js directly, we hand-roll it via resources/unpacked/background.js
btw. I broke it here: https://github.com/binaryage/chromex-sample/commit/a07c4fd412bf099cbc66c5a736e6f8932bdc71ff
ah, maybe I should try that. I’m trying to connect emacs CIDER to the ClojureScript repl started with lein fig
I tend to use Figwheel only for hot-reloading, disable its REPL in favor of using Dirac REPL. That is why it was left disabled there.
@pesterhazy You disable Chrome caching in the Dev console
@krukow more context: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md#dirac--figwheel
@rauh, is that a question or an assertion?
@darwin just posted here too: https://github.com/binaryage/chromex-sample/issues/3 so we can share a solution more broadly
@pesterhazy An assertion.
@darwin thanks for the reference - infact maybe the diract REPL is what I want, let me pursue this and get back! Thanks I appreciate the quick response
@rauh, right, I know I can disable it if I want, but regular "reload" should work without manual intervention
@krukow good luck and let me know if you hit some roadblocks, I could help probably, also feel free to modernize chromex-sample, it’s been a while since I last reviewed it
@pesterhazy It should work on reloading since figwheel will add a parameter to the URL. But not on F5, then it's up to chrome if it wants to load from memory or fresh.
@rauh, reloading via the "Reload" button (Cmd-R) is a normal part of everyone's dev workflow, so if that serves stale files, it's an issue I think
@krukow now I recall, it wasn’t because Dirac, it was because I was using lein-cooper (see the “devel” lein alias) which does not work well with interactive prompts
@krukow if you run lein fig
directly (along with other cooper tasks in other terminal sessions), you should be able to get figwheel REPL working from command-line
@pesterhazy I don't think it serves stale files. It's just that Chrome goes for the (old) cache. You can right click on the reload button in Chrome to see what options you have. A hard reload will avoid the cache.
Another option is to file an issue with fighweel so that it serves the right headers to avoid any caching.
I didn't phrase that well - you're right that figwheel doesn't serve stale files
It used to be that Chrome didn't use the cache when the Dev Console was open. But that seemed to have changed at some point. Now you have to explicitly disable it.
I think Chrome'e behavior has changed even with the Dev Console closed, caching scripts more aggressively even if no caching headers are returned.
But I can't prove that 🙂
@mobileink you need to provide that option :repl-verbose true
when configuring the REPL, not sure how boot-cljs-repl does that
@mobileink That option should be passed to piggieback/cljs-repl
here: https://github.com/adzerk-oss/boot-cljs-repl/blob/master/src/adzerk/boot_cljs_repl.clj#L128, currently not supported
I might have a snapshot with support ready in few minutes, I noticed a new piggieback version which might fix problems why I haven't used cljs repl
for more context https://groups.google.com/forum/#!msg/closure-compiler-discuss/bGWbLpsoVZU/u_dUKmclDgAJ
that is hilarious
sets too @dnolen https://github.com/google/closure-compiler/search?utf8=%E2%9C%93&q=clojure&type
so some mild frustration with secretary
and pushy
... what's the "correct" way to navigate? should i continue to use [:a {:href "#/my/route"}]
or should all of my links now dispatch an event using (set-token! history "/my/route")
?
thanks to @juhoteperi I can set :repl-verbose
now with boot-cljs-repl. However I get the following output; is there any way to get just the meat, i.e. ((1) + (2))
?
cljs.user> (+ 1 2)
cljs.core._STAR_print_namespace_maps_STAR_ = true
(function (){try{return cljs.core.pr_str((function (){var ret__19869__auto__ = ((1) + (2));
cljs.core._STAR_3 = cljs.core._STAR_2;
cljs.core._STAR_2 = cljs.core._STAR_1;
cljs.core._STAR_1 = ret__19869__auto__;
return ret__19869__auto__;
})());
}catch (e46877){var e__19870__auto__ = e46877;
cljs.core._STAR_e = e__19870__auto__;
throw e__19870__auto__;
}})()
3
i found this link: https://clojurescript.org/guides/javascript-modules
@mobileink You should probably try this without boot-cljs-repl/piggieback/weasel/cider-nrepl etc. with just bare Cljs repl to see if this is inference from tooling or from Cljs compiler: https://clojurescript.org/reference/repl#using-the-rhino-environment
juhoteperi: @mobileink: there’s no “interference” here, in order to run the repl you need to assign *1, *2, *3, *e and that’s the code you need to emit to make sure those are assigned.
If those are supposed to be printed, the example at Cljs site is a bit misleading: https://clojurescript.org/reference/repl-options#repl-verbose
that might be the case - my point was that in order to do what a repl is supposed to do in a clojure implementation, it needs to set those bindings, so it’s not something added by tooling, it’s fundamental repl stuff
@U051SS2EU assign howso? my repl-fu doesn’t have a whole lot of fu, I’m afraid.
the repl guarantees that *1 will be the result of the last expression in the repl, that *2 will be the second last, etc. and that *e will be the last uncaught exception
user=> (doc *1)
-------------------------
clojure.core/*1
bound in a repl thread to the most recent value printed
nil
I guess this is outdated? http://blog.fikesfarm.com/posts/2015-06-15-see-js-in-cljs-repl.html
it’s part of clojure.core
the docs for *1 and *e etc. describe this behavior, it’s part of what defines clojure
I mean that defining those things is correct behavior for a clojure repl, so I would not expect code that assigns them to come from anything other than the core language
they aren’t added by tooling
whether that’s exposed in the generated code you see while interacting with a repl is implementation details I think
(and I’d agree that they are just noise unless you are debugging the repl mechanisms themselves, but I don’t think our debug levels are fine grained enough to make that distinction inside them?)
@juhoteperi thanks, good point
there’s some stuff queued up for a future ClojureScript releases that will make it better gradually
i've been able to get the method described here working: http://blob.tomerweller.com/reagent-import-react-components-from-npm
foreign deps and/or CLJSJS for simple stuff, if more complex package your deps with webpack to produce a single foreign import
I have a question about not using clj->js
like @dnolen said a couple of days ago...
I mainly use clj->js
for converting dom attribute maps I build in om.next components. I use clojure functions to build the map (nice) and convert it just before calling a om.dom function (mainly in the om.dom/x invocation itself).
Since the map is very small and rendering (hopefully) doesn't occur often, performance issues shouldn't be a problem.
However, I am wondering since david talks about maybe deprecating clj->js
what is best way to build these js objects...
@julianwegkamp in your case you are probably safe because the keys in props
are owned by you
I hate to interrupt -- but if you're the real @dnolen I've watched so many of your talks and respect you & your work bigtime! You're walking inspiration.
@dnolen thx. Do you use goog.object to build/make changes to a js object or are there ways I'm not aware of?
@alice I agree completely!
but to be completely honest I almost always just build literals and don’t do much more
Don't wanna gush in public too much, but you're probably really responsible for all of my recent pursuits and my decision to dedicate myself to clojure lol
@dnolen I'm looking into how I can use goog.object
in the same way I use the standard clojure functions (mainly updating values by adding to className and setting defaults) but out of curiosity: what would be the problem js->clj in my scenario?
@julianwegkamp if you’re using js->clj
and you don’t have externs for something then you may see very strange problems under advanced compilation
i.e. Closure renames some ISeq
protocol access to ve
and some JS object accidentally has a property call ve
ah, ok. For a moment I forgot about advanced compilation 😄
Thx for explaining. I will do some more testing with #js
and try to figure out the best way to use it
I've read about ClojureScript, figwheel, but actually experiencing browser connected REPL with Emacs CIDER while writing a Chrome plugin is just... Wow! @darwin
I'm developing a ClojureScript library intended to be required and used by NodeJS users writing JavaScript. I'm able to require
the library fine, and the main function runs but the result when I execute lib = require('my-lib'); is an empty object, but I want to expose a more useful interface to node users. Googling seems to only return pages about using Node libs from ClojureScript.
I'm sure there are existing repos that implement this, but I don't know their names, can anyone point me at one? Thanks in advance. 🙂
@krubar my reaction was similar =) i had both content and background scripts in mine. did the (minimal) background ones in straight js but now can’t remember why…
Seems I should have searched here, my question was answered a few days ago: https://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-node.js-libraries Thanks again!
@crioux please note that this only works with shadow-cljs
. the other build tools don’t support this feature. feel free to ask questions if you have any, docs are in rough shape still.
Thanks! I'm currently working on my shadow-cljs.edn file, I have a pretty simple build but I'll let you know if I have any questions.
@crioux i was searching for an answer for this last couple of days as well, didnt come across this! Thanks for that, but what i found was a somewhat manual thing, refer to https://github.com/tonsky/datascript
He concats a prefix and a suffix to the compiled js file, while annotating all exported functions with ^:export inside the cljs files
@puzzler yeah. in Lumo:
Lumo 1.5.0
ClojureScript 1.9.542
Node.js v7.10.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=> (if js/undefined 1 2)
2
it’s actually the same as nil
🙂
cljs.user=> (nil? js/undefined)
true
Great, thanks. I didn't realize I could get at undefined with js/undefined
, so wasn't sure offhand how to test it for myself. Good to know.
@puzzler I should be clear. js/undefined
is not the same as nil
, but it’s equal to nil
cljs.user=> (== nil (js* "null"))
true
cljs.user=> (== nil js/undefined)
false