This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-26
Channels
- # architecture (2)
- # beginners (310)
- # boot (34)
- # cider (50)
- # cljs-dev (82)
- # cljsrn (1)
- # clojure (125)
- # clojure-dusseldorf (1)
- # clojure-hamburg (1)
- # clojure-italy (47)
- # clojure-russia (21)
- # clojure-spec (38)
- # clojure-uk (36)
- # clojurescript (200)
- # community-development (21)
- # cursive (10)
- # datomic (15)
- # duct (58)
- # emacs (20)
- # fulcro (10)
- # funcool (1)
- # graphql (2)
- # hoplon (6)
- # jobs (1)
- # lumo (12)
- # mount (20)
- # off-topic (14)
- # om (5)
- # portkey (43)
- # protorepl (2)
- # re-frame (31)
- # reagent (36)
- # ring (17)
- # ring-swagger (6)
- # shadow-cljs (50)
- # spacemacs (9)
- # sql (5)
- # tools-deps (28)
- # uncomplicate (4)
- # unrepl (5)
- # vim (2)
- # yada (2)
am I going crazy? i thought you could have a my-ns.core
that’s my_ns/core.clj as well as a my_ns/core.cljs and it’s totally fine? for example, if I wanted to do this:
(ns my-other-ns.core
(:require [my-ns.core :refer-macros [some-macro]]))
this is all fair because a cljs compiler knows that the .cljs file doesn’t have macros, so it must the .clj file I’m referencing?It is totally fine but the my-ns.core
CLJS file must have a (:require-macros [my-ns.core])
for the :refer
to work.
so the CLJS ns must require "itself" for others to be able to refer to macros directly
i ended up figuring out the issue was that one of my macros refered to my-ns.core/some-js-fn
and I was unintentionally using (:require [my-ns.core :as some-js-ns]
) which isn’t allowed
My understanding is we cannot require .clj from cljs file. So your code may not find proper macro…
@lwhorton try doing (:require-macros [my-ns.core :refer [some-macro]])
How do I do npm deps with cljs10?
I want to simply try out loading react and react-dom per npm-deps
It did work with the previous cljs 1.9 release
Now it appears that the process shim is broken somehow
The compiler emits production code for react-dom. That invokes react-doms mysterious checkDCE function that breaks everything.
I had to set :process-shim explicitly to true (doc says its set true by default but at least with -r it isn't)
But even though in runtime process.env.NODE_ENV is "development", the compiler has emitted the production stuff and react-dom won't load
I have disabled aot-cache
Or are there new requirements
how to use npm deps ?
@leongrapenthin it sounds like you’re talking about an issue specific to React
but I can’t offer any more real information, I tested with a bunch of other libs, but not React recently
@dnolen Well it worked with the last stable 1.9. Also my brief debugging session indicated that :process-shim simply doesn't work as it did before anymore. It is not enabled by default, and it appears to set NODE_ENV to "production" during code emission and to "development" only later. So should I file a ticket or repro this?
react-dom/index.js has this line "if (process.env.NODE_ENV === 'production') {"
it is eliminated and the code for the true case is emitted
:)) will look into it later today
@leongrapenthin process shim stuff is all in cljs.closure
, but if you what you says is true you should also just try to set the :closure-defines
yourself
ClojureScript 1.10.238 is released https://clojurescript.org/news/2018-03-26-release
I have a strange issue. Cursor jumps to the end of the atom-powered textfield each time I edit it.
This is a fairly common issue that pops up in managed components. The reagent channel would probably have more input, but one link has already been provided here I see.
think it's because :defaultValue just sets the init-state within the input element, and then leaves it unmanaged
I couldn't figure out why the mui input field acted like that either, i'm using it within rum. I'm guessing you're using reagent?
@achikin Check https://github.com/madvas/cljs-react-material-ui/issues/17 it shows some workarounds (best workaround would require Reagent change)
Tried to use npm library by :npm-deps. I add :npm-deps {"react" "16.2.0" "react-dom" "16.2.0" "create-react-class" "15.6.3" }
to cljsbuild compiler option. But there is this code
if (process.env.NODE_ENV === 'production') {
// DCE check should happen before ReactDOM bundle executes so that
// DevTools can report bad minification during injection.
checkDCE();
module.exports = require('./cjs/react-dom.production.min.js');
} else {
module.exports = require('./cjs/react-dom.development.js');
}
in index.js
file of react-dom package, while the compiled version just eliminates the if
and treat NODE_ENV to true, the result is always throw an error.The value of process.env.NODE_ENV
is "development". Does not know why closure compiled version treat the if
clause as true?
@dumeng81 @leongrapenthin duplicate report
yeah, setting :closure-defines {"NODE_ENV" "development"} doesn't do it unfortunately
{:npm-deps {:react "16.2.0"
:react-dom "16.2.0"
:create-react-class "15.6.3"}
:externs ["process.js"]
:main "hello-npm.core"
:output-to "resources/public/main.js"
:output-dir "resources/public/js/out"
:asset-path "js/out"
:optimizations :none}}
@leongrapenthin that isn’t how :closure-defines
works
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L2216
I'm running Cljs 1.10.238 + Reagent 0.8-alpha2 with Node modules and it is working for me.
it doesn't work with explicitly setting :closure-defines {"process.env/NODE_ENV" "development"} either
very strange that the compiler emits the production clause
Oh right, the error is from Chrome React Developer Tools
I don't usually have that enabled so haven't seen this error
If you check process.env.NODE_ENV
on browser, it is correctly set to development
It is just that the React 16 CommonJS bundle is completely insane
@juhoteperi can confirm that disabling dev tools does the trick
React 15 would also work
nonetheless if you compare react-dom/index.js from the node_modules folder with the node_modules folder in the compiler output it makes no sense
This is Closure-compiler bug: https://github.com/google/closure-compiler/issues/2841
the call to checkDCE should never be emitted
This problem is not related to process.env at all
is it only since 1.10 because closure compiler has been updated?
@juhoteperi Thanks for all the clarification.
and also @dnolen for helping invalidate my theory quickly 🙂
Hi! Any help with this please? https://clojurians.slack.com/archives/C053AK3F9/p1522072000000173
it’s found at the indexed location there under https://repo1.maven.org/maven2/org/clojure/clojurescript/1.10.238/
however, that error sounds like it might be related to security. I’m curious what version of Java you have installed (`java -version`)
@alexmiller we followed up in #beginners
I have seen people report this, but I don’t remember why
things to check: use -Sforce
to ensure you don’t have any classpath cached, see if this works if you go via leiningen dep, check whether you have anything funky in your Maven ~/.m2/settings.xml
@alexmiller Weird. After reinstalling 9 -> 8 -> 9, it works with jdk 9 too now. And I did wiped .m2, and the local .cpcache and ./out
hard to tell which one of those was important :)
Well, enough to move on for me now. @alexmiller thanks!
Looks like there's a lot of new information (or maybe I'd just missed it before) about using npm dependencies and stuff.
Hello guys, is there an alternative for Redux Offline on Cljs? Or just a good guide to PWAs?
Oh! I should had paid more attention to the guide then
Anyone know of any good shopping sites (perhaps with code available) written in Clojure?
With respect to everyone involved. Is their a difference between lumo and clj for the purposes of creating a executable node js file. Both aim to produce a js executable, right?
@drewverlee Most notable difference is that lumo uses self hosted clojurescript and lets you execute scripts without setting up a project. So it’s very suited for one off scripts.
Of course clj with cljs.main lets you do the same now, but the startup time is longer
and you require a JVM, which is not all that bad though, but for a little script it can be too much
@drewverlee another thing to add for js transpilation is that the Closure compiler port to JS is not completely the mirror of the JVM one. YMMV
Question: Is there anything like babel/coffee-script translator for CLJS? like: https://babeljs.io/repl/
@quang You can try KLIPSE: http://app.klipse.tech/
Cool. Another alternative is to use Lumo or Planck with -v
, which will cause them to print out the JavaScript for any form you enter. Or use any REPL in :repl-verbose
mode http://blog.fikesfarm.com/posts/2015-06-15-see-js-in-cljs-repl.html
hey is (.format(js/moment))
no space after .format, proper? or is that considered bad style?
Another example showing how trivial it now is to put a REPL in verbose mode is at the very bottom of https://clojurescript.org/news/2018-03-26-clojurescript-command-line
The first form seems to kind-of imply that you are calling format with an argument of js/moment
But really it is evaluating a call (js/moment)
and then passing that as the first argument to .format
By the way, since you are looking into JavaScript interop, there is a draft guide that hasn't yet been published, might be useful https://github.com/mobileink/clojurescript-site/blob/88805681e76a86dcab068ec8b574ed733ebd5f8c/content/reference/javascript-interop-ref.adoc
(js/moment"2018")
is a bad idea because, even though I work on the ClojureScript compiler, to be honest, I would have to try such an expression to see if it is even handled properly 🙂
I mean, I guess we should all immediately know if (js/moment"2018")
is well formed, but, life is short 🙂
> I would have to try such an expression to see if it is even handled properly hmm :thinking_face: yeah I'm surprised it compiles... but I guess that might change in the future? it seems like it should throw an error
Yean @dnolen I think we just need to wrap up the draft. It is too useful to not have 🙂
http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/ - was the best I guide I found before @mfikes’s link
Well, the semantics of (js/moment"2018")
are probably well defined, but I suspect if you try to elide spaces around lots of code, you might find things that don't work as expected.
For example, I think this used to work in very old versions of Clojure: (#(str%1) 1)
if moment("2018")
is correct from the console, then (js/moment "2018")
would be valid. what’s wrong with it, despite the deprecation warning you’ll get from this library?
That wip page is a bit too much and cover stuff we don’t want to cover, we just need a minimal page with the basics
I used to go to http://himera.heroku.com/ for a cheatsheet on js interop, but it’s down
That would match the conciseness David mentioned. We should get the Heroku examples, which were to-the-point and useful.
you can still run this locally: https://github.com/fogus/himera
fyi I guess (js/moment2018)
would definitely not work as wanted (passing a number), so I guess it's better to always add that space...
IMHO, whitespace formatting in Clojure has never really been an issue. It is mostly about where to choose to put forms on new lines that are getting a little long.
In other words, it truly does become difficult to discern who wrote a bit of code because it is so uniform.
I have a contrasting experience, I can detect several other members of my team from the code.
(You know, you've worked on projects in other languages where you can just tell by the style, who on the team wrote that code 🙂 )
Ahh, I haven't had the pleasure of reading much of his code. I should do that more frequently.
@U060FKQPN other than the attribution, what's unique about his ns form?
judge for yourself https://github.com/ztellman/aleph/blob/master/src/aleph/flow.clj#L1-L27
@U060FKQPN I see that anytime people use refactor on the default settings. I'm quite used to that, even though I suggest they turn it off.
Yeah, that's what I was referring to. Perhaps Nathan's style has changed, but the closing parens on their own lines was very unconventional looking.
Elm has a nice philosophy on that, they use whatever whitespace that's causes less diff's
> Goal: a consistent style that is easy to read and produces clean diffs. http://elm-lang.org/docs/style-guide
Golang is super fun with diffs on Github. All those super wide 8-space “tab only” indentations.
I think you can fix it a bit with ?ts=2 on the URLs for github, but there’s no way I know of to make that persistent.
I’m using doo and phantomjs for my cljs unit tests and my test diffs are really hard to read. Are there any tools that can pretty print the result and maybe even highlight the what’s different?
If you're using karma, you can try to upgrade to newer version of karma-reporter (https://github.com/honzabrecka/karma-reporter). Doo has dependency on some older version.
I managed to get pjstadig.humane-test-output to work for pretty print
It does the diff too
I’m using promesa with some Node code on AWS, and I’m suddenly getting “Should be only used in alet macro.” errors, which should be catching uses of await
outside of alet
. But all mine are within alet
s - does anyone have any idea why that might happen?
@cfleming I know that go
blocks can’t traverse function boundaries and the promesa docs say it is using go
machinery, so I wonder if that’s your problem?
@lee.justin.m Interesting, I hadn’t considered that. But there’s nothing in the doc or the docstring to suggest that sort of restriction around its use.
I would be shocked, shocked I say, to learn the a clojurescript library docstring was anything less than comprehensive. 🙂
However this did previously work for me, so something odd has changed. Perhaps a clean build is in order.
and i could be wrong. although i’ve looked at the promesa library many times, i haven’t yet tried it
There has to be a better way than what core.async is doing right now, so maybe I’ll try it.
Yeah, I like it better than core.async, especially for code which is really emulating synchronous calls (like AWS)
This is what I was referring to, fwiw: https://github.com/clojure/core.async/wiki/Go-Block-Best-Practices#unsupported-constructs-and-other-limitations-in-go-blocks