This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-31
Channels
- # architecture (1)
- # aws (23)
- # beginners (13)
- # boot (18)
- # cider (5)
- # clara (1)
- # cljs-dev (22)
- # cljsjs (9)
- # cljsrn (28)
- # clojure (120)
- # clojure-canada (12)
- # clojure-dev (6)
- # clojure-italy (4)
- # clojure-korea (1)
- # clojure-russia (18)
- # clojure-sg (8)
- # clojure-spec (45)
- # clojure-uk (12)
- # clojurescript (240)
- # component (4)
- # cursive (17)
- # datomic (91)
- # editors-rus (4)
- # figwheel (2)
- # flambo (6)
- # hoplon (163)
- # instaparse (6)
- # jobs (1)
- # leiningen (2)
- # luminus (5)
- # om (22)
- # om-next (2)
- # onyx (35)
- # perun (15)
- # play-clj (1)
- # protorepl (4)
- # re-frame (106)
- # reagent (4)
- # ring (106)
- # schema (1)
- # spacemacs (17)
- # untangled (40)
- # yada (14)
@juhoteperi: they’re not inherently compatible, but babel or webpack takes care of the differences so ES6 import syntax works for commonJS modules, and probably others
I have a problem that I can't seem to solve and maybe it has already been adressed. Let's say I have a .cljc
file with:
(defmacro safely
"Evaluates expr within a try/catch and returns the result.
If present, in case of errors it executes (ex-handler ex), a function
that accepts the exception, returning its value.
If the ex-handler is not present it just returns the exception.
The exception is always printed with TRACE log level."
[expr & [ex-handler]]
(let [ex-sym (gensym)]
`(try
~expr
(catch #?(:clj Throwable :cljs :default) ~ex-sym
#?(:clj (clojure.tools.logging/trace ~ex-sym "safely wrapped")
:cljs (adzerk.cljs-console/trace ~ex-sym))
~(if ex-handler
(list ex-handler ex-sym)
ex-sym)))))
When I :require-macros
the :clj
part of the reader conditional is resolved BUT I have strict classpath isolation in my project and I do not have clojure.tools.logging
in the frontend so an error is triggeredI understand why the :clj
part at the moment is evaluated where :require-macros
is in place, I don't even know why I am raising this issue, maybe I would love to see only the :cljs
part evaluated when Clojurescript files are in play...I know I know not possible at the moment 😄
@richiardiandrea: hmm, what happens when you do :require :refer…
(aka implicit refer) from cljs?
let me try
@richiardiandrea I don’t think you can use reader conditionals in macros like that
it might be better to conditionalize the macro itself
based on e.g. the existence of (:ns &env)
@darwin WARNING: Wrong number of args (2) passed to aprojectt.utils/safely at line 6 test/common/aprojectt/utils_test.cljc
with (require [aprojectt.utils :as utils :refer [safely]])
@anmonteiro oh that's a neat trick
that above trick might work though
@anmonteiro you are right I assumed I could and I knew it was a shot in the dark
now I remember having seen a similar trick: https://github.com/adzerk-oss/env/blob/master/src/adzerk/env.clj#L14
the problem does not really go away because at the top of my .cljc
file I have a:
(:require
#?(:clj [clojure.tools.logging])
that gets evaluated anyways
I could remove it and force a require from client code
it feels hackish (and maybe it is :))