This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-11
Channels
- # beginners (18)
- # boot (1)
- # cider (48)
- # cljs-dev (5)
- # cljsrn (2)
- # clojure (34)
- # clojure-greece (1)
- # clojure-mexico (3)
- # clojure-spec (6)
- # clojure-uk (3)
- # clojurescript (67)
- # cursive (1)
- # data-science (2)
- # defnpodcast (2)
- # fulcro (10)
- # jobs (3)
- # klipse (14)
- # off-topic (9)
- # pedestal (2)
- # re-frame (8)
- # spacemacs (2)
- # specter (2)
- # vim (2)
- # yada (1)
@dpsutton You can convert from a transit UUID to a core UUID by first converting to string:
cljs.user=> (require '[cognitect.transit :as t])
nil
cljs.user=> (uuid (str (t/uuid "123e4567-e89b-12d3-a456-426655440000")))
#uuid "123e4567-e89b-12d3-a456-426655440000"
Interestingly, there is code in Transit supporting the intent that Transit UUIDs and core UUIDs be transparently exchangeable, but the new core uuid?
function was written after all of that and doesn't address that aspect.
@dpsutton Looks like you can fix uuid?
failing on Transit UUIDs by revising them to implement IUUID. Hrm.
cljs.user=> (require '[com.cognitect.transit.types :as ty])
nil
cljs.user=> (extend-type ty/UUID IUUID)
#js {}
cljs.user=> (uuid? (t/uuid "123e4567-e89b-12d3-a456-426655440000"))
true
I’m getting an error I haven’t seen before while attempting to use a cljsjs dependency to a new project: java.io.FileNotFoundException: Could not locate cljsjs/aws_sdk_js__init.class or cljsjs/aws_sdk_js.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
the js files from cljsjs are in the right place, but it seems the cljs compiler is trying to load these as a java class for whatever reason
@mattly You would get that if you are requiring them as macros. In other words (require-macros 'cljsjs.aws-sdk-js)
repros that error.
@dpsutton No problem. Perhaps transit-cljs
should automatically (extend-type ty/UUID IUUID)
in its core namespace.
@dpsutton I think the intent is to hide the difference, but that was coded up 3 years ago, with uuid?
being relatively new.
@mfikes it uses re-frame, but that’s the only other entry in :require
and there’s no macros at all
@mattly Is there a stack trace associated with the error? Perhaps it has a hint as to where things go into Clojure-land.
@mattly Yeah, it definitely looks like you have a *.cljc
file that is being loaded by Clojure instead of by ClojureScript
@mattly On the surface, I don't think paths would be the root cause (all source files need to be "on the classpath" somewhere but that doesn't control how they are treated / loaded)
@mattly Perhaps you are onto something though, especially if it is in the "env/dev/myapp"
directory
Need, to run, but my guess above, with dev
is that stuff in that directory might be loaded like user.clj
would be loaded. In other words, it may have special meaning to lein
.
there’s actually nothing in the /env/dev
directory I’m using yet, I’m going to try removing that
this seems to be specifically a figwheel problem now, I can cause a similar error with a (js/console.log :foo)
call
Is it possible to pass feature flags to the reader used by the cljs compiler? Motivating use case described here: https://gist.github.com/lynaghk/0608a43f173558b6fcf30c3be53d77dd
@kevin.lynagh nice timing. I was going to open a ticket about that very thing. My current plan was to add :reader-features #{:kw1 kw2}
to the build config and use that when reading .cljc
files. My goal however was to enable reading based on the target platform, eg. node, browser, react-native, etc.
@thheller Interesting. Thanks for opening up a JIRA ticket. This looks like a straightforward technical change, but I haven't thought about broader community issues w.r.t. language fragmentation, conflicting conditional reads in transitive dependencies, etc.
So I can't say I'm certain it's a good idea, just that it'd solve my immediate problem. I'm curious to see what discussion happens on that ticket.
has anyone done some debouncing with react? (do something only after event stopped occuring, like trigger the search when the user stopped typing)
@roti use [goog.async Debouncer]
and then set it up in will-mount and tear down in did-unmount
@kevin.lynagh I think you could use :external-config
and some helper macros to exclude values on dev builds. Here's the example: https://gist.github.com/metametadata/bb00917e09463f6ce04f0e50ccc0740a cc @thheller
@thheller I'm not sure it's really needed in this case as hopefully Closure's DCE will kick in and core.spec will not end up in the produciton build.
that is unfortunately incorrect. cljs.spec is very unfriendly towards DCE. It pretty much can’t be removed at all.
huh, didn't know that, thanks
and what if one uses this feature? https://anmonteiro.com/2016/10/clojurescript-require-outside-ns/
I didn't try it but maybe (when-debug (require ...))
could work
right
okay, thanks. I'll upvote the the bug you issued 🙂
@kevin.lynagh If you can use 1.9.854 or later, you can rely on aggressive branch elision that occurs at the ClojureScript level for ^:const
Boolean Vars. This can remove stuff that even goog.DEBUG
fails to ferret out. Details here https://gist.github.com/mfikes/93cb77921ee35c2328b92af441ee5393
@mfikes I guess your solution (as well as :external-config
one) also won't help with eliminating the require of core.spec
as @thheller pointed out in the above thread, due to https://dev.clojure.org/jira/browse/CLJS-1701?
@metametadata In the test I was doing, simply requiring clojure.spec.alpha
results in no increase in generated code size under :advanced
.