This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-11
Channels
- # admin-announcements (36)
- # beginners (1)
- # boot (267)
- # cider (19)
- # cljs-dev (12)
- # clojure (149)
- # clojure-austin (4)
- # clojure-canada (1)
- # clojure-czech (3)
- # clojure-dev (31)
- # clojure-japan (2)
- # clojure-uk (22)
- # clojurebridge (3)
- # clojurescript (314)
- # clojutre (18)
- # core-async (8)
- # cursive (4)
- # datascript (1)
- # datomic (27)
- # editors (2)
- # events (80)
- # hoplon (13)
- # javascript (2)
- # jobs (5)
- # ldnclj (12)
- # ldnproclodo (1)
- # off-topic (4)
- # re-frame (21)
- # reagent (87)
- # testing (13)
What the heck… I’m using cljs-time, and cljs-time.core is nil when I require it. All the other nses are fine
cljs.user=> (require 'cljs-time.core)
nil
cljs.user=> (require 'cljs-time.format)
nil
cljs.user=> (require 'cljs-time.coerce)
nil
cljs.user=> (map some? [cljs-time.core cljs-time.format cljs-time.coerce])
(false true true)
@bensu: nice project
@bensu: honestly, lein’s overhead is something that eludes me
I wonder if there’s really value putting this stuff through lein rather than exposing just the small scripts
and having the build configs in some file clojurescript-builds.edn
. reason I opted out of putting them in project.clj
was to allow us to read the file without using lein, since it does profile merging and other things
I don’t have a strong opinion, just trying to reconcile david’s aversion to cljsbuild with the current state of the de facto build tools. I just recently realized that mies doesn’t use lein for anything other than managing dependencies and thought that was elegant
According to https://github.com/emezeske/lein-cljsbuild/blob/master/doc/TESTING.md, if :hooks are enabled then lein test
should also run the ClojureScript tests.
I do have hooks enabled, but when doing lein test
I only see it build ClojureScript. I don't get the cljs test reports. Any ideas?
Configuration is pretty much this: https://github.com/ricardojmendez/tropology/blob/develop/project.clj#L53-L63 (only with :hooks [leiningen.cljsbuild]
on the :test profile.
@shaunlebron: I agree that there is a lot of overhead to lein. But you said yourself, it manages dependencies for you! That is why the mies scripts still use it. Also it presents an easier to remember interface and entry point into the clojure build world. The point of lein-cljs
would be to present an uniform interface to a spoiled user (me ) and then get out of the way, while avoiding some repetition. I have +10 cljs projects and I wouldn't like to fill them with the same scripts, and then have to mantain them over time.
@shaunlebron: @bhauman as for a cljs.config.edn
, I could see it's value, specially considering boot which doesn't care about project.clj
. cljs.config.edn
could be a ground zero for any build tools
@bhauman: finally, what you are looking for, docs for custom build pipelines, seems to be more approachable from boot. I don't have much experience but I'll definitely look at it.
@bensu: boot provides an interface similar to the cljs.config.edn
: https://github.com/adzerk-oss/boot-cljs/tree/d06714775d49e37d2642a6cda8fd84270a2b1d29#multiple-builds (slightly outdated docs)
I need to go and try boot (`tenzing`?), think about it, and then decide if something like lein-cljs
is really needed, or the scripts will suffice
lein new tenzing +garden +less +sass +om +reagent
— pick one of om/reagent (this is a verbose list of options)
and +test
to add doo 😉
does anyone know how to scrape some HTML from the browser in ClojureScript? I've tried something like (-> (dommy/create-element :html) (dommy/set-html! my-html-string))
, but when I cannot seem to query against it - it's as if it was querying my DOM instead of the DOM I just created
@val_waeselynck I’d check if I find something relevant in goog.dom
@martinklepsch: thanks, will check it out
@bensu: > I have +10 cljs projects and I wouldn't like to fill them with the same scripts, and then have to mantain them over time
I think that point is good
@shaunlebron: "I think that point is good", as opposed to the others haha
well, especially
it's the same reason I started a lein plugin for cljs testing. I had runners/phantom-script.js
in every project.
lein is of course important for deps. I would rather just use lein deps
and be done with it, like npm install
I don’t know, I like the idea of maintaining the scripts more easily through lein though
it doesn't need to be lein. that is why I brought up boot. If what we need is flexibility and composability, boot was designed specifically for that
but I find the /scripts
everywhere as a step back (though great to educate on cljs basic)
I think people should continue to use to Boot & Lein. They are great tools for beginners and experienced users alike. But I would also like to see more dissemination of information on how to use Maven directly and how to script your application with Clojure only.
there’s a pervasive misinformed notion that Clojure is bad for scripting due to latencies introduced by other tooling.
@dnolen: I agree that it depends. I often have a couple of specialized scripts, specific to the project, and I see their value. I'm just reluctant to have everything be a script, when most of what I do is cljs.watch.api
using with no callback fn.
on Maven usage, I have little to none experience to contribute work or opinions on the matter 😞
@dnolen: what are the major issues you see (if any) with the current state of cljs tooling, as it applies to creating large frontend apps?
the lein-cljs
experiment is: Can we offer the basic cljs api without requiring the user extra work and without getting in the way of the compiler?
but I do think there’s a lack of wide spread understanding on how the tools actually work
the problem w/ that is that perfectly fine projects like cljsbuild languish (due to little contribution to bring it up to parity with the rest of the ecosystem)
@dnolen: yes, i am wondering what the state of cljsbuild is; i noticed bhauman has his own cljs compiler for figwheel too... so we have four compiler tool/libs and counting...
@pandeiro: the cljs.api
is so good, that I didn't need lots of motivation. if you read the source, you'll know what I mean.
@dnolen: no right, i know... referring to https://github.com/bhauman/clojurescript-build -- it uses that and cljsbuild... now there is lein-cljs, boot-cljs too
@bensu: i wonder if the same logic should apply to boot-cljs (ie, simplify and defer more work to cljs.build.api)
@pandeiro working on the compiler has shown me how cljsbuild
often got in the way, specially due to bad default opts. At the same time I do want some easy access point to the compiler from the command line. @shaunlebron was talking about how to package these scripts into the figwheel template, or figwheel itself. voila, lein-cljs
@pandeiro: Boot-cljs already uses cljs.build.api and other than small fixes there isn’t much that could be moved to cljs api
perhaps the only thing I would like to see which I don’t actually need myself at the moment is some CSS / image packing solution.
@dnolen: please be picky. it's the way forward. is there any fundamental reason you don't see something like lein cljs
from working?
@dnolen: on the CSS/packing, I see it as something to be handled by ClojureScript on node, taking advantage of npm modules
@bensu: I can see using mies for visibility into the build process, and lein-cljs for convenience
I think it’s somewhat relevant to see how many ways babel can be used: http://babeljs.io/docs/setup/
Are there other Clojure & ClojureScript validation libs that people use? Saw validateur (http://clojurevalidations.info/) and obviously Schema. Herbert which many people seem to like isn’t targeting CLJS.
@martinklepsch: I’m surprised no one ported herbert yet
@dnolen: well it uses a bunch of libs that are not available in CLJS I believe
@pandeiro: thi-ng/validate looks sweet
Leiningen noob question here. How can I make an uberwar from the lein-figwheel template? (running lein with-profile uberjar ring uberwar
builds without the optimizations)
Here is my project.clj:
@martinklepsch: Funny, I was just looking at the http://thi.ng libraries myself.
@bensu: @shaunlebron @dnolen So here is an idea. lein-cljs could run its tasks directly or with an --generate option generate a script to do the same task. This would give users a great path for taking control of the build process.
whoa http://thi.ng is an interesting collection
makes for cool inline documentation: https://github.com/thi-ng/domus/blob/master/src/log.org
currently the one recommended by Luminus
@pandeiro: somehow validate isn’t written in literate org files
sorry guys anyone know why I get this
Uncaught ReferenceError: React is not defined(anonymous function) @ holidaysapp.js:33041
created a simple app with the fig template
adding these dependencies
:dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/core.cache "0.6.4"] [org.clojure/clojurescript "1.7.58"] [om "0.8.0-rc1"] [org.clojure/core.async "0.1.346.0-17112a-alpha"]]
@andrea.crotti: Is this after doing an uberjar? If so, do you have externs?
@greywolve: ah ok I tried and it fetched react
Retrieving org/omcljs/om/0.9.0/om-0.9.0.pom from clojars Retrieving cljsjs/react/0.13.3-0/react-0.13.3-0.pom from clojars Retrieving cljsjs/react/0.13.3-0/react-0.13.3-0.jar from clojars Retrieving org/omcljs/om/0.9.0/om-0.9.0.jar from clojars
but still see the same issue after a cljsbuild
do I ever need to restart figwheel maybe?
@andrea.crotti: can you show us the code in holiday app that is causing this?
I just did "lein new figwheel"
I copied from an example @bhauman
(om/root (fn [data owner] (reify om/IRender (render [_] (dom/h2 nil (:text data))))) app-state {:target (. js/document (getElementById "app"))})
but don't think that code is the issue
it's just that it's not compiling the dependencies properly I guess
wait I also updated clojurescript to the last version which maybe was not a wise idea
@andrea.crotti: you do need to let things finish compiling.
mm ok I thought I did running with auto
ah gosh yes is true
Successfully compiled "resources/public/js/compiled/holidaysapp.js" in 14.722 second
I was impatient 😄
I guess editing makes the compilation restart every time?
@andrea.crotti: you are not the only one. lots of folks do this
good to know
I would have never thought it could take so long with an SSD
@andrea.crotti: you are compiling in :simple or :advanced right?
@andrea.crotti: you need to use optimizations :none in order to compile quickly
ah ok thanks @bhauman
I didn't touch the settings yet
if I'm running "lein figwheel" already do I actually need to have "lein cljsbuild auto"?
probably not, since it seems like it compiles already
@andrea.crotti: I highly recommend the quick start. https://github.com/bhauman/lein-figwheel/wiki/Quick-Start
@andrea.crotti: it will save you hours and hours
yes thanks @bhauman I went through that already many months ago but I forgot about that in the meanwhile of course
@andrea.crotti: cljsbuild auto defaults to :optimizations :whitespace
so thats why the compile times where so long. You have to supply :optimizations :none
explicitly when you are using cljsbuild if thats the behavior you want.
I’m seeing super-weird behavior where cljs-time.core
is nil
under 1.7.28, and #js {}
on 1.7.48. All other namespaces work fine. Github issue: https://github.com/andrewmcveigh/cljs-time/issues/41
so I'm following this tutorial
and while this works fine
(om/root (fn [data owner] (reify om/IRender (render [_] (dom/p nil (:text data))))) app-state {:target (. js/document (getElementById "app"))})
this instead should use a list
(om/root (fn [data owner] (om/component (apply dom/ul nil (map (fn [text] (dom/li nil text)) (:list data))))) app-state {:target (. js/document (getElementById "app0"))})
1. defining a component is the same as doing reify om/IRender?
2. what is supposed to be in the HTML to make that work?
@andrea.crotti: highly recommend that you go slow, take your time, and read everything. even the docs!: https://github.com/omcljs/om/wiki/Documentation#component
@andrea.crotti: for 2), what's needed is a dom element with id "app0"
yeah I have "app" in my example @jackjames so that should still work
ah cool so om/component is a shortcut
@andrea.crotti: "app" will work for the first example that you pasted. but def not for the second. for that one, you'll need an element with id "app0"
@jackjames: yes yes I know this is not the code I'm using
it's the code from the wiki, mine is
(om/root (fn [data owner] (om/component (apply dom/ul #js {:className "fruit"} (map (fn [text] (dom/li nil text)) (:fruit data))))) app-state {:target (. js/document (getElementById "app"))})
@andrea.crotti looks good as long as (:fruit data) evaluates to a seq of strings
@bhauman: love the --generate option
(defonce app-state (atom {:fruit [:banana :strawberry]}))
ok maybe they should be strings actually
but should I not get an error?
@andrea.crotti: you should not get an error. you should get a list of gibberish like: bananabanana111528917921537751054096
ah finally it works actually
the new version of clojurescript I think was the issue
Okay, so it looks like the weird bug where cljs-time.core
is nil or the empty object is only under figwheel…. https://github.com/andrewmcveigh/cljs-time/issues/41
@bhauman: No, it also appears to happen when I compile with nrepl. I guess that may be equivalent to requiring in the repl?
bhauman: being pulled in through an ns form doesn’t help:
lvh@zygalski ~/P/r/crunch (master) [130]> rlwrap lein figwheel 10:05:48
Figwheel: Starting server at
Focusing on build ids: app
Compiling "resources/public/cljs/main.js" from ["src" "test"]...
Successfully compiled "resources/public/cljs/main.js" in 0.69 seconds.
Started Figwheel autobuilder
Launching ClojureScript REPL for build: app
Figwheel Controls:
(stop-autobuild) ;; stops Figwheel autobuilder
(start-autobuild [id ...]) ;; starts autobuilder focused on optional ids
(switch-to-build id ...) ;; switches autobuilder to different build
(reset-autobuild) ;; stops, cleans, and starts autobuilder
(reload-config) ;; reloads build config and resets autobuild
(build-once [id ...]) ;; builds source one time
(clean-builds [id ..]) ;; deletes compiled cljs target files
(fig-status) ;; displays current state of system
(add-dep [ "0.8.1"]) ;; add a dependency. very experimental
Switch REPL build focus:
:cljs/quit ;; allows you to switch REPL to another build
Docs: (doc function-name-here)
Exit: Control+C or :cljs/quit
Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when figwheel connects to your application
To quit, type: :cljs/quit
cljs.user=> @#'cljs-time.core
#js {}
FWIW, the require libspec in that ns is [cljs-time.core :as tc]
. For some reason, nrepl knows how to autocomplete tc/whatever
, even though all of the tc/whatevers
are nil.
@lvh: so in the console I'm getting errors about DateTime.js not being found etc. So dynamic require of cljs-time doesn't seem to work from figwheel. But ... compiled require does work. If you do (clean-builds) (build-once) and then reload the page everything seems to be working at least in 3308.
cljs.user=> (clean-builds)
Focusing on build ids: app
Deleting ClojureScript compilation target files.
nil
cljs.user=> (build-once)
Focusing on build ids: app
Compiling "resources/public/cljs/main.js" from ["src" "test"]...
Successfully compiled "resources/public/cljs/main.js" in 3.988 seconds.
nil
cljs.user=> @#'cljs-time.core
#js {}
;;;;; REFRESHED PAGE HERE
cljs.user=> @#'cljs-time.core
#object[ReferenceError ReferenceError: cljs_time is not defined]
(resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:795)
(resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:53)
(resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:2)
figwheel$client$utils$eval_helper (jar:file:/Users/lvh/.m2/repository/figwheel/figwheel/0.3.7/figwheel-0.3.7.jar!/figwheel/client/utils.cljs:47:5)
GET
[HTTP/1.1 404 Not Found 1ms]
TypeError: cljs_time.internal is undefined core.js:21:0
GET
[HTTP/1.1 404 Not Found 1ms]
TypeError: goog.i18n.DateTimeSymbols is undefined Date.js:808:0
GET
[HTTP/1.1 404 Not Found 1ms]
GET
[HTTP/1.1 404 Not Found 1ms]
TypeError: goog.date.DateTime.prototype is undefined
│ │ └── goog
│ │ │ …...
│ │ ├── date
│ │ │ ├── date.js
│ │ │ ├── datelike.js
│ │ │ ├── duration.js
│ │ │ └── utcdatetime.js
So, I get all of the errors in the browser about stuff being missing, I refresh, and then:
> cljs_time
ReferenceError: cljs_time is not defined
cljs.user=> cljs-time.core
#object[ReferenceError ReferenceError: cljs_time is not defined]
(resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:69)
(resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:53)
(resources/public/cljs/out/figwheel/client/utils.js line 129 > eval:1:2)
figwheel$client$utils$eval_helper (jar:file:/Users/lvh/.m2/repository/figwheel/figwheel/0.3.7/figwheel-0.3.7.jar!/figwheel/client/utils.cljs:47:5)
I can (require ‘cljs-time.core)
but then I get the same errors in the dev console:
GET
[HTTP/1.1 404 Not Found 1ms]
TypeError: cljs_time.internal is undefined core.js:21:0
GET
[HTTP/1.1 404 Not Found 1ms]
TypeError: goog.i18n.DateTimeSymbols is undefined Date.js:808:0
GET
[HTTP/1.1 404 Not Found 1ms]
GET
[HTTP/1.1 404 Not Found 0ms]
TypeError: goog.date.DateTime.prototype is undefined
@lvh: yeah that's the problem. But to get things working. Require the clsj-time.core in a file thats required by your app, compile everything, from scratch and load the app. That should work
However, running the tests with doo
(so also in a browser but w/o figwheel) seems to work fine
bhauman: When you say required by your app, is having it anywhere in src/ good enough, or is there a specific ns that should require the ns that requires cljs-time
@lvh: the only code that is loaded is code that is required in the tree of files from your core app file down
I suppose you could argue that maybe it just needs a warning or something, either from figwheel or in the manual. after all I’m abusing figwheel to be my piggieback into a browser environment, and figwheel just wants to compile my app
Hi there! I am a clojure newbie. Learning about JS promises left me wondering.. Would it be possible to implement async
and await
style syntax using clojure macros?
@lvh: please go ahead an file an issue. The problem isn't cljs-time its a library resolution problem I think. It would be cool if you could verify that this isn't a problem in the regular cljs.repl
Ah. Thanks Ivh. I’ll read about core.async.
I wrote a blogpost about parameterizing ClojureScript builds using the tools coming with the Closure compiler: http://www.martinklepsch.org/posts/parameterizing-clojurescript-builds.html — feedback welcome!
@martinklepsch: i just skimmed it now; it's interesting but including a sample use case would be nice
@martinklepsch: great post! super helpful
@pandeiro: there’s the example of customizing an API endpoint at build time
@martinklepsch: that looks like it belongs in the ClojureScript wiki
@martinklepsch: ah ok, i see... yeah I think the background abstract info would be good in the wiki, maybe in the compiler options part
@martinklepsch: nice!
I finally got server-side rendering partially working. I got the basic example working, now I’m slowly introducing CLJS code to find the pieces that break. Is there a nice way to debug nashorn? I can’t seem to get even println debugging working on (.eval nashorn “some code”)
@arohner: I used node and figwheel to debug server side rendering. Might be a better environment. After that move to nashorn. Most of the bigger problems should be solved.
@arohner: some things surprisingly work great like dangerouslySetInnerHTML, other things that you would expect to work just don't
@arohner feel free to ama about node, node-repl, node-inspector, nodemon. Note: node-repl command only works with iojs currently. Use nvm to manage node & iojs versions.
@shaunlebron: @bhauman: I see the appeal to the --generate option. I don't know about it but I'll give it some thought.
@bhauman: that's right, syntax quotes and file generation. sounds dangerous in all the right ways
@lvh I had that same problem today. I required cljs-time
directly in core.cljs
, and that still didn't work. I gave up and copied the files locally. Did you get it working?
@coyotespike: Is core.cljs your main namespace?
@coyotespike: how are you building cljs?
@bensu: it seems like you should be able to use the run
command internally with generated code. not that much different than run-local-project
With figwheel, or do you mean my config in project.clj
?
coyotespike: If you’re building with figwheel, I guess it’s using cljsbuild, so yes, your cljsbuild config in project.clj
source-paths is src/cljs
, optimizations are none
@coyotespike: (clean-builds) (build-once) reload app in browser should work if you are requireing it in core.cljs
I did run lein clean
@coyotespike: the only thing that doesn't work for cljs-time that we found, was requiring dynamically. If you compile it as part of the source and load the app it should work.
@martinklepsch: goog.define
comes at the perfect time, I'm going to write some i18n macros next week and that sort of constant replacement is exactly what I need.
It works locally, but any clarity on what's happening is always welcome
@bhauman: thanks, I'll give it another shot
@bensu: happy to hear. I was doing some i18n before and I was wondering if I should make separate builds or include all languages in the build. With only two I went with including all of them but with more this probably becomes less a choice.
@martinklepsch: yes, same question here. so far only supporting english, but in the future we'll need a way to "parameterize cljs builds" to include things like language. if only somebody thought of such things...
you don’t need macros! 😛
I need them for something else, what if the the string needs to be interpolated? "Hello %s!" then I better leave an anonymous function that takes a name there.
@bhauman: I have my server-side render running in node now, but now I get different errors 😞
@nullptr: already opened a task for that http://dev.clojure.org/jira/browse/CLJS-1402
is there a blog post / demo / gist out there of what bootstrapped clojurescript looks like?
I’m using [hickory](https://github.com/davidsantiago/hickory) to parse some DOM fragments into Clojure data structures. Is there something like Hickory that starts from the DOM? It seems like Hickory itself uses the DOM in CLJS, so is there a way for me to just give it a DOM element?
@bhauman: not yet. Appears to be something with React detecting whether or not it is a module
*detecting whether or not the env has JS module support, and then defining itself as a repl
@arohner: are you requiring cljsjs.react in your ns? and have you seen https://github.com/DomKM/omelette/blob/master/src/omelette/render.clj
@arohner: it should and you are using something other than :none right. You are going to want a monolith
@arohner: there is also this reference http://augustl.com/blog/2014/jdk8_react_rendering_on_server/
react.js starts with: !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);
but then something in my full app breaks with no stacktrace, so I was trying to use node to get real JS stacktraces
@arohner: you might want to read cljs.repl.nashorn
to understand the hacks that are need for React to work if you’re setting up a script context yourself
it is typical to check the presence of window
, modules
, global
- all are problematic in in Rhino or Nashorn context
and you can pass the trace to cljs.stacktrace
to map it back to original sources if you build up the source map with cljs.source-map