This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-29
Channels
- # aws (1)
- # beginners (65)
- # boot (400)
- # cider (19)
- # clara (2)
- # cljs-dev (29)
- # clojure (127)
- # clojure-chicago (2)
- # clojure-conj (1)
- # clojure-dev (12)
- # clojure-russia (156)
- # clojure-sg (6)
- # clojure-za (1)
- # clojurescript (193)
- # core-async (23)
- # datomic (91)
- # editors (4)
- # editors-rus (1)
- # events (1)
- # hoplon (3)
- # jobs (1)
- # ldnclj (6)
- # leiningen (3)
- # nginx (3)
- # off-topic (5)
- # om (93)
- # onyx (10)
- # re-frame (11)
- # spacemacs (1)
- # testing (2)
- # yada (5)
little namespacing question...
src/cljs/ui/electron/menu.cljs
looks like this:
(ns
(:require [ui.parser :as parser]))
src/cljs/ui/parser.cljs
like this:
(ns ui.parser)
cljsbuild target like this:
{:id "ui:dev"
:figwheel true
:source-paths ["src/cljs/ui" "src/cljs/dev"]
:incremental true
:jar true
:assert true
:compiler {:main "ui.core"
:output-to "app/js/front.js"
:externs ["app/externs.js"]
:warnings true
:elide-asserts true
:output-dir "app/js/out-frontend"
:asset-path "js/out-frontend"
:optimizations :none
:pretty-print true
:output-wrapper true}}
yet every time I try to compile things, I get a error inside menu.cljs
:
Caused by: clojure.lang.ExceptionInfo: No such namespace: ui.parser, could not locate ui/parser.cljs, ui/parser.cljc, or Closure namespace "ui.parser"
everything under src/cljs/ui/ is one cljsbuild target. There are other folders like src/cljs/backend/ as well, but they have separate builds
@dvcrn: if source paths is "src" it will look for the namespace "my.app" in "src/my/app.cljs"
@martinklepsch: ohh... so I'm one level too high? For that to make sense I have to put my things into src/cljs/ui/ui
?
@dvcrn: yes I think that would do it
each of these compile into a different .js file with the exception being dev/
. That gets merged into ui/
Probably a source did for each of them
that's actually what I had before lol I thought it would be better to put it all into one src/
what is the best way to declare union-type like schema in prismatic schema? either
marked as deprecated in favor of cond-pre
, and cond-pre
is marked as experimental in its turn
Hi @ul, I had the same struggle, I use cond-pre
@hmadelaine: thank you! I tried this, seems to be working
@ul the documentation is not very clear on that subject.
sadly reported messages too =( just tried to make one of my functions with schema definition, got long error about schema data mismatch, but not sure for what exact reason
@ul sometimes I had great difficulties to understand why Schema is yelling at me 😉
i want to try to do some refactor of my codebase programmatically, what is the best library for walking and changing code? https://github.com/xsc/rewrite-clj ?
ul: What is the difference between cljs and clj files that you see would make a difference in support for rewrite-clj?
i just not sure about size of domain where it is working. if it just eats edn and doesn't trie to understand it, everything should be okay
hmmm... cljs.core has some funcs that are not in clojure.core and differences of interop, if you mean smth like that
yeah, or as the docs have it: ClojureScript is the same (at a Lisp level) as Clojure except for the following: no runtime evaluation no runtime compilation
So I’ve started my first ClojureScript project 😱 It’s working (sort of), but I’m struggling to find a good workflow. Server-side I have a standard ring app with http-kit I’ve also set up reloaded.repl. Client side I use ClojureScript and chord to communicate with the server. I’ve also added figwheel. Everything seems to work fine, except things crash when I run reloaded.repl/reset server side. It causes my browser to hang (I can’t reload the page or close the browser). Before I spend a lot of time debugging, I figured I would ask here if there are any obvious things I might have done wrong given my setup?
@chedgren: that’s not even quite true, runtime evaluation / compilation is optional - just not default.
oh, thanks. That line there's from the bottom of: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
@ebaxt: sounds like just the setup I use in http://parensofthedead.com - have you looked at differences between that and your code? You don't have to try to catch everything via the videos, the code is here: https://github.com/magnars/parens-of-the-dead
@magnars: Thanks, I used your project as a starting point I managed to isolate the problem to chord, and eventually managed to prevent Chrome from freezing up by handling closed channels properly.
@chedgren: and to answer your actual question - no it’s reasonable to think of ClojureScript as a subset of Clojure with affordances for the JavaScript runtime instead of Java
have anyone had luck including [mvxcvi/puget "0.9.2"] in a ClojureScript project? It throws a no namespace puget.printer
exception at me
ah, I have ultra...but a colleague of mine has empty profile.clj
you can try installing ultra from https://github.com/venantius/ultra/pull/42
no but I wanted to include it in a project, to use programmatically printer.cprint
, can it be min-lein-version
?
I am on 2.5.3 but maybe something goes hairy
true, will try, but this does not explain the behaviour with empty profile
i even tried puget 0.8.1
no sugar
ISO: approaches to serializing/deserializing/sanitizing JSON data with keys like {"This Is Gonna Hurt": true}
.
ie, Does this mean I have to abandon (js->clj json-response :keywordize-keys true)
altogether?
(keyword “This Is Gonna Hurt”) does yield a keyword value, though it’s technically not a valid keyword
Stuart has claimed the behavior of the keyword fn hereby is unspecified, IIRC
If you have no guarantee your json keys aren’t valid keywords, I’d skip the nicety of keywordize-keys myself
But I’m sorry, you’re talking about cljs, everything I’ve just said may be complete lies in this world, apologies.
@donaldball: No, useful and valid observations. Giving up keywords is painful though. Still mulling it over.
iirc cheshire allows you to supply a fn governing the transformation of json keys
@donaldball: right, as does clojure.data.json/read
...
In this frontend case, I think the keyword conversion is actually baked in to the HTTP lib (cljs-http)
@dnolen: Do you know if using transit would somehow circumvent this issue? Like does it "fix" keys with spaces automatically somehow?
if you want my honest opinion, keywordizing string keys is just more trouble than it is worth
Unfortunately it's the default (and I think non-configurable) when using cljs-http to talk JSON
@pandeiro: I took a look at cljs-http, it’s not hard to fix this, write your own 5-10 lines of middlware
@dnolen: Cheers; I'm trying to understand if there's an API for modifying middleware or if I'm supposed to just create a new replacement request
with the ones I want... Guessing the latter
it may be the case that it’s more work than I thought, I don’t have time to read that code further
No worries, appreciate it. It is the case I'm pretty sure, so I'm creating an issue to see if @r0man is interested in maybe streamlining that use-case.
Is there a reason other than "noone got around to it", that goog.net.IframeIo
is missing from
?
@mbertheau: I was just looking at that these days (the Closure lib ns, not the http://clojure.browser.net)
@mbertheau:
is really more of an implementation detail namespace
@dnolen: What is meant by that exactly? It shouldn't be used by applications usually?
Is there a clojurescript translation of the javascript require function? I am running tests in phantom and I would like to do this:
var system = require('system');
var env = system.env;
Object.keys(env).forEach(function(key) {
console.log(key + '=' + env[key]);
});
I can also just do it in javascript if I have to.phantom doesn't have require you have to use injectJs http://phantomjs.org/api/webpage/method/inject-js.html.
at least that is what worked for me when I first tried using cljs with node about a year ago.
@chrisn: You're looking to use some phantom libraries correct?
Okay I think I found how to do what you need. The cljs.nodejs
namespace has this (def require (js* "require"))
which defines require as a statement. js/require
treats require
as a global javascript object instead of a statement. once you def
require you should be able to use it like (require "event")
so the top two statements of your example would be
(def require (js* "require"))
(def system (require "system"))
(def env (.-env system))
let me know if that works
looking at the generated output @spinningtopsofdoom solution as well as a simple js/require should have worked
Yes. The real problem I am fighting is that I need an environment variable from inside my cljs script.
Phantomjs provides access via the method I posted way earlier but I cannot figure out how to get to that method while testing.
Wait, I only need these during unit testing. I don't need them when I am in the browser because the server sets these up.
No, the real answer is that we define this code in handler.clj and send it over during runtime but during test time they simply exist in the environment.
With the old cemerick testing system we could provide javascript to execute before executing the main test script and this allowed us to set a js variable when testing to this environment variable's value.
So then phantom is run in basically two different modes? If I provide a js file it runs it in the script but if it gets an html page it runs it in the browser?
in that script you can ask to open a webpage and evaluate code. that's when phantom makes a webkit instance and runs your code sandboxed there
Hmm, Can I pass information from the first scope into the second while still using the doo framework or does that mean I am completely off into my own non-doo universe?
Great question, if I can define arbitrary javascript to include into the cljsbuild then yes.
does that arbitrary javascript need access to your environment variables (aka is it node.js code)? then no
We had something like this before (in project.clj):
~(str "window.base_url='" (System/getenv "CATALOG_URL") "';")
@martinklepsch was kind enough to add those to the compiler.
from this side, it was harder to communicate than to solve. The compiler has matured a lot in the last year
(println (aget goog "base_url"))
did not but I get that is just not how you get to the goog stuffOK, I either need a js library just to define that closure variable or I need to hijack an existing closure variable.
and then use it as you would normally do, then at compile time, if the compiler finds it under :closure-defines
it will overwrite it with that value
This works:
:closure-defines {'style.test/base_url ~(System/getenv "CATALOG_URL")}
combined with:
(goog-define base_url "")
OK, now lein doo phantom once works but lein install doesn't because it doesn't find the doo namespaces. I really want the clojurescript compiler to never use the test configuration except during lein doo phantom once.
@bensu: Sort of.. I need to check if the type of a property is a function though. Not sure that would help in this case.
in any case, @richiardiandrea has opened an issue to use doo alongside figwheel, which is close (running it in other build contexts)
yes in my case I had to specify the doo runner in another folder:
{:id "test"
:source-paths ["src/cljs" "test/cljs" "test/doo"]
:compiler {:main launcher.runner
:output-to
:pretty-print false}}