This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-18
Channels
- # beginners (22)
- # boot (12)
- # cider (3)
- # cljs-dev (12)
- # cljsrn (8)
- # clojure (101)
- # clojure-nl (5)
- # clojure-russia (13)
- # clojure-spec (5)
- # clojure-uk (15)
- # clojurescript (158)
- # cursive (5)
- # datascript (16)
- # datomic (8)
- # hoplon (11)
- # lumo (33)
- # off-topic (3)
- # om (25)
- # parinfer (1)
- # pedestal (8)
- # protorepl (4)
- # re-frame (8)
- # reagent (5)
- # specter (18)
- # sql (1)
- # testing (11)
- # timbre (1)
- # unrepl (2)
- # untangled (1)
Is there any way to split bundles in ClojureScript? I mean bundle the cljs core library part in one file, and others in another?
@johanatan not sure if I’m on state of the art, but I have gotten to a functional state
using cljsbuild and doo
@jiyinyiyong ClojureScript has code splitting via Closure but it involves code motion, so there’s no way to really ensure that some “bundle” is just one namespace or anything
I have what I think is a pretty basic question, which is getting the same effect as JSON.stringify in cljs. So far, I’ve tried not using it at all (and just (.log js/console obj)) using JSON.stringify (.log js/console (.stringify js/JSON obj) and (.log js/console (with-out-str (cljs.pprint/pprint obj)))
the first printed a lot of extra stuff that told me I needed to stringify, the second was not really any better, and the third doesn’t resolve to an actual fn
I think either I need a require, or to address it some other way.
I tried removing the namespace and it wasn’t any better
If I’m using this (http://cljs.github.io/api/cljs.pprint/) do I need to require the ns?
@dpurrington you always need to require any ns you want to use
except js?
it kinda looks like one in the fn references
what ^^
I don’t have to do (.log js/console x)?
either works, generally you should prefer yours, but the other way works for convenience
apparently, cljs is moving so fast SO can’t keep up
heh, @dpurrington in this case this behavior has been around for 5 years
right on. That gave me exactly what I was looking for.
@dnolen , I am looking at Clojurescript git history, trying to understand the compiler, I saw that you started to work on it around late 2011 - can you share how did you were able to get into the project (technically)
should I concern myself with cljs jvm vs js?
regarding the note on [this topic] (http://cljs.github.io/api/cljs.core/): "We are currently only listing the "ClojureScript JVM" implementations here. The "ClojureScript JS" macro implementations are not listed here, but their API is identical of course."
@baptiste-from-paris I just sent some patches
dev activity wasn’t super intense in late 2011 so I got commit rights and I supplied more patches and made sure other people’s patches also made it through - that was it
having a lot of JS expertise also meant that I was well positioned to do a lot of the early runtime optimization work
yes but I guess you had somehow to understand everything - parsing, emiting code
maybe before submitting you first few patches
Yes, I am looking at the First commit ! really instructive
So if I want to understand internals now that codebase is quite big, should I go back at the beginning of the project to simplify things
it’s one of the simplest compiler you could work on - I think other contributors in #cljs-dev can mostly confirm that 🙂
@baptiste-from-paris you can or just find a bug in JIRA that you want to fix and learn that way
@dpurrington ya I gave doo another try and it seems to be working fine now
let me know if you see a way to get more verbose errors from cljs.test
b/c I have an invocation throwing an exception in a test
just a one-line typeerror
@dpurrington 👍:skin-tone-2:will do
huh. So “can’t find x of undefined” is a null reference issue. And I got the stack trace by explicitly doing a (try…). I was missing a parameter in my fn call, which doesn’t get detected in cljs.
(I read that earlier today, no arity validation in cljs)
am i correct in understanding that currently there is no way to use async/await in cljs? node currently has the capability to run them, so i'm interested
@anmonteiro re: :npm-deps {:faunadb "1.0.0"}
that had errors due to reserved words (https://clojurians.slack.com/archives/C03S1L9DN/p1489791634538694) I tried fixing the code in the local node_modules/faundb
folder, but when I ran the build again, it overwrote my changes. Is this cljs or closure handling this piece? Is there a way to pin it or use a local source?
@thosmos for now the solution would be to call cljs.closure/index-node-modules
and pass its result to foreign libs
@anmonteiro found a small one-liner bug in that function ...
go on
can you tell me what you think the bug is first?
if you have signed the CA, you can make a ticket + patch
definitely a bug 🙂
cljs.closure/index-node-modules
worked quite well. it got through the build and now the browser is complaining about a handful of require
s that got skipped. for example: var request$$module$$Users$thomas$Develop$cljs$rimdb$fauna_module$node_modules$faunadb$src$Client=require("superagent");
but it looks like that is a problem with closure-compiler: https://www.refheap.com/133297
@thosmos just looks like the foreign libs array doesn't have those modules listed
they shouldn't hrm
some differences between cljs and clj
user=> (>= 1 nil)
NullPointerException clojure.lang.Numbers.ops (Numbers.java:1013)
cljs.user=> (>= 1 nil)
true
watch out 🙂@anmonteiro if I print out what index-node-modules
generates, those are actually already in there: {:file /Users/thomas/Develop/cljs/rimdb/fauna-module/node_modules/superagent/lib/client.js, :module-type :commonjs, :provides [superagent]}
so that makes sense
@thosmos does it also list their package.json
files?
for this one yes: {:file /Users/thomas/Develop/cljs/rimdb/fauna-module/node_modules/superagent/package.json, :module-type :commonjs}
I don't think order matters
@thosmos can you put together a minimal example I can try locally?
you can check in the node_modules
folder too, since you're making changes to some modules
thanks
@jjl yes, you can, checkout promesa http://funcool.github.io/promesa/latest/
ok, then I don’t understand the question. Sorry
@thosmos fixed the fields in your ticket http://dev.clojure.org/jira/browse/CLJS-1984
@thosmos so I had a look at your example
1. I don't think that faunadb
module is supposed to work in the browser
or is it?
right
because it tries to require('util')
that's a Node.js internal module
anyhow
switched to :target :nodejs
and made some progress
that led me to find another bug in ClojureScript 🙂
now it compiles fine, but there seems to be a problem with a dependency called qs
ok, switched to :target :nodejs
and I'm still getting failed module loads on the same packages. is this related to the other bug?
@thosmos yes, see CLJS-1985
@anmonteiro added your patch and still getting those module load errors. Are you possibly using a patched version of closure-compiler, such as with the PR patch you referenced earlier?
I was using Closure Compiler from master
@thosmos note that some warnings are expected
the expected warnings should refer to Node.js internal modules
@anmonteiro I'm still getting the same errors on the external modules and when I run node main.js
it biffs it on the first require: https://www.refheap.com/133303
@thosmos oh hrm, you need to pass :target :nodejs
in the opts to index-node-modules
@jennifer: Reading your code snippet, I don’t think I’m clear on what part isn’t working - is the backend handler working but just never receiving the text you are sending?
backend updates the atom i have stored there (this is just a basic todo app) and returns the updated atom, which has incremented properly, but doesn’t contain the new text.
and i’ve tested the backend with sample data in the repl and that function works as expected.
so i’m pretty confident that it’s just something here not passing to the backend correctly.
Looking at some of my existing code, it looks like all I’ve done is
(POST
{:params data
:keywords? true
:handler (fn …)})
but I remember having some trouble getting it working at the beginning - you could try adding :response-format :json
(assuming your backend is expecting json) as well, that’s given me trouble with some backends.@jennifer: ^ and if you’re sending just a string the keywords?
part shouldn’t matter I don’t think.
hmm. okay. my backend is expecting a stringified atom. i wonder if i’m sending over the wrong stringified thing. thanks for the feedback!
@jennifer: You should be able to print out the entire ajax map from the server side - I think Chrome devtools can show it all, but I think I’ve also had things when troubleshooting that didn’t seem to show up there due to problems with the format or things. Good luck getting it to work!
thanks! i think i might be onto why it’s not working. but been at this for a while. gonna rest my eyes and try again later. cheers!
@anmonteiro: Now I'm only getting the internal node module load errors like you mentioned, but also a java.lang.IllegalStateException: Cannot build without root node being specified
https://www.refheap.com/133306
@thosmos use :language-in :es5
in your compiler options
@jennifer if it's expecting an atom than what I suggested above is wrong, and you might just try sending the text-atom without the @
@anmonteiro ah yes, it built! The qs problem I think has something to with this module load error: WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "./lib/" at .../node_modules/qs/index.js line 1 : 17
yeah, that's what I got
@thosmos so here's the problem
superagent
is a dependency of faunadb
and faunadb is using a super old version of superagent
which in turn has a super old version of qs as a dep
I suspect qs
does some weird dynamic require magic that Closure Compiler can't understand
if you use qs v6 it also works
or upgrading superagent or something
so that's probably a Closure bug
you should report it upstream
@anmonteiro gotta run, it's been fun bug hunting with you
(defn foo [x y z]
(let [bar (long computation that does NOT dependon x y z and can be cached)]
...))
in the above case, the bar has to be evaled eveyr time, because clj has no idea whetehr there are side effects right? so if I want to 'cache it', I'd ahve to do something like
(let [bar .... ]
(defn foo [x y z] ...))
?@anmonteiro should I include anything for compiler flags/options, as they request?
as detailed as possible
qqq that's one option, another is to put bar
in a def, or make a memoization of the function called to calculate bar, and use that in foo
awesome