This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-05
Channels
- # aws (6)
- # beginners (10)
- # boot (33)
- # cider (23)
- # cljs-dev (50)
- # cljsjs (2)
- # cljsrn (10)
- # clojars (1)
- # clojure (215)
- # clojure-czech (1)
- # clojure-dev (5)
- # clojure-italy (23)
- # clojure-russia (18)
- # clojure-spec (11)
- # clojure-uk (53)
- # clojurescript (157)
- # core-async (29)
- # cursive (12)
- # data-science (15)
- # datascript (16)
- # datomic (68)
- # graphql (2)
- # jobs (5)
- # jobs-discuss (1)
- # juxt (17)
- # lein-figwheel (2)
- # luminus (3)
- # off-topic (155)
- # om (3)
- # pedestal (1)
- # portkey (1)
- # re-frame (7)
- # reagent (4)
- # ring (3)
- # ring-swagger (2)
- # rum (11)
- # unrepl (11)
- # vim (1)
- # yada (2)
Ok, weird I must be missing something with cljs macros. All parameters to macros seem to be the symbol/form and not the evaluated values.
that's what macros are- the evaluated parameters happen well after the macro is gone
a macro takes a form (with symbols in it, usually), and returns a new form (usually using the same symbols)
by compiling code at runtime
macros are meant for syntax, they don't act on values, they act on forms
(which are values consisting of literal data in a source)
no, same goes for jvm clojure
your macros don't see runtime values, they see the forms in the source
are you trying to use the macro from the same compilation unit thatdefines it? that doesn't work in cljs
the macro itself, yes, but when calling the macro, it's using the forms in source as well, but only in cljs.
#om has anyone gotten the hello example (or any of the examples) in the om repo to work? I get the following error. clojure.lang.ExceptionInfo: Invalid :refer, macro cljs.pprint/deftype does not exist in file examples/hello/out/cljs/pprint.cljs {:tag :cljs/analysis-error}
It seems I am not alone. @pedroteixeira revieved the same error 2017.05.28 https://clojurians-log.clojureverse.org/om/2017-05-28.html Is this something I should post on the github as an issue? Or is there some work around.
I am able to get a clojure project compiled with cljs/pprint.cljs in the out folder when doing the clojurescript getting started tutorial. I am not sure if there may be an issue with lein cljsbuild.
Are there any cljs http libs out there that can handle different response formats between success/error?
Anyone know how cljs.test
actually runs my tests? (like what environment does it use?)
@ssaul @pedroteixeira try bumping the clojurescript version to 1.9.562
I got the following warnings:
WARNING: Use of undeclared Var cljs.pprint/pprint at line 15 examples/hello/out/devcards/util/utils.cljs
WARNING: Use of undeclared Var cljs.pprint/with-pprint-dispatch at line 23 examples/hello/out/devcards/util/utils.cljs
WARNING: Use of undeclared Var cljs.pprint/code-dispatch at line 23 examples/hello/out/devcards/util/utils.cljs
WARNING: Wrong number of args (1) passed to UUID at line 564 examples/hello/out/cljs/reader.cljs
WARNING: Use of undeclared Var clojure.string/starts-with? at line 822 examples/hello/out/cljs/analyzer.cljc
WARNING: Use of undeclared Var clojure.string/ends-with? at line 972 examples/hello/out/cljs/analyzer.cljc
WARNING: Use of undeclared Var clojure.string/starts-with? at line 2643 examples/hello/out/cljs/analyzer.cljc
WARNING: Can't take value of macro cljs.core/require at line 15 examples/hello/out/cljs/nodejs.cljs
WARNING: require already refers to: cljs.core/require being replaced by: cljs.nodejs/require at line 15 examples/hello/out/cljs/nodejs.cljs
but it compiled.
but when i go to the browser I get the following errors in the console.
Uncaught Error: Assert failed: No target specified to om.core/root
(not (nil? target))
that get's you past compiler failing - just lots of warnings but trying to open index.html you get an assertion that the target is not specified
yeah, i see what you are saying. Show I use an earlier version of om? Is there anywhere, maybe in a readme or that I missed that says what version of clojurescript works with what version of om?
I added a breakpoint at
(om/root widget app-state
{:target (.getElementById js/document "app")})
i tried document.getElementById("app")
but I just got back null in the browser.
ohh you are doing some real debugging. nice!
hmm ... outta my depth here ...
([f value {:keys [target tx-listen path instrument descriptor adapt raf] :as options}]
(assert (ifn? f) "First argument must be a function")
(assert (not (nil? target)) "No target specified to om.core/root")
options seems to have all the values but the keys have not been extracted
options.root.arr[0].tail
(2) [c…s.c…e.Keyword, div#app]
0:
cljs.core.Keyword
cljs$lang$protocol_mask$partition0$: 2153775105
cljs$lang$protocol_mask$partition1$: 4096
fqn: "target"
name: "target"
ns: null
_hash: 253001721
__proto__: Object
1: div#app
length: 2
__proto__: Array(0)
nah, it is all good. you have already helped greatly. I will take a look at what you have sent. Thanks!
Hi is there a way to hotload clojurescript apps in production?
I'd like to propose a new variant of cljsjs/react
called cljsjs/surrrogate-react
, which only includes the externs file and an empty react.js
Including this dep would make it possible to (require 'cljsjs.react)
without errors, except that it wouldn't actually include react source files
Requiring this would be a cleaner version of including src/cljsjs/react.cljs
in your project
We'd also need cljsjs/surrogate-react-dom
.
@juhoteperi what do you think of this idea?
Sounds like a workaround and won't solve using npm-deps with Reagent etc.
@pesterhazy React 16 will also drop react-with-addons so react/react-dom/react-dom-server can all be provided by single cljsjs package
At least that will make using alternative versions a bit easier as there one less exclusions will be needed
yeah it's a workaround, but a useful one for a lot of people
for example, everyone in react-native land has this weird empty namespace in the src folder
having a surrogate dependency available from a trusted source would reduce that to a single line in project.clj
The externs could be provided in separate package, that would help a bit
right
although I'm not sure we even need externs for React
with npm-deps they are at least required, I don't know about react-native
I'm guessing reagent will work without externs, but not sure about the other wrappers
would you be open for a PR to add surrogate-react?
Hmm, perhaps this would be good opportunity to also deprecate react-with-addons and merge the three packages
wouldn't react and react-dom still be separate?
One package can provide the all three foreign-lib namespaces
yes that's true, but you might want to selectively mock out only react or react-dom
Merging the packages prevents problems with mismatched react & react-dom dependencies
Hmm, I think that can be achieved by adding local foreign-lib entry for react or react-dom
Not sure if local cljs namespace would also overwrite a foreign-lib
not sure I understand
If cljsjs/react
provides both cljsjs.react
and cljsjs.react-dom
foreign-libs, those can be mocked out by providing local foreign-lib entry in the project, or with cljs namespaces with the same name
right
but that would still require adding an empty js file to your project, right?
But how common it is to mock only one of them?
react-native project, for example, don't require react-dom
but you're right, that wouldn't mean selectively mocking out only one
so your idea is that cljsjs/react
provides both libs, and you just don't get react-dom if you don't require it?
But I guess that can cause problems with Reagent as it has require on react-dom
honestly I always liked the fact that the dependencies were explicit
it mirrors the way react and react-dom are packaged by facebook
My thinking is that in future we need to somehow remove these dependencies from libraries (Reagent) and let the users select in project select if React is provided from npm-deps or cljsjs or whatever
But not sure yet how we can achieve this
Yeah that is true also
I remember when I first got into reagent, the empty react namespaces confused the hell out of me
PR welcome for surrogate packages
cool 🙂
Probably best to modify react build.boot to build these artifacts so it is automatically updated with new versions and that way you can also easily include the externs
yeah I had a quick look at how to modify it
https://github.com/cljsjs/packages/blob/master/react/build.boot#L55 perhaps a another with-files
here which doesn't use download
but for example sift
to copy a empty file in resource-paths to a correct path & pom with modified name etc.
what does with-files do here?
It is implemented just before the package-part, it creates a filtered copy of fileset and runs the given task pipeline with that fileset and merges the results back to original fileset
ok I'll give it a try
hello everyone, i’m quite new to clojurescript so here’s my question - what’s the best way to write react apps now? om.next + figwheel + re-natal ?
@charafau I’m not sure about “best”. om.next
is one way - reagent/re-frame are also very popular way. You also have Rum. Conceptually om.next
is more like Relay / Relay Modern than plain React. re-frame is more like say Redux.
@charafau You mentioned re-natal
. For mobile, be sure to check out #cljsrn and http://cljsrn.org
Hello.
When using reagent/create-class and defining :component-will-update, is it possible to call component-will-update on a child component?
I guess a work around could be taking the namespace of a random ::keyword , but I do have a feel there is something better
@iku000888 doesn’t work, can’t be a dynamic var like in Clojure - it could be a file level constant - you can get at the current ns via your own macro though.
hello good sirs. may I ask if figwheel has a proxy option?
Well "updatedBy" is certainly not the same as "updated-by"
Hello. Is it possible to compile ClojureScript to output, which I'd be able to later compiler with Google Closure compiler myself (Please don't ask what for 🙂 )?
@andrewboltachev that’s optimizations :none
thanks @dnolen !
uhm... still have that ERROR - Missing @define annotation
sounds like you’re either using JS module processing in your project or something less typical like that
in fact I'm trying to make advancedly-compiled bundle which consists of regular CLJS project, and bunch of JS libraries as well
i.e. I'm trying to concatenate two bundles and use compiler on that result
(I wanted to try if this would work, i.e. I won't need externs that way)
ah yep, I'd better try just to compile the CLJS :none
optimized bundle alone
I thoght so
(but wanted to try anyway)
I know that e.g. React gets around with all that keyMirror
etc things
i.e. there's a reason for keyMirror
to exist
well that’s news to me since we can compile React from NPM and we still needed to supply externs, but maybe there’s new changes I’m not aware of
ah well... I'm providing React separately btw
in JS file
got it. thanks @dnolen
So I'd have either to provide externs exhaustively for all the code or just go for :simple
yes, I don’t think you’ll be able to provide a better pipeline for mixed JS / ClojureScript that’s advanced compilation friendly than the system we already provide
well in theory you could of course but a lot of effort has gone into ClojureScript and tools like shadow-build, starting from scratch doesn’t sound particularly productive at this point 🙂
uhm, the exact point out there that I wanted won't work anyway. So yes, unlikely productive 🙂 Only I might say that real projects actually start needing all that 3-rd party JS components very quickly, and there ain't necessarily externs for all of them (the components themselves are in ES6 etc)
btw, the way I'm importing React is this: http://blob.tomerweller.com/reagent-import-react-components-from-npm
don't know if this is very interesting
but it's not a standard way: > Now, to fool Reagant into thinking that these packages already exist - we’re going to create empty namespaces. <...>
the other way is to use :npm-deps
but your mileage may vary and integrating with libs that use cljsjs.react
is challenging
though I believe even that is probably solveable in Reagent or Om etc. by adding a bit of indirection to React
uhm btw interesting if :npm-deps
use npm
or might use e.g. yarn
as well (or rather independent)
so I think for the greatest impact, try to get :npm-deps
working for your use case and report issues
understandable if not practical because you’re trying to get this working for something you are trying to ship now - but that would be path towards the future
@andrewboltachev it did get me thinking a bit about the problem, I posted some thoughts in #cljs-dev if you’re interested
@dnolen got it, yes, thanks