This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-20
Channels
- # beginners (61)
- # cider (25)
- # cljsrn (7)
- # clojure (76)
- # clojure-austin (1)
- # clojure-russia (10)
- # clojure-uk (2)
- # clojurescript (96)
- # cursive (12)
- # datomic (38)
- # defnpodcast (9)
- # emacs (24)
- # fulcro (1)
- # graphql (5)
- # hoplon (3)
- # jobs (1)
- # keechma (20)
- # leiningen (4)
- # lumo (5)
- # off-topic (13)
- # perun (6)
- # re-frame (19)
- # reagent (1)
- # remote-jobs (2)
- # shadow-cljs (199)
- # sql (6)
- # vim (7)
clojurescript is strangely not executing the reset!
in this function... anyone knows why?
(defn do-plot
[map-object markers-atom data]
(let [markers (map (partial do-build-marker map-object) data)]
;; Removing this console.log will prevent markers from being plotted at all
;; Compiler overoptimization?
(.log js/console (clj->js [:do-plot-data data markers]))
(map gmap-marker-remove @markers-atom)
(reset! markers-atom markers)))
i'm using create-class
in reagent because i've to first render some div
before calling google's api on it to draw a map
@ackerleytng Pretty sure reset!
will be run unless something else throws an exception
hmm...
Note that map
is lazy, so in case you rely on side effects you should use something else
i do rely on side effects.
let me try
@rauh thanks soooo much!!
mapv
works!
wait in that case, why didn't reset!
force the map
in let
to execute?
@ackerleytng A lazy seq is just an object. Like any other CLJS datastructure like lists or vectors. Unless you "request" an element nothing will realize the lazy seq
i see. thanks so much once again!
Hello! Please, how do I call an npm module from my node cljs 1) without including it in the resulting source bundle and 2) without risking that :optimizations :advanced
will screw it up?
I guess I could just (def aws (js/require "aws-sdk")) (.describeEnvironments (aws/ElasticBeanstalk. ...) ...)
but that could by changed by advanced optimizations, so I perhaps need to include an extern file or use the automatic externs detection. Perhaps I could add to my project.clj [cljsjs/aws-sdk-js "2.94.0-0"]
without actually using it anywhere, just to make its externs visible to the compiler? Or use cljs-oops
for the calls, avoiding the risk of changes by :advanced? (I assume that the new npm modules integration isn't suitable because it also includes the module's code in the compiled source bundle, but I might be wrong)
(Context: I am writing an AWS Lambda function. It has aws sdk node module pre-installed in the execution environment in so I don't need and don't want to include it.)
Thank you!
is there any way to prevent the compiler to add that line "#!/usr/bin/env node" to my compiled javascript for a node target ?
nodejs could be used from windows ... or maybe from node-webkit as is the case from me... that first line could be added as part of a build process... and is rather harder to remove in the context of figwheel developement
How bad is it to trick cljs.core by setting *target*
to "nodejs" from my code ?
My problem is that I want to use js->clj , but this only works with a target of :nodejs under node-webkit ... and I can't/don't want to really target nodejs because it's now causing all kind of troubles with figwheel... that's because we're now assuming that the files are loaded from the file system rather than from a web server
@faxa quite a bit of depth on that subject @ https://clojurescript.org/news/2017-07-14-checked-array-access if you are interested
But I think the main storyline is that aget
is/was often abused for js field access when it wasn’t really intended for that purpose
and Cljs may be pushing for further optimizations on its actually intended purpose - array access
Anyone knows how to use an npm modul from node cljs without including it in the gcc-produced source bundle and without advanced optimizations wreaking havoc on the calls to it? Thx!
Normally it isnt needed but I am creating an AWS Lamda function so minimization is important
it installed once (I think after running lein figwheel
?), but after adding additional dependencies, it will not update the package.json or even install the earlier ones after deleting node_modules
OK, I figured it out - I was trying to install a version of a library that didn’t exist
I’m getting this error in my browser when I run figwheel:
Uncaught Error: Undefined nameToPath for glamorous
@U4R5K5M0A specifically go
is like async
and <!
is like await
at least in terms of programmer ergonomics. under the covers they are totally different
:thinking_face: other modules I’ve installed from NPM - e.g. React - seem to be working fine
dev:cljs.user=> (require 'left-pad)
nil
dev:cljs.user=> (require 'glamorous)
#object[Error Error: goog.require could not find: glamorous]
figwheel$client$file_reloading$figwheel_require (jar:file:/Users/will/.m2/repository/figwheel/figwheel/0.5.14/figwheel-0.5.14.jar!/figwheel/client/file_reloading.cljs:179:30)
nil
😩I think, fundamentally, google closure compiler can't cope with a fair number of import/export/etc syntax used in npm modules
I’m trying to help my team get spun up on developing in Clojure(Script) and we’re just getting comfortable using figwheel. there’s also lots of nice templates out there, so I don’t really have to focus as much on getting things like REPL integrations (e.g. CIDER, proto-repl) working
if it was me, I would take a week to learn how to configure shadow-cljs for my use case. but it’s taking a week to learn shadow-cljs (while not getting work done), and then spending 3 weeks helping everyone else learn it
@lilactown I could tell you exactly how shadow-cljs does it but for CLJS i don’t know exactly myself unfortunately
in theory it is looking at node_modules/glamorours/package.json
main
entry and then loads that file
I removed jsnext:main
and module
fields from the package.json, leaving only main
, and it worked
I'm struggling a little with the cljs API. I have a .cljs
file containing a series of forms on my classpath and want to obtain the corresponding javascript as a string. I can get it through the analyzer, but don't know how to get the javascript emitted:
(with-core-cljs nil (fn []
(analyze-file "us/quartyard/wat.cljs")
(println(all-ns)) ;; prints essentially what I expect.
(now what???)))
Any help would be most appreciated.