This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-17
Channels
- # bangalore-clj (1)
- # beginners (23)
- # boot (141)
- # cider (68)
- # cljs-dev (29)
- # cljsjs (1)
- # cljsrn (11)
- # clojure (150)
- # clojure-austin (3)
- # clojure-berlin (1)
- # clojure-france (2)
- # clojure-greece (13)
- # clojure-italy (5)
- # clojure-russia (49)
- # clojure-spec (15)
- # clojure-uk (45)
- # clojurescript (152)
- # code-art (1)
- # core-async (75)
- # cursive (12)
- # datascript (2)
- # datomic (90)
- # dirac (5)
- # emacs (10)
- # garden (1)
- # hoplon (52)
- # instaparse (4)
- # juxt (2)
- # lein-figwheel (2)
- # lumo (47)
- # mount (94)
- # off-topic (20)
- # om (21)
- # onyx (14)
- # parinfer (19)
- # pedestal (3)
- # protorepl (13)
- # re-frame (5)
- # reagent (20)
- # slack-help (10)
- # spacemacs (8)
- # specter (57)
- # unrepl (11)
- # untangled (3)
- # vim (1)
- # yada (1)
Does anyone here use boot for their clojurescript development? Does adzerk/boot-cljs-repl have the require macro? I'm getting require being undefined inside the cljs.user namespace.
@cdimara : I 'm using boot + cljs. I worked through the first few of https://github.com/magomimmo/modern-cljs/tree/master/doc/second-edition and everything, including adzerk/boot-cljs-repl, worked fine
I'm working through that too!
I'm doing a little experiment though trying to run quil-cljs in a live environment.
But it seems like things like require and doc would be built into all namespaces.
But maybe because its clojurescript its different?
Ok. I found the problem. Proto-repl and atom.
Ran boot-repl and had no problems.
Is anyone else getting this error when using figwheel with the new clojurescript compiler (1.9.494)? I did package it myself to include the newest google-closure library to fix the core.async bug.
Compiling "target/not-used.js" from ["src" "env/dev"]...
module.js:472
throw err;
^
Error: Cannot find module 'module-deps'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at [eval]:2:13
at ContextifyScript.Script.runInThisContext (vm.js:23:33)
at Object.runInThisContext (vm.js:95:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:571:32)
at Immediate.<anonymous> (bootstrap_node.js:390:29)
The externs inference is pretty cool btw!@seantempesta are you consuming Node modules?
@anmonteiro: Yeah. This is a react native project.
@seantempesta so you need to install the module-deps
package
@anmonteiro: Yup. That fixed it. Sweet. Thanks!
Does anyone know which one is best when passing state around in Reagent?
a) Pass a defonce atom declared in the core namespace to components in other files as an argument IE [my-component state]
b) Require and refer the state from the files as [:require my-proj.core :refer [state]]
?
js
/**
* Freeze the prototype of javascript build-in objects.
*/
/* istanbul ignore next */
export function freezePrototype () {
Object.freeze(Object)
Object.freeze(Array)
Object.freeze(Object.prototype)
Object.freeze(Array.prototype)
Object.freeze(String.prototype)
Object.freeze(Number.prototype)
Object.freeze(Boolean.prototype)
Object.freeze(Error.prototype)
Object.freeze(Date.prototype)
Object.freeze(RegExp.prototype)
}
Still not very sure how does this piece of code break ClojureScript. Anyone got some clue?
+cljs.user=> (.freeze js/Object js/Object)
#object[Object "function Object() { [native code] }"]
that's equivalent to Object.freeze(Object)
for the wrapper, something like (defn ^:export freeze-prototype [] ...)
I think
and then there's (.-prototype js/Object)
(.-prototype js/Array)
etc.
I think they called Object.freeze(Object.prototype)
, why Ca.prototype.toString
is frozen...
Turned out they are fixing the problem with Object.seal
https://github.com/apache/incubator-weex/pull/109
Is is possible to require a library based on a condition on ClojureScript for dev purposes? (if x (require '[..]))
I notice that leaving out devcards and re-frisk speeds up (incremental) compilation, but I don’t think it can be accomplished this way. I’m talking about the dev build, in prod of course we leave it out already. Maybe I’ll make a third build.
@borkdude I use different source paths for some parts of my app depending on dev/prod. Ie, you always include the files, but they might just be empty for production. Works really well and it's super easy.
Hmm, I’m not sure what caused the slow compilation. I restarted and it’s within 2-3 seconds now
I wasn’t saying it’s possible, just posting the link as an explanation why it’s not 😉
I’ve been trying to run generative tests using spec
in Clojurescript. I wrote this helper function:
(defn assert-generative-test
([sym] (assert-generative-test sym nil))
([sym opts]
(is (empty? (->> (stest/check sym
{:clojure.test.check/opts opts})
(map stest/abbrev-result)
(filter :failure)
(map :failure))))))
When I try to build though I get a java.lang.RuntimeException: Unable to resolve symbol: sym in this context
Could someone explain why this is happening? This function compiles in JVM Clojure.
@jysandy not 100% but stest/check
in CLJS is a macro so it might not be possible to pass dynamic args like that
This stuff changes quite a lot...If I want to create a package that I can add to my dependencies for https://github.com/cubiq/iscroll, is there an up-to-date guide on what to do?
https://github.com/clojure/clojurescript/wiki/Packaging-Foreign-Dependencies is latest afaik. To actually do the work, easiest is to simply check the boot.build of a package from cljsjs and adjust accordingly.
@foobar be aware that the (params …) function will be called even if the value isn’t used
@foobar it’s the same as get
@foobar I do think that using get
is easier to read when you are using a default value like this
(get query-data :params (params component))
does anyone have any thoughts on: http://stackoverflow.com/questions/32541144/puzzling-clojurescript-error-namespace-com-cognitect-transit-util-already-dec ?
@peterwestmacott that line com.cognitect.transit.util = {};
is basically goog.provide('com.cognitect.transit.util');
so transit seems to be included in the server-side.js
which then also loads the other files
but hard to tell without knowing your entry points .. looks like you have two builds server-side
and app
@thheller that's not my question, but I suspect it's related as I get a similar error. In my case I'm attempting to run cljs tests with doo on nashhorn.
qqq js has no characters, but this works
+cljs.user=> (not (js/isNaN "9"))
true
+cljs.user=> (not (js/isNaN "a"))
false
does anyone know why lein-cljsbuild produces a 90 kb output when I only have a hello world println?
@luisdevlopez all the code for all of cljs' data types and functions ends up in the output unless you turn on minification for the build
that’s probably a minified build already
oh...
it is, I created a new lein figwheel project
the simple fact of enabling printing will cause a lot of stuff to be included in your build
(enable-console-print!)
will add all that cruft
yeah I have that one added
thanks!
@qqq (re-find #"#{" “hello#{”)
— maybe? not sure if I fully understand
@martinklepsch , @thheller : sorry for not making problem cleearer
webcomponents v1 uses this js: class AppDrawer extends HTMLElement {...
(https://developers.google.com/web/fundamentals/getting-started/primers/customelements). can this be expressed in cljs? i googled but came up with nothing.
@qqq (str/split "hello #{world#{today" #”#\{”)
@mobileink that's not easy at the moment, mostly because some JS runtimes don't allow extends
on native elements in any other form
@thheller would that involve using Reflect.setPrototypeOf ?
(defn component []
(js/Reflect.construct js/HTMLElement #js [] component))
(set! (.-prototype component)
(js/Object.create (.-prototype js/HTMLElement)
#js {:connectedCallback
#js {:configurable true
:value
(fn []
(this-as this
(js/console.log "connected" this)))}
:disconnectedCallback
#js {:configurable true
:value
(fn []
(this-as this
(js/console.log "disconnectedCallback" this)))}
:attributeChangedCallback
#js {:configurable true
:value
(fn []
(this-as this
(js/console.log "attributeChangedCallback" this)))}
}))
(js/window.customElements.define "x-component" component)
that's enuff to get me started. fwiw polymer v2 rc is just out, it uses wc v1, so i guess it's stable.
thheller: thanks. i know just enuff js to be dangerous so anything that kinda sorta works is okay for now. i'm generating the cljs from a macro anyway, so it doesn't matter how gnarly it is.
Is anyone aware of a tool for clojurescript projects that will look at your CSS files and audit other files to point out what classes/ids are not being used?
haven’t heard of it, @njj - but as an alternative i’d recommend looking into something like https://github.com/roman01la/cljss (then you can do stuff like “find usages” on the styles since it will be clojure code)
One of the interesting use case I can see from cljss lib is that , facebook does use this kind of thing to generate different class
in html file , every time we refresh the browser, it makes things harder to scrape. I just get to know it
@rafaelzlisboa I’ve seen this before, and definitely would like to move towards something like this at some point but thats a big undertaking w/ the amount of CSS we have right now 🙂
@martinklepsch @thheller : I got it working with [#][{]
, but I like your solution of #\{
more
@anmonteiro Out of curiosity, do we get DCE when using :npm-deps
?
@kenny yes! Updating the post now
@anmonteiro: If someone wanted to use :npm-deps
without having node installed, or otherwise have a guaranteed immutable dependency, could they manually copy the downloaded deps files and have it work?
@shaun-mahood that’s not currently possible with :npm-deps
but you have cljs.closure/index-node-modules
which you can use
you can feed the result of that to foreign libraries
we should maybe consider moving that to the cljs.build.api
namespace
Ok - not a blocker for me, but with the number of people who have avoided CLJS because they didn't want to install Java, I can see a similar conversation happening way too often with Node as well.
@shaun-mahood I don’t agree with that statement
if you wanna consume Node.js modules, you probably already have Node.js installed
and you can opt out of consuming them
do not include :npm-deps
🙂
that said, all of this is still alpha, as I mention in my post
we’ll be fine tuning the behavior over the next iterations, of course
I would say most people will like the current behavior
we can hopefully please the full spectrum as we iterate
has anyone had to deal with floats in transit? js only has the number type, so if your value is an integer, that number will be delivered via transit as an integer
@anmonteiro: You could be very right on that point - I will happily be consuming them with Node installed. Having spent a bit of time lately working with Google Closure based JS libraries, I'm definitely looking forward to having a similar workflow for node libraries eventually.
@anmonteiro This is exciting. Just to confirm if I read correctly, we won’t have to run npm install
separately anymore, right?
correct
@shaun-mahood: I would argue that these days having Node.js installed is not a particularly strange expectation. And the fact that it won’t work without is no more troubling than the Node REPL not working either.
I'm trying to figure out how best to use the faunadb js driver (https://github.com/fauna/faunadb-js) in a clojurescript project. They have both nodejs and browserify versions, both of which are es5. :npm-deps {:faunadb "1.0.0"}
throws a compiler error. Should I report this on the clojurescript bug tracker? So far, I'm able to load the browser build (https://github.com/fauna/faunadb-js-release/blob/master/faunadb.js) if I first create a new js file with a faunadb = require("faunadb")
and then use browserify on that, and then include the new file either in a script tag or in :foreign-libs
. Is there a better way? I tried adding :module-type :commonjs
and :module-type :amd
but both of those threw errors.
@thosmos you’re probably hitting a Closure Compiler error
this one maybe?
it's similar but a little different: https://www.refheap.com/133232
looks like that one
try using Closure Compiler from master
@dnolen: Well, this change has certainly given me a good reason to care more about Node than I did before - before this, I couldn't see any real benefit to using Node or NPM in a Clojure + CLJS environment. I guess my main concern is that npm-deps
will become pervasive enough in the CLJS environment that beginners will essentially be required to learn the JVM, Maven, Clojars, NPM, and Node all at once. Likely a concern that can be remedied once the first patch is more than a week old, though 🙂 Either way, I think it's a very impressive and important step for ClojureScript to take and I'm glad to be along for the ride.
@anmonteiro @dnolen thanks for the work on this!
@shaun-mahood heh right, there’s definitely some expectation management to do here
@anmonteiro that looks like the one. using closure from master is basically cloning it, then a mvn install
then updating clojurescript deps to use 1.0-SNAPSHOT?
that’s it
@thosmos @martinklepsch made the instructions a little more beginner friendly the other day https://github.com/google/closure-compiler/pull/2374
@thosmos also note that there’s still an unsolved module bug which will hopefully be fixed in the next release. see https://github.com/google/closure-compiler/pull/2350
@anmonteiro ok, now I'm getting an error (https://www.refheap.com/133234) that looks very similar to the one I got when i tried to load the browser build in :foreign-libs
with :module-type _
: The two errors in the beginning are the same: identifier is a reserved word
@thosmos not every package can be consumed
boolean
is a reserved JavaScript keyword
also you can set :closure-warnings {:non-standard-jsdoc :off}
to silence those JSDoc warnings