This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
@ul probably better to extend string, extending native javascript objects does not work properly in some browsers
getting:
cljs.user=> (extend-type string IFn (-invoke [s x] (get x s))) ("z" {"z" 1})
#object[Function "function (s,x){
return cljs.core.get.call(null,x,s);
}"]
cljs.user=> ("z" {"z" 1})
#object[TypeError TypeError: "z".call is not a function]
TypeError: "z".call is not a function
at eval (eval at figwheel$client$utils$eval_helper (), <anonymous>:1:93)
at eval (eval at figwheel$client$utils$eval_helper (), <anonymous>:9:3)
at eval (eval at figwheel$client$utils$eval_helper (), <anonymous>:14:4)
at figwheel$client$utils$eval_helper ()
we could probably teach that to the compiler in the spirit of being more like clojure
but not sure if that would introduce more issues, maybe try a JIRA issue. not sure if this has been discussed before
@maria, thanks for the blog pointer, but I’ve seen the documentation a few places and as far as I can tell, when I build with :optimizations :whitespace
, the compiler doesn’t emit the CLOSURE_UNCOMPILED_DEFINES
variable; I set up a simple repo to demo what I’m seeing: https://github.com/cvermilion/goog-define-bug
would love to figure out what I’m doing wrong 😕
@ul and you should never extend-type JS primitive types - extend-type js/String will definitely cause problems.
@dnolen: I have some tooling that needs to know the compilers default :output-dir
. Do you think it's wise to expose something like cljs.closure/add-implicit-opts
? https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L1569
@bensu already happened https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/build/api.clj#L164
do you think it should issue some warning when using node to include something like cljsjs/node_externs
when using node?
I'm just using (.exit js/process 1)
in a normal program, and process.exit
is not covered in the built in externs
If you know what's going on, you can figure it out fairly fast, otherwise it takes a while
1) this Node.js, advanced optimizations don’t matter much, 2) we’re never going to provide the complete Node.js externs file because we don’t have the time to maintain it and because of 1)
I agree with both points, that's why I'm asking about warnings/docs. I'll see if there is a suitable place in the wiki to point Node users to cljsjs/node-externs
@cvermilion: closure defines do not currently work with white space I think.
Whitespace skips the closure compiler and just concatenates files/removes whitespace. Please someone correct me if that's not correct.
And with whitespace there is no insertion of the defines as you already discovered.
@martinklepsch: yep, :whitespace
is one of the weird modes, unless you’re writing something like a browser plugin best to avoid entirely.
I have
(if (and (exists? js/KM) (exists? js/KM.i))
(.i js/KM)
, but I’m still getting ReferenceError: 'KM' is undefined
. What am I doing wrong?"(((typeof KM !== 'undefined') && (typeof KM.i !== 'undefined'))?KM.i();\n:)"
is the generated code
@arohner: exists?
is just JS typeof
idiom, it does not work the way you believe it to work above
"undefined"!==typeof KM&&"undefined"!==typeof KM.i?KM.i():null
works in my Chrome consolearg. looks like a caching issue. the client loaded the previous, broken code, which was (exists? js/KM.i)
, with no (and (exists? js/KM))
, and then I looked at the current .cljs source
however I’ve seen weird stuff if I have any breakpoints lying around (I always clear them out)
the error was in production, and I got the stacktrace from our JS error reporter, and then looked at current .cljs
Hey everyone, if you wanted to use the latest react-router, alongside reagent, how would you go about making the node modules play well with cljs? Would you a) use webpack to handle the node modules and expose the files via preamble to cljs b) use foreign-libs (am a bit hazy on how to do this well)
@stopachka: I would stick to a)
In the past I have just split by “.” and then used js/JSON.parse on the 2nd segment according to the spec here http://jwt.io/
Which works as long as the payload is not encrypted. I don’t believe you can parse an encrypted token client side without exposing your secret key.
@thheller you are correct. Its just base64. I meant to say you cannot verify the token validity client side to my knowledge.
https://github.com/google/closure-library/blob/master/closure/goog/crypt/hmac_test.js#L57-L61
but verifying a sercet JWT token in the browser seems questionable since you need to transmit the secret to the client
@tyler I haven't used it but I think buddy: https://github.com/funcool/buddy/ has jwt
I did that with friend on the server. Would still need to expose secret on the client with buddy.
@roberto jws/jwe seems to support asymmetric crypto for signature & encryption, but if your client is a browser then there's not much point in validating a token delivered by a server with code delivered from the same server and a public key also delivered from the same server... if you were validating a token from a different source than the code/pubkey then it may be useful
i use (buddy) jws for a client (browser) to store an auth token after login - the server signs the token with a symmetric key, and later validates the token given back to it by the client, unwrapping the clients user-id
the client doesn't really care what's inside the token in this case, it's just an opaque means of authing to the server
@martinklepsch and @dnolen — thanks for the helpful comments re :optimizations :whitespace
and goog-define
! It would be nice to document the issue, say, in the description of compiler options, since I could see this tripping someone up like it did me.
@cvermilion: do you know about the clojurescript wiki? It has a page on compiler options that everyone can modify/improve :)
I did know about the wiki! I just wasn’t sure how welcome edits were. But happy to help where I can! I’ll take a look on Monday when I’m back at work.
@cvermilion: edits are very welcome, the only thing that’s really off limits without asking first is the Quick Start
for the obvious reason that if someone edits that then it would ruin the experience for newcomers as edits these days are almost always wrong
Hello everybody!
I posted this question on #C03S1L9DN irc, sorry if I spam a little
basically I would like to contribute a package on cljsjs
it depends on jquery
and the main constructor is
$.fn.jqconsole
the problem is, I cannot get rid of
Uncaught ReferenceError: $ is not defined
in my minified (prod) buildI even tried to import directly jquery in :foreign-libs, but it does not want to cooperate
my package defines:
(deps-cljs :name "cljsjs.jqconsole"
:requires ["cljsjs.jquery"])
I thought it would be enough