This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-12
Channels
- # bangalore-clj (1)
- # beginners (28)
- # boot (33)
- # chestnut (3)
- # cider (35)
- # cljs-dev (64)
- # cljsrn (16)
- # clojure (95)
- # clojure-android (6)
- # clojure-austin (1)
- # clojure-italy (5)
- # clojure-korea (1)
- # clojure-russia (55)
- # clojure-sg (1)
- # clojure-spec (25)
- # clojure-uk (57)
- # clojurescript (120)
- # code-reviews (7)
- # community-development (2)
- # core-async (3)
- # cursive (6)
- # data-science (3)
- # datascript (10)
- # datomic (12)
- # devcards (1)
- # emacs (9)
- # gsoc (7)
- # hoplon (18)
- # lumo (2)
- # off-topic (10)
- # om (24)
- # onyx (17)
- # pedestal (46)
- # powderkeg (1)
- # protorepl (7)
- # re-frame (31)
- # ring-swagger (34)
- # spacemacs (10)
- # specter (9)
- # sql (39)
- # unrepl (9)
- # untangled (3)
- # utah-clojurians (1)
I have a cljs codebase. It's 1200 lines. It takes 54 seconds on :optimizations :advanced, and 47 (from cold start, not incremental) on :optimizations :none ?
@U2J4FRT2T : thanks for verifying
@qqq maybe for a "from scratch" compile, but most of that time would be in spinning up the compiler and analyzer. In my codebases (well over 10k lines) I could get much faster compilations with incremental compiles
e.g. a "rebuild all" in figwheel maybe took 1 min, but a simple saving of a file and it getting pushed to the browser via figwheel took less than a second
Anyone care for a thenable atom?
(defn watch-cycle [a]
(let [k (gensym)]
(add-watch a k
(fn []
(remove-watch a k)
(reduce #(%2 %1) @a (:q (meta a)))
(alter-meta! a update :q #(vec (rest %)))))))
(defn aswap [a afn]
(alter-meta! a assoc :q [])
(watch-cycle a)
(js/setTimeout #(swap! a afn) 1)
a)
(defn then [a afn]
(alter-meta! a update :q conj afn)
a)
then...
dev:user=> (def t (atom 1))
dev:user=> (-> (aswap t inc) (then #(inc %)) (then #(println "result:" %)))
#object [cljs.core.Atom {:val 1}]
dev:user=> result: 3
dev:user=> @t
2
Yeah, I know, bad use of meta. I just haven't mastered extend-type
yet. (don't do that at home)
Then chaining is just a simple (defn chain [a & fns] (reduce then a fns))
with (chain (aswap t inc) #(inc %) #(println "result:" %))
Hi everybody !
I'm trying to separate a cljs build in 3 closure modules: common.js
, outer-pages.js
and inner-pages.js
. But my inner-pages.js
and outer-pages.js
files are always empty. I suspect code motion to be responsible and I'd like to force the compiler to not move everything to common
. Is it possible ?
ggaillard: https://github.com/thheller/shadow-devtools/wiki/ClojureScript-for-the-browser
consider using this for :modules
, lets just say the CLJS version of :modules
has "issues".
but if the files are empty they might just be removed as dead code? do the entries contain any ^:export
or code that runs?
Hi @thheller, I tried it but I got some issues with shadow-devtools. An error saying that Prone (a library) tried to provide cljs.core
, if I understood well
[:dev] Build started.
-> Finding resources in classpath
Ignoring bad file, it attempted to provide cljs.core
jar:file:/Users/geoffrey/Documents/GitHub/bf/bf.front/local-m2/prone/prone/1.1.4/prone-1.1.4.jar!/prone/generated/prone.js
<- Finding resources in classpath (4201 ms)
FIXME: error format for clojure.lang.ExceptionInfo <:tag missing>===
So I removed Prone and still got the <:tag missing>===
error …You might be right about DCE, the namespaces I'm trying to modularize are all only implementing a multimethod.
I have this architecture : app.dispatcher
is a namespace defining a get-view
multimethod. app.core
is requiring app.dispatcher
and app.pages
. app.pages
require all the app.pages.<page-name>
namespaces. Every app.pages.<page-name>
require app.dispatcher
and add a multimethod implementation to it.
If I compile the whole thing in :advanced
mode without modules I get everything working, so I guess DCE is not removing app.pages.<page-name>
namespaces
I'm trying to find what is causing the :tag missing
exception
The problem with excess files in the Prone jar was fixed in the 1.0 release. Is that not the case for you?
@U07FCNURX not a problem really. you should probably switch to at least :simple
though. 2.1mb JS seems excessive for what you are doing
@U2DART3HA the issue is somewhere else, I can work with prone just fine. do you have more errors after the missing tag? there should be a trace no?
Effectively, I had [thheller/shadow-devtools "0.1.20170408"]
, my bad 😕 . I first pulled the lastest clojars version, but by trying different configurations from exemples I must have copied this version.
Updating did indeed fix the <:tag missing>
message. But I got an exception with goog dependencies
ExceptionInfo ns "goog.i18n.NumberFormatSymbols_fr_FR" not available, required by bf/front/core.cljs
by the way I got no traces for these errors
the error is all I need, there should only be traces for errors I didn't make "pretty" yet.
so goog.i18n.NumberFormatSymbols_fr_FR
does not exist, only goog.i18n.NumberFormatSymbols_fr
just import goog.i18n.NumberFormatSymbols
and set :closure-defines {goog.LOCALE "fr"}
in the build config
I had retrocompatibility issues preventing me to update, but since shadowbuild bring a new version on the closure library I have to adapt my code. I will do it now.
I have a lot of things to fix but it's going way better ! I'm really sorry I took your time with these issues 😕
nonsense, thank you for sticking with it. I need people that run into issues when compiling, only way to fix it.
please let me know if you run into any other rough edges, I want to clear them up. even if it just a better warning/error
I keep having these errors
NS:figwheel.client.file-reloading has duplicate require/use for goog.string
I removed duplicates from my code and made a pull request to fix one in Re-Frame, but I can't do it for every libraries, is there a way to disable these checks ?uhm figwheel
won't work with this. shadow-devtools
has its own REPL/file-reloading that you don't need to configure
I will see if I can be less strict about duplicate requires. I always considered these to be errors but it should probably just warn
just pushed version 1.0.20170512-13
which removes that check. turns out clojure allows this as well, so not actually an error. my bad.
just wrote an extra section about live-reloading, wasn't documented that well before
https://github.com/thheller/shadow-devtools/wiki/ClojureScript-for-the-browser#live-reloading
Awesome !
@thheller I managed to make it work ! But I have still problems with cross module code motion … Don't think it's a shadow-build problem, more the way I configure it. I have the same behaviour with the classic cljsbuild. I'll ask on #clojurescript, I must have missed something.
Is there a good way to implement (format "%.1f" s)
so that it works in both Clojure and ClojureScript? It looks like it was removed at some point as a wrapper for goog.string.format, but I'm using this in a shared file. 😞
that's pretty much what I do in namespaces where I need to format in cljc, yes
Has there been any talk about when the next version of clojurescript will be released? I'd love to get the clojure.spec.alpha
naming changes https://github.com/clojure/clojurescript/compare/r1.9.521...master
@qqq well you need to factor in your deps of course - and whether you using a 3rd party tooling (Boot/Lein) to kick of that process
If you always get confused about requiring namespaces, constructors and whatnot from Closure Library this one is for you https://twitter.com/martinklepsch/status/863043601760112640 💝
@martinklepsch strictly speaking shortcut/EventType.SHORTCUT_TRIGGERED
is not allowed. it should be :import
the EventType
and then (.. EventType -SHORTCUT_TRIGGERED)
@martinklepsch thank you!
currentoor: welcome! 🙂
@thheller ah, really? I saw the issue with EventType shadowing each other and thought it might be better to describe the way that cannot suffer from this issue
@thheller in what way could/would it break?
Do you mean strictly as in it’s not proper cljs syntax?
@martinklepsch @dnolen any official word on whether shortcut/EventType.SHORTCUT_TRIGGERED
is allowed? (the property access) clojure doesn't allow it so I assumed it only worked accidentally in CLJS (or something limited to js/
)
@martinklepsch to be honest I'm surprised that even works 😛
I found import weird because import is for constructors
@thheller it works because it’s in the same file
goog/net.XhrIo
for example wouldn't work unless the XhrIo was required somewhere else already
(.-SHORTCUT_TRIGGERED shortcut/EventType)
that would be perfectly valid no?
I think much of this stuff is a bit mushy because it’s JS
FWIW you can even do KeyboardShortcutHandler.EventType.SHORTCUT_TRIGGERED
after importing the constructor
but as fair as I know the alias/something.nested
syntax isn't allowed since clojure doesnt allow it
yeah, totally get that argument
still given :import
is for constructors, what would be a perfectly valid way of doing it?
I don't know, if shortcut/EventType.SHORTCUT_TRIGGERED
works just use it. (.. shortcut/EventType -SHORTCUT_TRIGGERED)
or js/goog.ui.KeyBoardShortcutHandler.EventType.SHORTCUT_TRIGGERED
is what I usually use
in case of js/
don't forget the require for [goog.ui.KeyBoardShortcutHandler.EventType]
though
not a fan of js/goog but yeah, whatever works I guess
curious what David has to say
I am looking for a way to register an unhandled error handler in re-frame or reagent. The idea is that when any unhandled error occurs, a user friendly message is displayed. is there a standard way of doing this? Thanks!
I know window.onerror = function () {...}
used to exist in Firefox, but I haven't used it in a long time and don't know what the browser compat is on it nowadays
but if you’re just talking about nested property access with inline .
, will always work
if people want to abuse it, nothing will stop them, and we’re unlikely to bother with all the work that would be required of validation
@martinklepsch there you have it. I was wrong I guess.
ClojureScript 1.9.542 released https://groups.google.com/d/msg/clojurescript/xt_wS-FicwA/uXLyEMlKAAAJ
I'm trying to figure out how to convert this js snippet to cljs
function hexToBase64(hexstring) {
return btoa(hexstring.match(/\w{2}/g).map(function(a) {
return String.fromCharCode(parseInt(a, 16));
}).join(""));
}
I assume we're mapping the anonymous function (on the right) across the result of the .match
on the hex string.
Is there an off the shelf drag + drop component (so an file is on the user's desktop, and they drag it onto a div, and the cljs uploads the file). All libraries I have found so far is about "dragging + droppung divs within the website, but not a file from outside the browser into a div on the browser"