Fork me on GitHub
#clojurescript
<
2015-09-06
>
val_waeselynck00:09:37

I have made a ClojureScript tutorial based on the official AngularJS tutorial: https://github.com/vvvvalvalval/reagent-phonecat-tutorial/wiki. Feedback welcome simple_smile

underplank00:09:05

anybody got any pointers on how this has changed going from 0.0-2760 to 1.7.48?

underplank00:09:06

TypeError: 'undefined' is not an object (evaluating 'goog.dependencies_.pathToNames[path]')

underplank00:09:31

this is just js btw, not cljs->js ... so I just need to work out the correct stuff.

dnolen03:09:42

@underplank: we periodically update Google Closure Library, they occasionally change things. goog.dependencies_ is a private implementation detail. If something is relying on it, then that thing should be OK w/ the possibility of breakage.

mikethompson04:09:56

@underplank: you'll probably want something like this:

var pathToName = {};
        for (var key in goog.dependencies_.nameToPath) {
            var value = goog.dependencies_.nameToPath[key];
            pathToName[value] = key;
        }
        for (var key in goog.dependencies_.requires) {
            if (goog.dependencies_.requires.hasOwnProperty(key)) {
                if (goog.dependencies_.requires[key]["cljs.core"]) {
                    //as key is a path find its namespace
                    goog.require(pathToName[key]);    // will trigger CLOSURE_IMPORT_SCRIPT calls which injectJs into page
                }
            }
        }

mikethompson04:09:32

BUT obviously, as dnolen said, this is dependent on the current implementation and may not work with the next upgrade.

bhauman13:09:57

@underplank: I don't think pathToNames exists

bmaddy14:09:42

I've spent a number of hours now trying to get a basic datascript example working. Can anyone see what I'm going wrong? I start lein figwheel, refresh my browser and run this:

cljs.user=> (require '[datascript :as d])
cljs.user=> (d/create-conn {})
#<TypeError: Cannot read property 'call' of undefined>
The project is so simple that I'm sure I must be making a silly mistake. Here's the repo: https://github.com/bmaddy/prochaine Has anyone else run into this error?

phil_r15:09:33

The clojurescript version in that project.clj is pretty old...

phil_r15:09:38

@bmaddy: it's a figwheel problem. Update figwheel to 0.3.9 and it works.

underplank15:09:37

Using @mikethompson 's code I think I got it to work. I understand this could change at any time. But as a POC its working for now.

bmaddy15:09:48

Oh! Thanks @phil_r! I need to run right now, but I'll try that as soon as I get back. Thanks for taking a look!

underplank15:09:45

Im trying to get testing working with reagent and phantomjs with optimization :none.

phil_r15:09:59

@bmaddy you should also remove the clojure exclusion, I think that might actually be what did it

underplank15:09:35

I've almost got it but im getting tripped up at `ERROR: Error: goog.require could not find: cljsjs.react STACK TRACE: -> resources/public/cljs/fast-test/goog/base.js: 662 -> resources/public/cljs/fast-test/goog/../reagent/core.js: 8`

underplank15:09:44

ERROR: Error: goog.require could not find: cljsjs.react
STACK TRACE:
 -> resources/public/cljs/fast-test/goog/base.js: 662
 -> resources/public/cljs/fast-test/goog/../reagent/core.js: 8

underplank15:09:09

this is my compiler map

{:id "fast-test"
              :source-paths ["src/cljs" "src/cljc" "env/dev/cljs" "test/cljs"]
              :notify-command ["phantomjs"
                               "test-js/runner-none.js"
                               "resources/public/cljs/fast-test"
                               "resources/public/cljs/fast-test/opplz-test.js"
                               "test/vendor/es5-shim.js"
                               "test/vendor/es5-sham.js"
                               "test/vendor/console-polyfill.js"
                               "window.literal_js_was_evaluated=true"]
              :compiler {:pretty-print true
                         :output-to  "resources/public/cljs/fast-test/opplz-test.js"
                         :source-map "resources/public/cljs/fast-test/opplz-test.js.map"
                         :output-dir "resources/public/cljs/fast-test"
                         :optimizations :none
                         :foreign-libs [{:provides ["cljsjs.react"]
                                         ;; Unminified React necessary for TestUtils addon.
                                         :file "resources/components/react/react-with-addons.js"
                                         :file-min "resources/components/react/react-with-addons.js"}]
                         :source-map-timestamp true}}

underplank15:09:50

Its lifted from the ci.circle one. but im not sure what the foreign-libs does or if I actually need it?

martinklepsch15:09:34

underplank: do you need testutils?

underplank15:09:56

thats a good question simple_smile I dont know what it does simple_smile

martinklepsch15:09:38

Probably good to try just using the cljsjs/react jar and commenting out that foreign libs bit

underplank15:09:14

yeah I just found the cljsjs/react deps to put in lein. so Im gonna try adding that in and see what happens.

underplank15:09:21

do you know what testutils does?

jaen15:09:10

React's testing helpers, I think

underplank15:09:34

ahh ok. I dont think i use them at the moment...

underplank16:09:44

so I added [cljsjs/react "0.13.3-0"] into my :dependencies and still getting the same error.

underplank16:09:56

goog.require could not find: cljsjs.react

venantius17:09:29

Does anyone have any recommendations for good resources around Cljs deployment? Figwheel is awesome in a development environment but I’m having trouble understanding how to get everything to work nicely when I’m not using Figwheel.

venantius17:09:35

When I try just running the Chestnut basic Uberjar steps I stop seeing the Hello Chestnut message

underplank17:09:15

@venantius: hmm.. for a production deploy you are probably better serving them as static files through nginx or a CDN honestly. Once you have used an optimization level of anything but :none you should just have one file you can upload.

underplank18:09:00

I think if you want the ring server to serve them you have to put a route/resources route in your app. Again this probably isnt the most run-time efficient way of doing it, but from a deployment ease its not all bad.

jaen18:09:53

++ for serving static files with nginx/divshot/whatever

tel20:09:09

what’s the best solution around right now for running cljs.test in something like slimerjs on CI? Is there a solid runner/shim solution?

jaen20:09:50

I'm aware of this - https://github.com/boot-cljs-test/testem-runner - but can't vouch for how good it is in practice

tel20:09:55

ah ah, it’s running through node

tel20:09:19

I’ve considered that a few times!

tel21:09:41

brillant, thanks!

tel21:09:39

does everyone create those impl dirs just to avoid name clashes between modules and vars in cljs? haha

dnolen21:09:02

@tel I don’t think so, you see that pattern in Clojure which doesn’t have that issue. I think it's a simple way to communicate implementation namespaces.

tel21:09:05

fair enough! I’d wondered about it for a while and just implemented it in order to avoid such a name clash

tel21:09:11

thought I’d stumbled on to something

wildermuthn21:09:29

Anyone here use vim with cljs? I got tired of fireplace not working out of the box with figwheel, and kind of stumbled upon sending text from a buffer directly to the repl via tmux and with this plugin: https://github.com/ervandew/screen

wildermuthn21:09:31

It’s actually really nice, since fireplace’s evaluated results go into vim’s command line instead of the repl.

bhauman23:09:42

@wildermuthn: the great thing about that setup is the reliability