This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-02
Channels
- # bangalore-clj (1)
- # beginners (5)
- # cider (24)
- # clara (2)
- # cljs-dev (6)
- # cljsrn (2)
- # clojure (10)
- # clojure-austin (2)
- # clojure-serbia (1)
- # clojure-spec (6)
- # clojure-uk (6)
- # clojurescript (59)
- # cursive (1)
- # datomic (10)
- # emacs (3)
- # events (7)
- # graphql (1)
- # jobs (2)
- # lein-figwheel (9)
- # off-topic (40)
- # pedestal (5)
- # portkey (2)
- # re-frame (5)
- # reagent (20)
- # shadow-cljs (7)
- # spacemacs (4)
- # specter (19)
- # testing (21)
I've choosen react-menu-bar
. After installing it via npm npm install react-menu-bar
I have included it in my ns: (:require ["react-menu-bar" :as menu]))
- but now the compilation is raising an error:
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
errors in file: /home/otwieracz/dev/clojure/shadow-cljs-test/node_modules/react-menu-bar/src/MenuBar.jsx
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/react-menu-bar/src/MenuBar.jsx", :js-requires [], :js-err
s [{:line 34, :column 7, :message "primary expression expected"}], :goog-requires [], :tag :shadow.build.npm/errors}
ExceptionInfo: errors in file: /home/otwieracz/dev/clojure/shadow-cljs-test/node_modules/react-menu-bar/src/MenuBar.jsx
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.npm/get-file-info* (npm.clj:527)
shadow.build.npm/get-file-info* (npm.clj:435)
shadow.build.npm/get-file-info (npm.clj:563)
shadow.build.npm/get-file-info (npm.clj:560)
shadow.build.npm/find-resource (npm.clj:652)
shadow.build.npm/find-resource (npm.clj:612)
@slawek098 you are doing nothing wrong. it is very bad form for npm packages to contain .jsx code and proper packages do not do that. react-menu-bar
has not been updated for years https://github.com/ahutchings/react-menu-bar and has barely any downloads at all https://www.npmjs.com/package/react-menu-bar. so you probably best stay away from it. the package basically assume you are using webpack
which is unfortunate.
What is the valid approach to react-bootstrap
with reagent
in shadow-cljs
? All guides I am seeing suggest using cljsjs/react-bootstrap
so it's not applicable for shadow-cljs
AFAIK.
Hi there ... do somebody know a good cljs lib for templating (like selmer is for clj)? I'm not going to produce html so generation (like enlive) will not work for me ...
@jerger_at_dda i have recently used selmer to render LaTeX, which was pretty cool
Porting was my first thought also - but I found some java related stuff like commons-codec in selmer dependencies. So I'm not really sure about portability ...
@jerger_at_dda i think it is only used here
i have similar cross-runtime code for hashing and encoding here https://github.com/replikativ/hasch/
not that you need it, but hex encoding and crypto hashes are readily available in cljs/js
so this should translate right away: https://github.com/replikativ/hasch/blob/master/src/hasch/md5.cljc
@jerger_at_dda but if you try to port it, i am willing to help if you get stuck
What's the idiomatic way, with lein and cljs to have a value change between dev and deploy? I have a URL that needs to change (from localhost to live site) on deploy. Can I use :resource-paths for some trickery?
FWIW, the ClojureScript compiler has support for Google Closure defines: https://clojurescript.org/reference/compiler-options#closure-defines
Thanks guys! I'll check it out. What I'm doing now, which is slightly cheesy, it to have a namespace defined in two directories. Each build profile points to a different directory, so I can switch out vars depending on profile.
@whilo Thanx for your offer. But as discussed with yogthos (see https://github.com/yogthos/Selmer/issues/173) I tend to do some regex magic by my own over trying a full selmer port.
core.cljs:
(ns jsx.core
(:require-macros jsx.core))
(js/console.log (compile [:div nil "hello"]))
(defn ^:export init []
(println "init"))
see the conversion here: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/tagged_literals.cljc#L70-L85
AFAIK you should be able to construct it in your macro, doing what reader would do (`JSValue` is a clojure thing I believe)
but this sounds like too much trouble, I would recommend emitting js-obj
and similar function calls for doing what you would like to do via #js
I have another semi-related question though: how do I define my own tagged literals?
I tried creating a data_readers.clj
with {jsx/t jsx.core/compile}
and it’s not working
not sure about data_readers, it should be possible somehow, but I would recommend reconsidering clj->js, a lot of work will be done at runtime, which is not necessary
I can probably add an optimization later that if a literal map is passed in to generate js-obj
instead
Using npm-deps and graphql, I get Uncaught Error: Undefined nameToPath for graphql
when requiring it. Anyone know why or how to fix it?
@lilactown Updated to [com.google.javascript/closure-compiler-unshaded "v20180506"]
but no luck. What version are you using?