Fork me on GitHub
#clojurescript
<
2017-05-23
>
danielgrosse09:05:51

Im getting errors like [Violation] Parser was blocked due to document.write(<script>)in Chrome. Is this something new?

borkdude11:05:33

Lately we keep getting errors like this, but we can’t trace where it originates: clojure.lang.ExceptionInfo: Attempting to call unbound fn: #‘clojure.spec.alpha/macroexpand-check This is only during development builds

mfikes12:05:56

@borkdude With 1.9.542, since the introduction of the alpha spec namespaces, it would be important to also ensure you are using Clojure 1.9.0-alpha16. Perhaps you are, and something more subtle is going on.

borkdude12:05:17

We are using clojure.future.spec

borkdude12:05:20

with that version

mfikes12:05:58

(At its core, this is related to the point where the compiler checks macros against specs, FWIW.)

misha12:05:21

Clojure 1.9.0-alpha16 with future.spec (future spec is a backport of spec to clojure ~1.8, right?)

mfikes13:05:17

Yeah, my hunch would be to remove clojure.future.spec as a dep and just use 1.9.0-alpha16. Perhaps this is causing classloader issues. Hrm.

borkdude13:05:49

Probably yeah. We still depend on Clojure 1.8.

borkdude13:05:06

@misha We use Clojure 1.8

Tim14:05:31

I have a small figwheel project I started, and for development it worked fine but when I tried to do a prod profile for cljsbuild it didn’t work. To get it to work I had to remove/comment out all figwheel references entirely like in this lein segment. Is this normal?

:plugins [#_[lein-figwheel "0.5.8"]
            [lein-cljsbuild "1.1.6"]]

  :cljsbuild {
              :builds {:dev {:source-paths ["src/cljs"]
                             ;:figwheel     true
                             :compiler     {:main       "hello-seymore.core"
                                            :output-to  "resources/public/javascript/main.js"
                                            :output-dir "resources/public/cljs/out_dev"
                                            :asset-path "cljs/out_dev"}}

                       :prod {:source-paths ["src/cljs"]
                              ;:figwheel true
                              :compiler     {:optimizations :whitespace
                                             :main "hello-seymore.core"
                                             :output-to  "resources/public/javascript/main.js"
                                             :output-dir "resources/public/cljs/out"
                                             :asset-path "cljs/out"}}}
              }

dvingo15:05:33

tmtwd: seems to be normal. if you do lein new figwheel <project_name> there is a sample min build the project.clj

Tim15:05:49

ah, I had to change it to:

:cljsbuild {
              :builds [{:id           "dev"
                        :source-paths ["src/cljs"]
                        :figwheel     true
                        :compiler     {:main       "hello-seymore.core"
                                       :output-to  "resources/public/javascript/main.js"
                                       :output-dir "resources/public/cljs/out_dev"
                                       :asset-path "cljs/out_dev"}}

                       {:id           "prod"
                        :source-paths ["src/cljs"]
                        :compiler     {:optimizations :whitespace
                                       :main          "hello-seymore.core"
                                       :output-to     "resources/public/javascript/main.js"
                                       :output-dir    "resources/public/cljs/out"
                                       :asset-path    "cljs/out"}}]
              }

nikki17:05:38

does cljs.js contain the entirety of the code for eval'ing?

mfikes17:05:29

@nikki Well, cljs.js depends on other namespaces to do its job, notably the analyzer and compiler namespaces.

nikki17:05:39

makes sense

gastove18:05:24

Does… anyone have a second to help me grok something? I’m trying to access Node.js from ClojureScript; based on examples and docs I’ve found across the internet, my best speculation is I should do this like so:

(ns clojurescript.core
  (:require [cljs.nodejs :as nodejs]))

(def fs (nodejs/require "fs"))

gastove18:05:45

But: when I compile it, I run in to WARNING: No such namespace: fs, could not locate fs.cljs, fs.cljc, or Closure namespace "" at line 9 src/clojurescript/core.cljs

gastove18:05:53

(I should note, my compilation works with a much more “trivial” example — if I require nodejs and write a hello-world -main, it builds and runs with node perfectly normally. Things only get weird when I start trying to nodejs/require)

gastove18:05:19

Confession: I’m new to both JS and CLJS, so my intuitions about these errors are failing me. It doesn’t… from the Node docs, it doesn’t look like Node submodules need to be, say, individually npm install. But, this feels like a time when I’m running headlong into something screechingly obvious >_<

gastove18:05:00

I should also say: I see a lot of use of a build.clj file in the ClojureScript docs, but those files do not appear in the lein-cljsbuild docs, so I have not yet made one. --

rgdelato18:05:51

I haven't tried it, but a direct translation of JS would be more like:

(def fs (js/require "fs"))

gastove18:05:15

Huh — that behaves the same as (nodejs/require "fs") for me.

deg18:05:35

(crossposting from beginners). In CLJS 1.9.542, (cljs.reader/read-string "#:user{:a 1 :b 2}") errs, even though #:user{:a 1 :b 2} is handled just fine in the repl. Bug, known bug, or am I doing something wrong?

anmonteiro18:05:54

@deg I don’t think cljs.reader has support for namespaced maps

anmonteiro18:05:05

you should probably use clojure.tools.reader

dnolen18:05:07

pretty sure there’s an open issue for that

anmonteiro18:05:28

I think there’s an issue for deferring cljs.reader functionality to tools.reader, is that the one you’re referring to?

anmonteiro18:05:47

we should get around to that. I’ll put it on my list

deg18:05:52

Thanks. Is clojure.tools.reader is built in, or do I need to add a dependency?

deg18:05:45

(never mind. found the github and adding the dep now)

anmonteiro18:05:57

@deg it should come with ClojureScript, but you can also add the dep. here’s an example in Lumo:

Lumo 1.5.0
ClojureScript 1.9.542
Node.js v7.10.0
 Docs: (doc function-name-here)
       (find-doc "part-of-name-here")
 Source: (source function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (require '[cljs.tools.reader :as r])
nil
cljs.user=> (r/read-string "#:user{:a 1 :b 2}")
{:user/a 1, :user/b 2}

gastove18:05:02

….huh. (nodejs/require "readline") works just fine

deg18:05:15

Yeah, thanks... I had a braino/typo where I was spelling "read-string" as "reader" and couldn't figure out why it wasn't working.

gastove18:05:30

(In the off-chance anyone ever runs in to this: I misread the line numbers. Problem was trying to access methods on fs as static rather than instance methods. Switched to instance method access, everything groovy now.)

borkdude18:05:37

I’m exploring ideas for generating a PDF of a web page. It uses SVG, Canvas and React.

borkdude19:05:57

@anmonteiro Thanks! I’ll put it on my list of things to look at

gastove19:05:35

Does anyone know, or know of good reading on, the relationship between a tool like lein-cljsbuild and a build.clj script?

dnolen19:05:58

@gastove there’s not much that covers this but the distinction is pretty simple. cljsbuild is a Lein plugin that integrates with the ClojureScript compiler.

dnolen20:05:10

build scripts are just Clojure programs that call into the ClojureScript compiler directly.

husain.mohssen20:05:03

dumb question: how can I call all-ns in clojurescript?

husain.mohssen20:05:01

I tried something naive like cljs.repl/all-ns and found nothing there. In general, how do I approach thinking of this problem without bothering the fine people here?

dnolen20:05:29

@husain.mohssen namespaces and vars not reified in ClojureScript

dnolen20:05:43

so you shouldn’t expect any of the typical Clojure things here to work at all

dnolen20:05:58

and if they work, there will be some tough and tricky limitations

dnolen20:05:49

better to assume they just don’t work

husain.mohssen20:05:55

great to know, thanks! (also I feel honored to hear directly from you @dnolen :))

dnolen20:05:57

@husain.mohssen np, basically it’s only possible to get at vars / namespaces from within a macro - usually more effort then it’s worth

dnolen20:05:26

if you’re trying to accomplish some kind of automation (like testing) then maybe useful - but the runtime hijinks you can do in Clojure I would give up on

husain.mohssen20:05:34

thanks @dnolen You answered my question very well but if you want to know what I'm doing: I have junior developers working in parallel on different pages and I want each of them go start their work in their own namespace so they don't bump into each other's work. My current design is to have a page that will walk though each of the name-spaces and calls a public (run) function to render the page. The original solution I was thinking of was for each one to have their own namespace that compiles to a different .js file and call that from a different .html file. The problem is I could not get modules to work with figwheel.

cpmcdaniel20:05:47

hmmm… Chrome says it can find my source maps, and seems to be able to locate the files, but they are empty when I open them… any ideas?

gastove20:05:19

@dnolen ah excellent, thanks so much for the clarity. I was hoping that would be the case.

dnolen20:05:35

@husain.mohssen hrm yeah, modules would be one way to solve that problem - we should probably get them working under :none.

husain.mohssen20:05:19

"under :none" ?

whilo21:05:04

i am trying to ship a google closure module with my clojurescript library, but somehow it cannot be found in projects that include the library

whilo21:05:29

i guess i should put pkcs7.js somewhere in the src folder

spinningtopsofdoom21:05:37

You'll need to have the Closure Library under a directory in your :source-paths (e.g. src/gclosure/pkcs7.js)

mobileink23:05:54

just discovered https://www.ampproject.org. anybody working with this and cljs?