This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-04
Channels
- # aws (1)
- # beginners (163)
- # boot (1)
- # bristol-clojurians (1)
- # cider (7)
- # clara (1)
- # cljs-dev (22)
- # cljsjs (1)
- # clojure (43)
- # clojure-denver (1)
- # clojure-finland (6)
- # clojure-italy (1)
- # clojure-nl (3)
- # clojure-russia (1)
- # clojure-spec (1)
- # clojure-uk (6)
- # clojurescript (107)
- # cursive (4)
- # data-science (2)
- # datascript (2)
- # datomic (19)
- # duct (31)
- # emacs (1)
- # fulcro (50)
- # graphql (15)
- # hoplon (3)
- # lein-figwheel (2)
- # luminus (21)
- # off-topic (74)
- # onyx (3)
- # parinfer (15)
- # portkey (2)
- # precept (9)
- # proton (1)
- # re-frame (130)
- # reagent (73)
- # reitit (7)
- # ring-swagger (5)
- # shadow-cljs (61)
- # spacemacs (18)
- # specter (12)
- # uncomplicate (1)
- # vim (88)
- # yada (2)
Hello everyone! I write my own library, it is a reagent component. I use re-com and I want to catch errors from It, but I can`t. Can you explain how make this work? That is what I wrote https://pastebin.com/PfEipjLB As you see I want catch an error and return reagent element with info about the error
I sought how re-com work with errors and i found this https://github.com/Day8/re-com/blob/master/src/re_com/validate.cljs#L19
From the look of it (and not knowing much about reagent specifically), it seems that there's nothing to throw an error there. That declaration just creates a data structure. You'll have to write a try/catch around the code that actually uses the structure.
What's the error you're getting?
When i pass invalid argument to the v-box component for example
Error rendering component (in pozn_adaptive.views.main.main_panel > swipe.views.slider_component > re_com.box.v_box)
---
Validation failed for argument ':height' in component 'v-box': Expected 'string'. Got '900' at pozn_adaptive.views.main.main_panel > swipe.views.slider_component > re_com.box.v_box
---
Uncaught Error: Assert failed: (validate-args-macro v-box-args-desc args "v-box")
...
It looks like you've got a type error. Try wrapping "height" in (str)
{:height (str height)}
Also, it's best to be specific with the units, so I would recommend passing "900px" to :height
rather than "900"
Regarding re-com errors, the message above is re-com trying to provide a "helpful" message when it gets an argument it doesn't accept
I agree about specific units. But why I was confused about errors is that If an user pass to the component an incorrect string, for example "100ggggg" How i can catch It? I can write my own validator, but why would I do it if re-com have this validators already?
If I understood you correct you want to say that re-com just provide me info about incorrect arguments and not throw errors?
In the case of v-box
, here is the line that is throwing: https://github.com/Day8/re-com/blob/master/src/re_com/box.cljs#L300
It will NOT cause an exception in your prod builds (it's stubbed out), but you will get unexpected behaviour
When using :npm-deps
how do I require a modules sub-package? How do I require devtools in this example
Using ES6
import { Controller, Module } from 'cerebral'
import Devtools from 'cerebral/devtools'
cljs
(ns app.core
(:require
;; [cerebral/devtools]
;; [cerebral.devtools]
[cerebral]))
@codonovan in shadow-cljs you can use string includes (:require "cerebral/devtools")
. I don’t know if that works with npm-deps, but maybe give it a shot?
@lee.justin.m Was not aware of shadow-cljs. Will have a look see. Thanks
@codonovan this might help https://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d
Hello. I tried to use :npm-deps
on ClojureScript 2.10.238
with this module ( https://github.com/Stanko/react-animate-height ) and include it into Reagent project, but with advanced opmtimization it didn't work. After few hours of debug it seemd that this line in React https://github.com/facebook/react/blob/master/packages/react/src/ReactBaseClasses.js#L26 was optimized away by Google Closure Compiler. Does that seem realistic?
It is possible, though it is not obvious why this would only happen with react-animate-height. I'm running tests with just React and no problems.
You might want to test with new Closure-compiler release (it works with current Clojurescript), it fixed one another problem: https://github.com/reagent-project/reagent/commit/35a04a612565419375bc0eab91774ac7a80aecef
Anyone know how I can find out what JIRA issue this attachment is part of? https://dev.clojure.org/jira/secure/attachment/17793/cljs-master-error.txt
that's mine, don't remember the ticket, but I think it was solved.
not sure though, will try to dig
nope, the error still seems to happen here
yes still getting the same error, it looks like the dependencies cannot be computed correctly here, no sure though
I don't understand how that ticket relates to the npm-deps error. I get my error when trying to build with leiningen cljsbuild.
might be different then
I would suggest you to reproduce it using the cli tool so that you exclude tool-specific problems
I have actually tried right now to put -c
at the end of the command line invocation and magically it started to work:
clojure -Srepro -R:cljs-jvm -m cljs.main -O simple -t node -c ep-cloud.handlers
Is there some guide on how to troubleshoot these compile/build errors using something like you did there?
I'm getting errors in build all the time and having a hard time troubleshooting them. Have to learn to isolate the issues somehow.
the cljs.main
feature is kinda new, I usually just enable :verbose
and see what happens. In case of :npm-deps
there is really little you can do, probably just report it here.
I mean lein
I have actually tried right now to put -c
at the end of the command line invocation and magically it started to work:
clojure -Srepro -R:cljs-jvm -m cljs.main -O simple -t node -c ep-cloud.handlers
why do i sometimes get stack traces to things that look autogenerated? i have an error in a partial function application and part of the stack trace looks like
at G__29817__1 (core.cljs:4260)
at G__29817 (core.cljs:4263)
. those two lines point to the implementation of partial
. i just don’t quite understand where those G__29817
symbols come fromthose are gensym
symbols. used in macros mostly when you need a "hygenic" variable name
@thheller what’s confusing is that there don’t appear to be any macros in the definition of partial
yeah, but partial is a defn
with multiple arities. those get unrolled. G__29817__1
is the function with one arg basically.
Does any of the alternate CLJS runtimes (Lumo, Planck etc.) consider “reified vars” a priority? (I’m just curious about design considerations.)
@kumarshantanu Lumo and Planck simply act as shells to host self-hosted ClojureScript, from that perspective.
Thanks for the pointer!
I’ve tried (ns my-ns (:require bar)) (bar/foo)
, (ns my-ns (:require [bar :refer [foo]])) (foo)
and whatnot
Hi, I am using the advanced compilation of clojurescript with the infer-externs
option set to true. Now I get warnings like these:
Apr 04, 2018 6:52:47 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNUNG: target/cljsbuild-compiler-2/inferred_externs.js:20: WARNING - name goog is not defined in the externs.
goog.fx;
^^^^
When I look into the resulting inferred_externs.js
file I can see goog.fx added. Do I have to do something now or can I just ignore the warning?@mattly if those are exported by default exports you made need access differently see https://dev.clojure.org/jira/browse/CLJS-2376
@dnolen there it is: https://github.com/sveri/cljsinferrepro the compilation still shows one error like this, you can see that in the readme. I hope that is sufficient.
@dnolen I missed the hint I should do it against master. How can I refer the master build in leiningen?
For my clojurescript :advanced compiles, I seem to be consistently hitting 300k on the low end with a brand-new lein chestnut setup. That seems... oddly big? Is there a way to get that down?
gzipped with 7z is 78k. That seems better 🙂
Hm, using clj I cannot reproduce it with the latest stable version nor with the latest master version.
But there is a difference in the generated inferred_externs. The stable version contains entries like: goog.isArrayLike; var goog;... while the master version does not and contains a few lines less. Maybe somehow I am not printing warnings during compilation?
Not sure if this is the right place to ask but I'm doing a write-up on cli scripting with cljs (lumo) and wonder if anyone wants to help me proof-read it before I publish...
Guess I'll leave a link to my draft here in case anyone's interested: https://medium.com/@akiroz/command-line-scripting-with-clojurescript-5e5567367713
the require for fs can be simplified to
'[fs :refer [writeFileSync]]
also this is only partially true at the moment: > Unfortunately, there isn’t an easy way to manage dependencies on the Clojure side just yet so for now we are stuck with manually installing JARs to your local maven repo.
I wrote something in the wike: https://github.com/anmonteiro/lumo/wiki/Run#using-clojurescript-libraries
and you can use npm
modules directly
so you can use cljs packages published on npm
by just adding them to your package.json
at the moment no many on there, see the list
good job overall 😄
Great article! Who is the audience? I feel it could be clojurists or JS developers, which is great 🙂
Just a few notes:
> As you can see, the require function can now act like its JS counterpart and pull in JS modules as you would with the following code:
For the above, perhaps illustrate the "counterpart" you are referring to. I mention this because it might gain a larger JS audience if they feel like you are speaking to them too.
> Integrating with NPM
This section is a little unclear to me. Does request not have to be npm installed
? If yes, maybe show the steps? The concern is that a lot gets lost if steps are removed and then people become disgruntled and blame it on the technology 😞
> Who is the audience? A friend of mine who's getting started in the cljs world 😉 I'm not exactly sure how it ended up being an article half-way through.... > If yes, maybe show the steps? Got it, will make some edits today~
@akiroz there is also a #lumo chan but here should be fine as well
I will have a look
@richiardiandrea thanks!
I'm trying to use Google's Workbox. With cljs-oops, I call (oget js/self "workbox" "precaching")
. Error! Great. I spent half an hour trying to understand why, before trying. (.-precaching (oget js/self "workbox"))
, which magically functions.
@achythlook hm, maybe look at generated javascript and compare both cases?
in repl you can use a trick with anon function and .toString
on it, e.g. (.toString (fn [] (oget o "prop"))
Welp, one is wrapping the call to "precaching" in a bunch of oops calls, and the other is straight dot access after the oops calls.
Which means... I'll need externs? Or is there another way to sidestep them?