This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-22
Channels
- # aws (1)
- # beginners (102)
- # boot (5)
- # cljs-dev (59)
- # cljsjs (1)
- # clojure (154)
- # clojure-australia (1)
- # clojure-brasil (1)
- # clojure-dusseldorf (4)
- # clojure-greece (36)
- # clojure-italy (10)
- # clojure-poland (5)
- # clojure-romania (1)
- # clojure-russia (7)
- # clojure-spec (32)
- # clojure-uk (113)
- # clojure-ukraine (3)
- # clojurescript (107)
- # cursive (13)
- # data-science (25)
- # datomic (23)
- # emacs (3)
- # events (1)
- # fulcro (72)
- # funcool (10)
- # graphql (1)
- # leiningen (1)
- # luminus (2)
- # lumo (38)
- # off-topic (14)
- # onyx (78)
- # planck (4)
- # re-frame (55)
- # reagent (1)
- # ring (3)
- # ring-swagger (2)
- # rum (19)
- # shadow-cljs (89)
- # spacemacs (101)
- # sql (2)
- # unrepl (88)
Hi guys. Anyone knows how can I export module for npm from clojurescript? I am writing npm module with cljs but got stucked…
does it help https://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-node.js-libraries
@jiyinyiyong Thank you for information! 😭 I had no idea to search for build tools.(I was trying with lein-cljsbuild) After searching, I found same functionality in lein-figwheel. I will use it because I am more familier to it than shadow-cljs. FYI: https://github.com/bhauman/lein-figwheel/wiki/Node.js-development-with-figwheel#nodejs-module-development-with-figwheel
Is there a modern consensus on how to handle logins and sessions with clojure/script?
Specifically, how can I make sure a login persists between browsers being connected and not ? I want to make things as uninterruptive (new words yay) as possible for someone revisiting.
Some ideas I had revolve around keeping a local hashed value and then transmitting it over the wire on new connect and de-hashing it, and verifying logins that way. Is that reasonably secure, or is there a better way?
@sova between browsers seems impossible, as there is no way to data at a location multiple browsers can access as far as I know. Of course you could retrieve a session after a login, so the only thing they have to do on another browser is to log in again. If all your state is in the back end, you can then just go on as before. I started my current project from https://github.com/nginx-clojure/nginx-clojure/tree/master/example-projects/clojure-web-example they use a shared map to store information in the session, but have hints to use redis so you could scale. And you need not to hook the old session to the new session when the same user logs in again. There might me better/easier solutions.
Hi everyone, I'm trying to configure a var at compile-time with "goog-define" but I receive the following warning:
WARNING: Use of undeclared Var job_name.core/goog-define at line 4 src/cljs/job_name/core.cljs
I also specified the var in the :compiler options:
:closure-defines {job_name.core/foo "value"}
Anyone could help?@giorgio.porzio goog-define
is a macro and can only be called statically
How do I call getAttributeNames on a dom node? This method cannot be found with advanced compilation
https://github.com/google/closure-compiler/commit/0ae2a39e2ac50a857f5d02ef2ba4c1ca45609646
@bravilogy I've successfully used core.async with Om
(Om previous)
-- I had various channels in my app-state, and responded to messages with transact! Using core.async's pub-sub worked well for me
what it did mean was that I passed all messaging channels through to views so they could construct UI event-handlers that dispatched messages, which lead to changes in app-state (no direct coupling - all event handlers send messages like {:click :my-button} - no direct state-mutation in handlers)
- that way you can associate other events with the same responses, like messages from the server, so you can drive the UI from server messages too
does anyone here use cljs-oops? if so, how do you work with javascript date objects? when i try (ocall (js/Date.) :getTime)
i get Uncaught Oops, Unexpected object value (date-like)
@joshkh use normal cljs interop in case of dates, it is covered by default externs, more details https://github.com/binaryage/cljs-oops/issues/13#issuecomment-332560027
strings, dates and other standard javascript objects are guaranteed to have externs covering them (those externs are bundled with closure compiler)
here is the full list of diagnostics checks cljs-oops does in dev mode: https://github.com/binaryage/cljs-oops/blob/b8a2e8b3d8b9b2740e85ef7bcb0a1a4dc2b72276/src/lib/oops/codegen.clj#L46-L63
thanks @darwin . i didn't realise there were default externs bundled with the closure compiler 🙂
Hi, Is there a way to ensure/see if my externs file is being found by the closure compiler? It doesn't appear to be but I get no errors/info.
@mbutler maybe try to introduce a syntax error into your extern file? I believe closure compiler should spit some warning at least
this is one thing I don't like about externs btw. see what I wrote in point 4 here https://github.com/binaryage/cljs-oops#externs-from-hell
@darwin It would appear that my externs files is indeed not being read in/found 😞
Are there some good checks/obvious pitfalls?
I don't know, once I had to modify ClojureScript compiler with some verbose logging of what is being passed into closure compiler API as parameters, my problem was that a library I was dependent on had bundled externs but it didn't seem to work
Also sorry @darwin I lied, I threw in the syntax error in dev mode casually forgetting to turn advanced compilation on... At least i can now be confident that my file is being read and the problem is my inability to write externs 😄
However, it was working, all i did was move a few files around, I dont know if that is more scary 🙂
I’m getting an error compiling cljs: “No reader function for tag Inf” with the newest versions of cljs, what could be causing this? I looked in the file and it’s just to do with defining infinite number literals for js
could someone help me understand what i'm doing wrong with the recent code splitting / :modules compiler options updates? i set up a dummy project with the following advanced compilation configuration:
https://github.com/joshkh/modules/blob/master/project.clj#L45
when i compile with lein cljsbuild once min
i get the following error:
------ Figwheel Configuration Error ------
Missing required key :entries at path (:cljsbuild :builds 1 :compiler :modules :cljs-base)
{:cljsbuild
{:builds
[{:compiler
{:modules
{:cljs-base
{:output-to "resources/public/js/compiled/app.js"
:entries ...
^---- The required key :entries is missing
}}}}]}}
------------------------------------------
But the documentation at https://clojurescript.org/reference/compiler-options#modules states that you can override the cljs_base.js file name by providing only an :output-to keyi don't think so, i'm running the very latest figwheel / clojure / clojurescript versions
providing the :cljs-base map with an :entries []
key/value doesn't appear to work either as suggested here: https://clojurescript.org/news/2017-07-10-code-splitting
you do not need a { before cljsbuild
i don't in the actual project.clj in the link. i think that's just how figwheel does its reporting 🙂
oh i did not notice you linked to the actual file 🙂
I believe you need an output-to file.js
you have one in :outside {} but one needs to live inside :compiler {} according to a recent project.clj here locally
i think i might have been barking up the wrong tree. figwheel shouldn't have anything to do with this. it's advanced compilation.
yeah figwheel won't run until it's satisfied
that everything is "valid"
(is my understanding)
hmmm, okay, update: https://github.com/joshkh/modules/blob/master/project.clj#L45
weirdly enough my public/js/compiled directory has a bunch of files that look more like no optimisations:
app.js cljs cljs_base.js cljsjs clojure goog outside outside.js process reagent re_frame work
so uh, can you just put nil there or :none ?
but empty entries are still fine since they “catch” common dependencies in the graph
what's the :entries line for exactly? i know nothing about advanced compilation in cljs land
i think maybe i'm missing something fundamental here. if i include no module descriptions and run lein cljsbuild once min
i still get loads of files in js/compiled. that doesn't sound right at all for advanced optimisation.
isn't that ok though? i figured it was only the end product .js that got all the optimizations
compilers are a magical black box 😄
i don't think so? my other cljs projects produce a single some-app.js when i use advanced comp. what's going on here! maybe it's time for a walk. 😉
Yeah, what role the files in the output-dir play is still a mystery to me
the end goal of this madness is to compile cljs based web workers into their own files
you want each webworker to have its own .js ? sounds attainable ... modules seems to be the best way to go about that so far? it's a new puzzle to me
if i remove the :cljs-base entirely and keep the :outside module entry then i get an app.js of 0 bytes, cljs_base.js of 234 kb, and outside.js with 160kb. anyway that's a start... thanks for the input guys. i'll keep playing around with it.
@joshkh One workaround would be to switch off figwheels config validation. See validate-config
i wish the newest module changes had a bit more documentation with practical examples. they seem to be fantastic changes and cover a lot of ground that previously separated cljsbuild from something like webpack
i think you want to give each webworker two things: base namespace that they all share in common, unique namespace that each webworker has its own code specific to it, and then specify :entries #{"namespace.unique"} and :depends-on #{"namespace.shared"}
i'll make a note of that for now and apply it i get a simple module example working. thanks again!
compiler comprehension is a team effort 😃
you could try shadow-cljs where modules actually work and I have been using them since 2013 😉
the guide takes you through a complete setup https://clojurescript.org/guides/code-splitting
what you were referring to was the announcement which doesn’t really show you how to use it
still, it may be that shadow-cljs is more convenient for the WebWorker use case, but I wouldn’t know about that
@joshkh see https://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-the-browser#web-workers, just set :web-worker true
for the module and the rest will be taken care of
@dnolen i'm very sure it's just a problem on my end - sometimes i need a little practice for things to click. i haven't spent much time playing with the compiler itself. @thheller thanks for the link. i'll play with shadow-cljs if it solves my use case, then dig more into :modules when i have some time.
@lockdown- I'd go for cljs if it's a SPA. for the more typical "sprinkled bits of js in a server-rendered app", cljs might be overkill if you're not very familiar with it