This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-18
Channels
- # aleph (59)
- # beginners (21)
- # bigdata (1)
- # boot (110)
- # cider (7)
- # clara (1)
- # cljs-dev (160)
- # cljsjs (3)
- # clojars (10)
- # clojure (122)
- # clojure-czech (2)
- # clojure-dusseldorf (5)
- # clojure-france (1)
- # clojure-italy (4)
- # clojure-korea (5)
- # clojure-russia (13)
- # clojure-spec (15)
- # clojure-uk (78)
- # clojurebridge (1)
- # clojurescript (196)
- # core-async (6)
- # core-logic (27)
- # cursive (11)
- # data-science (2)
- # datomic (45)
- # dirac (9)
- # emacs (2)
- # funcool (8)
- # hoplon (16)
- # immutant (13)
- # jobs (1)
- # klipse (11)
- # lein-figwheel (1)
- # leiningen (1)
- # off-topic (3)
- # om (40)
- # onyx (31)
- # pedestal (25)
- # re-frame (55)
- # ring (1)
- # ring-swagger (1)
- # rum (4)
- # specter (1)
- # sql (2)
- # untangled (30)
- # vim (12)
- # yada (12)
In my project.clj I have two builds, one for prod and one for dev. Is there a way for the app to know which one is running without adding extra source files that I include in one or the other?
@kenny: there's just no way around it in ClojureScript. If that namespace requires DataScript, user projects that require it will need a dependency on DataScript
See e.g. the cljs.spec.test
namespace. If you require it you'll need to have test.check in your dependencies
@pupeno: in your production build you could add :closure-defines {goog.DEBUG false}
The you only need to check whether goog.DEBUG
is true or false and you know which environment the app is in
I see… that might work 🙂
thanks.
@pupeno: reference for the closure-defines
compiler option: https://clojurescript.org/reference/compiler-options
@lxsameer - ptaoussanis released https://github.com/ptaoussanis/tempura yesterday - I'd check that out
@0farcher lxsameer, Untangled has (a sort of strange) i18n support -- trying to learn untangled now, presuming it works as billed, it also seems rather convenient -- just write in English (or whatever) and there's an extraction for all the strings which you have translated and then placed put back in the project
@dm3 perhaps (:locals &env)
?
@lxsameer I would recommend to look at what closure providers in terms of i18n/l10n and build on top of that as it will have compiler support
@anmonteiro thx, I'll try working with that.
@lxsameer There's also https://github.com/tonsky/tongue
@pupeno I needed similar check, but for my macros, to decide which variant of code to generate, I tap into clojurescript compiler internal state, if I need it in cljs, I emit the value to clojurescript to be visible during runtime: https://github.com/binaryage/cljs-oops/blob/eefe95045ac307284290f04514066f8cb4d1917a/src/lib/oops/config.clj#L21 disclaimer: this is might break in the future of course, so having tests covering this is a must
Are there any helpful tools for finding the problem when getting StackOverflowErrors when compiling CLJS files?
we have code to detect circular deps, though you may have found a case where it doesn’t work
@lvh the stack trace is nearly always pointing at the real problem - even if it seems strange on the surface
- clojure.lang.ExceptionInfo: failed compiling file:/Users/lvh/Projects/rackspace/shrieker/src/shrieker/billing.cljs {:file #object[java.io.File 0x2b67d8ad "/Users/lvh/Projects/rackspace/shrieker/src/shrieker/billing.cljs”]} - Caused by: clojure.lang.ExceptionInfo: at line 1 jar:file:/Users/lvh/.m2/repository/com/taoensso/sente/1.8.1/sente-1.8.1.jar!/taoensso/sente.cljs {:file #object[java.net.URL 0x5e23795f "jar:file:/Users/lvh/.m2/repository/com/taoensso/sente/1.8.1/sente-1.8.1.jar!/taoensso/sente.cljs"], :line 1, :column 1, :tag :cljs/analysis-error}
Now I’m down to "Caused by: java.io.FileNotFoundException: /Users/lvh/Projects/rackspace/shrieker/src/shrieker/events.cljs (Too many open files in system)"
@lvh it’s possible there’s a file leak somewhere, though would be surprised no one has run into that before
@lvh hrm there’s no good workaround actually - I’ll probably cut a release just to address this issue
@lvh it would be helpful if you could test master when I fix it to demonstrate that this fixes the issue for you
i humbly request that you also include http://dev.clojure.org/jira/browse/CLJS-1821, @dnolen, please 🙂
I’m not sure if I can, we’re stuck on like 1.7 for bad reasons, and I think we haven’t figured out how to upgrade to current versions of cljsbuild/figwheel without gratuitously breaking everything
thank you! much appreciated!
(that changing something leads me to believe that that’s just the recursive descent parser having a really good time, not a broken circular dependency check or something)
@lvh concluding anything at this point is unwise, since your problem isn’t a minimal one
@lvh if you can replicate the issue with just ClojureScript (after the other fix) then we can take a look
Can anyone point me in the right direction for overloading a function on a js object from clojurescript? Specific example... I’m using google closure autocomplete and I need to overload selectRow on the InputHandler.
@adammiller Google Closure should have examples of subclassing their components
dnolen BTW; I did eventually discover a bug: it was a circular reference problem, and I’m guessing it didn’t get caught because the reference was using varquotes
They’re orthogonal; but you suggested that the circular reference detection might have bugs in it; I think one of them might be related to referring to something via a var quote, rather than referring to it directly, because that’s the most obviously unusual part about this code
So, when I run it against master, I’m expecting the stack overflow again, but maybe not running out of fds
@viebel last night i used klipse to help me understand the difference between the js generated by (for) and the js generated by loop/recur on a (make-array) - very helpful, thanks! 🙂
@jrheard happy that you found it useful. Can you share the url of your code in the #klipse channel?
@dnolen: Already worked around it, but currently persists. I'll try to get a minimal case. Currently on phone though, so no promises on ETA :)
@dnolen: just so I understand correctly: circular dependency detection means I should not see a stack overflow that goes away when I remove the circular dependency, right?
Yep, that's what I understood . But does "disallow" mean "undefined behavior", "error message that details the dependency cycle " or something else entirely? Even if I can reproduce minimally, I'm trying to figure out if it would even be a bug.
thank you @dnolen and @anmonteiro 🙂
having trouble figuring out how to access the js = and == functions in clojurescript - any tips?
i could have sworn i once saw a way that you can embed a string of raw javascript in your cljs and run it, but am having trouble finding it in google
@jrheard you really should not do that unless you’re ok with your code suddenly not working one day
@jrheard js*
is supposed to be for internal stuff only. you shouldn’t have the need to use it.
is there good documentation somewhere on the correct way to use into
to get performance? i’ve got a 2d javascript array of booleans that i’m trying to turn into a 2d cljs vector of keywords, and currently i’m doing this:
(into []
(for [row an-array]
(into []
(for [full? row]
(if full? :full :empty)))))
but profiling indicates that i’m spending all of my time in this function, so i must be doing something wrong herei could manually make and fill transients, but into
seems like it wants to do that for me, so i’m betting that i shouldn’t be using for
here but should instead be using.. something else?
profile UI if it’s helpful - https://www.evernote.com/shard/s11/sh/78e6bc21-1c88-4629-a654-fb23c04f8a32/2a62f1f0edbae168 - seems like i’m spending all of my time in these for
s; again, i’m pretty sure i’d be easily able to make+fill+persist transients by hand, but i feel like i’ve read that there’s a more graceful way of accomplishing that
so it should be pretty zippy if :static-fns true
(implicit if you’re doing an :advanced
build)
awesome - i’ll read transduce
and array-reduce
, and will learn what :static-fns
does 🙂
trying
(into []
(map (fn [row]
(into []
(map (fn [cell]
(if (true? cell) :full :empty)))
row)))
an-array)
, and i see a noticeable (~2x) speedup! looks like this is exactly the use-into-to-get-performance-without-making-your-own-transients-by-hand usage i was looking for, thanks 🙂you can go one step further and use a transducer inside the into call too
hm, i thought that by doing (into [] (map foo bar) an-array)
i was using a transducer in the into call - is that not what you mean?
oh, maybe you are :) just hard to read all the indents properly
@jrheard there’s probably an optimization opportunity here that I hadn’t considered ...
@arohner pretty sure the more specific one is chosen
so if you're calling from CLJS then foo.cljs
@arohner @danielcompton is correct. In addition, :require-macros
will load the .cljc
@arohner actually, if you’re on a ClojureScript version lower than 1.9.229, you might encounter weird behavior
here’s the related commit: https://github.com/clojure/clojurescript/commit/ce6c657a751cce5fb1b8e94eb97e74944c0d7fa6
@dnolen good to know - at this point the function i was optimizing is now plenty fast for my purposes, but i’ll keep that in mind if i run into a similar situation, thanks for the heads up
@jrheard also I forgot how this worked - it should definitely be faster with your production build when :static-fns true
is applied globally
yeah, i think i’ve probably been worrying too much about optimizing various parts of my side project that are slow in dev - often when i do a production build, i find that they’re suddenly 10x faster 😅
@jrheard depending on the project, of course, but if you find that you don’t constantly redefine functions at the REPL (e.g. with different arities), it should be somewhat safe to also use :static-fns
in dev mode
here’s some more context on :static-fns
:
http://blog.fikesfarm.com/posts/2015-11-03-planck-static-function-dispatch.html
http://blog.fikesfarm.com/posts/2016-04-14-static-free-clojurescript-repl.html
@jrheard yeah there are many optimizations that we apply only in productions builds, some of these have a huge impact
How can I make unicode characters become integers in cljs? I have this "\u22126"
but (.fromCharCode js/String (goog.string/parseInt "\u22126"))
wont do it.
@hlolli https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt
ahh ok, I was missing that part that 54 is the charcode coming from unicode. Now I get positive 6, but that's fine, thanks @dnolen
@dnolen “we apply only in productions builds” - is this for :advanced only or :simple applies too?
@dragoncube :static-fns
needs to be explicitly set to true
for simple compilation
same for :optimize-constants
@anmonteiro I see, thanks!