This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-23
Channels
- # aleph (9)
- # beginners (30)
- # boot (42)
- # carry (1)
- # cider (148)
- # clara (2)
- # cljsrn (13)
- # clojars (2)
- # clojure (90)
- # clojure-dev (1)
- # clojure-dusseldorf (2)
- # clojure-italy (7)
- # clojure-madison (1)
- # clojure-quebec (1)
- # clojure-russia (19)
- # clojure-sg (1)
- # clojure-spec (14)
- # clojure-uk (90)
- # clojurebridge (1)
- # clojurescript (70)
- # clr (7)
- # core-async (24)
- # cursive (26)
- # data-science (2)
- # datascript (3)
- # datomic (46)
- # devops (2)
- # emacs (6)
- # events (1)
- # figwheel (2)
- # hoplon (200)
- # klipse (2)
- # ldnclj (1)
- # lein-figwheel (4)
- # leiningen (3)
- # off-topic (44)
- # om (70)
- # other-languages (6)
- # pedestal (5)
- # protorepl (1)
- # re-frame (17)
- # reagent (14)
- # schema (2)
- # spacemacs (1)
- # specter (3)
- # test-check (38)
- # unrepl (38)
- # untangled (19)
- # yada (16)
Im getting errors like [Violation] Parser was blocked due to document.write(<script>)
in Chrome. Is this something new?
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
@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.
(At its core, this is related to the point where the compiler checks macros against specs, FWIW.)
Clojure 1.9.0-alpha16 with future.spec (future spec is a backport of spec to clojure ~1.8, right?)
@borkdude Here is the Clojure compiler change that is related to this: https://github.com/clojure/clojure/commit/42a7fd42cfae973d2af16d4bed40c7594574b58b#diff-f17f860d14163523f1e1308ece478ddbR6814
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.
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"}}}
}
tmtwd: seems to be normal. if you do lein new figwheel <project_name>
there is a sample min build the project.clj
here is the template: https://github.com/bhauman/figwheel-template/blob/master/src/leiningen/new/figwheel/project.clj#L50
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"}}]
}
@nikki Well, cljs.js
depends on other namespaces to do its job, notably the analyzer and compiler namespaces.
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"))
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
(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
)
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 >_<
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. --
I haven't tried it, but a direct translation of JS would be more like:
(def fs (js/require "fs"))
(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?
@deg I don’t think cljs.reader
has support for namespaced maps
you should probably use clojure.tools.reader
I think there’s an issue for deferring cljs.reader
functionality to tools.reader
, is that the one you’re referring to?
we should get around to that. I’ll put it on my list
@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}
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.
(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.)
I’m exploring ideas for generating a PDF of a web page. It uses SVG, Canvas and React.
@borkdude this was on my feed yesterday: https://github.com/diegomura/react-pdf
@anmonteiro Thanks! I’ll put it on my list of things to look at
Does anyone know, or know of good reading on, the relationship between a tool like lein-cljsbuild
and a build.clj
script?
@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.
build scripts are just Clojure programs that call into the ClojureScript compiler directly.
dumb question: how can I call all-ns
in clojurescript?
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?
@husain.mohssen namespaces and vars not reified in ClojureScript
great to know, thanks! (also I feel honored to hear directly from you @dnolen :))
@husain.mohssen np, basically it’s only possible to get at vars / namespaces from within a macro - usually more effort then it’s worth
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
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.
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?
@dnolen ah excellent, thanks so much for the clarity. I was hoping that would be the case.
@husain.mohssen hrm yeah, modules would be one way to solve that problem - we should probably get them working under :none
.
"under :none" ?
:none
is an optimizations level:
https://github.com/clojure/clojurescript/wiki/Compiler-Options#optimizations
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
it is included here: https://github.com/replikativ/geheimnis/blob/master/project.clj#L29
You'll need to have the Closure Library under a directory in your :source-paths
(e.g. src/gclosure/pkcs7.js
)
@spinningtopsofdoom thanks 🙂
just discovered https://www.ampproject.org. anybody working with this and cljs?