This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-25
Channels
- # 100-days-of-code (6)
- # announcements (4)
- # aws (2)
- # beginners (151)
- # boot (1)
- # calva (1)
- # cider (19)
- # clara (47)
- # cljdoc (9)
- # cljs-dev (25)
- # clojars (18)
- # clojure (151)
- # clojure-canada (1)
- # clojure-conj (1)
- # clojure-dev (17)
- # clojure-italy (42)
- # clojure-nl (34)
- # clojure-spec (67)
- # clojure-uk (125)
- # clojurescript (163)
- # core-async (106)
- # cursive (19)
- # data-science (11)
- # datomic (9)
- # duct (2)
- # figwheel (1)
- # figwheel-main (6)
- # fulcro (97)
- # graphql (9)
- # instaparse (4)
- # jobs (6)
- # jobs-discuss (21)
- # leiningen (62)
- # mount (23)
- # off-topic (16)
- # re-frame (15)
- # reagent (16)
- # reitit (5)
- # remote-jobs (1)
- # ring-swagger (9)
- # shadow-cljs (176)
- # tools-deps (102)
- # unrepl (3)
@jamie857 you need window
or just global context?
would js/Electron
work for you?
@U1V7K1YTZ appreciate the response here. I think I'm focusing on a symptom of an overall problem here. Been a tough go getting Electron & Figwheel main playing well together
I ran into some issues trying to compile a ClojureScript node.js project. Basically, when I run cljsbuild with optimizations :none
I get something that works, but any other optimizations produces Cannot find module "../moment"
, which comes from cljsjs.moment. The code that requires moment is already working in an existing browser app with advanced optimizations… Has anyone seen anything like this?
I have reproduced the issue in this repo: https://github.com/cjohansen/cljs-compiler-woes
@christian767 I'm assuming you need compilation under Node.js for some reason? Like AWS Lambda?
I wanted compilation in order to have a single file, and not use the goog module loading stuff
the strange thing is that I didn’t touch any of the code using moment - it’s just :require
d from an existing browser app
anyway - the build does work in the browser in the repo I posted above. even with optimizations
;(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' && typeof require === 'function' ? factory(require('../moment')) : typeof define === 'function' && define.amd ? define(['../moment'], factory) : factory(global.moment)}(this, (function (moment) { 'use strict';
@dnolen sure, but my test actively loads the offending code and uses moment to print a formatted date
you could use shadow-cljs where its just (:require ["moment" :as moment])
for both node and the browser 😉
my biggest problem right now is that I’m trying to reuse some existing code, so the moment require isn’t in my new code. and I’ve seen the same problem with React etc
cljsjs.moment
will work as well in shadow-cljs since the shim already exists https://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/moment.cljs
question: the unoptimized package (which is a CLI tool) seemed a little slow to me (longer startup times than I’m used to with pure node apps). I assumed this was due to loading lots of files, and that a simple compile to one file would alleviate it
but this was just an assumption. would :simple
optimized cljs be faster than :none
?
you’re saying that I could even use cljsjs.moment successfully with optimizations with shadow-cljs?
I agree that its not all that useful to go for :advanced
in node but it does make a difference in startup time
back in when there was ton of data structure work, I would benchmark both :advanced
and :simple
+ the other needed bits
these flags control the ClojureScript compiler and take effect regardless of :optimizations
I'm having some issues with using reagent with cljsjs/material-ui. When using material-ui/Input (after adapting) as a controlled input, and using android irefox (desktop Firefox works fine), the input does not correctly fire events. Lets say I tried to type "example" into the input. When "e" is pressed, the input reads "e" When "x" is pressed, the input reads "eex" When "a" is pressed, the input reads "eexea" When "m" is pressed, the input reads "eexeaeexm" When "p" is pressed, the input reads "eexeaeexmeexeap" And so on. This bug only occurs on Firefox for android, and does not occur on Firefox Focus for android. Has anyone run into this before?
I suspect that problem probably affects direct usage from JS - if so, might want to check the material UI issues first?
I haven't seen any issues on their github, and pure js material-ui on their example site seems to work fine.
I did notice that the on-change function was called twice, although Im still not sure why that would cause problems, unless there is something wrong with the event itself.
Not the latest version of material-ui, but didnt see any mentions of firefox in their changelog.
I would probably debug this a bit further then to make sure it's not something logic related or ClojureScript specific (which I'd be skeptical about)
I got it down to a pretty simple failing example: (defonce text (reagent/atom "")) (defn input [] [material/Input {:value @text :on-change #(reset! text (-> % .-target .-value))}])
It seems that in all other browsers, on-change is called once, with the correct event.target.value. In firefox it is called twice: once with event.target.value as "", and once with the screwy result.
Not sure why this only happens in cljs, as I dont see anything cljs specific.
Found the reagent channel, Ill ask there.
I have a question about figwheel! When I make a new reagent project using lein new reagent
, how would I require
a javascript file? I'm thinking of a hypothetical scenario where I wanna make a new clojurescript project but reuse my react components!
@odd.andreas the most robust standard way is https://clojurescript.org/guides/webpack
you can't really just require JS files since usually there's a lot of assumptions baked into your JS
ok thanks! I was hoping to be able to import js files in a less robust way just while I was experimenting I guess 😄
in the old days when people shipped real "just" JS files like jQuery etc. this was trivial
When figwheel is running and I modify a file, figwheel fails in docker and I receive exception: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
This worked for me a while ago https://gist.github.com/vharmain/9dda15880b1b93ede2ec2045040b0d26
However I’m not using that setup anymore. I’m running figwheel on the host because io is quite slow with mounted volumes and It’s a bit of a hassle. I run other parts of my dev setup (db, elasticsearch etc.) in docker still though.
..and if I were building a new setup, I’d use figwheel-main instead of lein-figwheel, for simplicity.
I’ve got an if syntax exception now manifesting itself as:
java.io.NotSerializableException: clojure.spec.alpha$regex_spec_impl$reify__2436
Not sure if that’s my tooling or something specific to cljs 🙂@borkdude https://github.com/boot-clj/boot-cljs/pull/181 & referenced issue, boot-cljs tries to serialize exceptions to move them from threads to another but that fails for some classes
thanks @juhoteperi
@borkdude Hmh, as I haven't come up with proper solution ten months I think I'll just merge the workaround, so fix should be available soon
anyone cop this? https://reactjs.org/docs/hooks-intro.html 👀 🤯
This is odd to me because I thought React started with using functions and was then starting to push for js classes (which I haven’t been a fan of). And now going back away from classes? Hah.
it's always used classes. just for awhile, it had it's own "class" implementation 😅
I just felt like there was more emphasis on using functions as components before and then a bunch of features kept becoming you could only do by defining your own class.
:thinking_face: I don't think it will break reagent? unless you mean something different
and in reagent things are in weird order because it first constructs the hiccup vectors
but I see it as providing a lot of the same ergonomics as what the reagent + ratom API gives us today, in bare React
https://reactjs.org/docs/hooks-reference.html#conditionally-firing-an-effect has some info on how to ameliorate that
but IME creating new functions on each render is a pretty low-value optimization compared to many other things
In the clojurescript compiler config for a reagent project, I have :foreign-libs with one of the libs having :global-exports of {create-react-class preactCompat.createClass}
. This was working w/ earlier cljs but isn't working now - the generated js looks like $goog$global$$["preactCompat.createClass"]
, but to be able to read an object property for an export, it should be $goog$global$$["preactCompat"]["createClass"]
or something equivalent. Does this look like a bug or is there another way we're supposed to export object properties as namespaces?