Fork me on GitHub

The new cljs.main ClojureScript capability is very solid at this point, but could use your help in finding bugs prior to release! It is real easy to try it out with a single command, as detailed in this gist: I really recommend giving it a spin—this is really going to make trivial to get up and running with ClojureScript for a lot of use cases!


@mfikes Is there a documentation page describing what it is?


Not yet. But, in short, it is the ClojureScript analog of clojure.main, which has been available forever and lets you run Clojure files, or start a REPL with -r, or evaluate an expression with -e, or run a namespace with -m. This same capability exists in the new clj / clojure tool. What's it good for? Well, if you want to fire up a REPL, it is now trivial. But you can also use it to, say, run tests in a ClojureScript test namespace, or even run a browser REPL and have it automatically compile your code as you view the results in a browser. (Much of the Quick Start will likely be updated to work in terms of it.)


For a lot of simple use cases, there will no longer be any setup.


Yes, it sounds pretty good. I was thinking there’s be a or something similar.


Yeah, I would expect documentation like that in the end.


I guess the Clojure guide is and perhaps there will be a ClojureScript equivalent.


i'm using the google maps api and when using :optimizations :advanced I get this Uncaught TypeError: Cannot read property 'sf' of undefined. The offending line of compiled javascript is return new,b) I've already included [cljsjs/google-maps "3.18-1"] as a dependency. how do i check that the dependency is being used?


tried to generate a source map but got

Exception in thread "main" java.lang.AssertionError: Assert failed: :output-dir "target/cljsbuild-compiler-1" must specify a directory in :output-to's parent "/Users/ackerleytng/Documents/moocs/clojure/gowherene/target/cljs-output/public/js" if optimization setting applied


oops. to fix the source-map issue, i should have added something like :output-dir "resources/public/js/compiled"


random comment. I am SO impressed by source maps.


Is it possible to use re-frame without reagent/react back end? I mean, use it as general application frame work, but not render into webpages? Or is there a similar library for general application?


if i specify an externs file, is it appended to the rest of the externs that came with the libraries?


@leira well I believe it is coupled with reagent/react currently. There was an issue in GitHub before about being able to use an alternative backend and I think a sample project was made called re-Frankenstein or something. Not sure much more on that. However there is also re-natal that could let you use re-frame with react native to target native apps instead of web. Not sure what you are looking for more specifically though.


is it possible to destructing js object?


@doglooksgood - you can do a few useful things with goog.object which comes by default


but not keys destructuring like we'd do with a hash-map, no


I think interop in clojurescript is used more often than in clojure.


I use it pretty frequently in both - then again I'm the one most comfortable with interop in my team so I get those tasks 😄


(defn- render-item [x]
   [view {:style {:background-color "yellow"}}
    [text (.. x -item -text)]]))   ;; <------------------

(defn app-root []
  (let [greeting (subscribe [:get-greeting])]
    (fn []
      [view {:style {:flex-direction "column"
                     :margin 40
                     :flex 1
                     :align-items "center"}}
       [flat-list {:data [{:text "a"}  ;; <---------------
                          {:text "b"}
                          {:text "c"}
                          {:text "d"}]
                   :key-extractor (fn [item index] index)
                   :style {:width 100
                           :height 10}
                   :render-item render-item}]])))
what do you think about this?


@doglooksgood yes, it is possible by extending js objects to implement ILookup, see this code:


but it is not recommended to do unless you have full control over your js env and you know what you are doing 🙂


a good solution for me maybe, thanks!


instead of aget you should be using unsafe-get these days (a side note)


isn't aget for object lookup discouraged now too? (that's part of why I linked to goog.object)


goog.object/get has the required not-found behavior of ILookup -lookup already


correct, goog.object/get is a better option, I just wanted to point out that the code in that SO answer is a bit outdated 🙂


Is there a way to create a cljsjs package of a JavaScript file that uses a WebAssembly (.wasm) file?


cljs.main can now synthetically generate index.html making browser-based REPL startup effortless. To see for yourself, try this one liner

clj -Sdeps '{:deps {github-mfikes/chambered {:git/url "" :sha "094c4b943e25dfdaa0c0886fa2bdbf537ec0316a"}}}' -m cljs.main -re browser -c chambered.core -r
and after the REPL starts, if it doesn’t automatically, go to http://localhost:9000 in your browser