This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-24
Channels
- # aws (14)
- # beginners (111)
- # boot (12)
- # cider (1)
- # cljsrn (7)
- # clojure (65)
- # clojure-dusseldorf (1)
- # clojure-germany (7)
- # clojure-greece (10)
- # clojure-italy (13)
- # clojure-poland (7)
- # clojure-russia (7)
- # clojure-spec (53)
- # clojure-uk (29)
- # clojurescript (27)
- # community-development (9)
- # cursive (2)
- # data-science (1)
- # datomic (17)
- # emacs (16)
- # events (6)
- # fulcro (155)
- # graphql (8)
- # instaparse (1)
- # leiningen (30)
- # lumo (29)
- # om-next (3)
- # other-languages (46)
- # pedestal (11)
- # portkey (7)
- # re-frame (13)
- # reagent (6)
- # ring (8)
- # rum (1)
- # shadow-cljs (75)
- # sql (1)
- # timbre (3)
- # unrepl (128)
I just tested shadow-cljs in my project and everything just works.. How can this be?? I haven't even included my 2500 lines extern files. This has got to be black magic.
it even knows I'm pulling a var from script tag???
vN.j ? vN.j(ax, e5) : vN.call(null, ax, e5);
function f5() {
return "undefined" !== typeof $zopim ? $zopim.livechat.window.show() : null
wow... why doesn't everybody just use this. I think I spent close to a week debugging mangled node libraries that I fed to closure
thank you for shadow-cljs, this is amazing. I will help with documentation as I go along.
its early still … still much left to do. I really need to write more docs but I prefer writing code.
just pushed [email protected]
. see https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9
wow that looks really useful! I’ll give shadow-cljs a spin when I get a chance 😄 can it run in separate “.edn” files like boot-cljs (https://github.com/boot-clj/boot-cljs/blob/master/docs/cljs.edn.md)?
could add something like shadow-cljs.<build-id>.edn
if that seems useful. I kinda like having my config in one place but it tends to get pretty large in bigger projects.
you can configure many builds https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L28
How do people here handle cljs.spec integration with regards to the instrument
call? My first guess would be to call it after each reload?
I’m looking to use the “consul” npm module from cljs in a shadow-cljs project. I’m doing: (:require ["consul" :as consul])
in cljs, and the consul.js looks like:
function Consul(opts) {
if (!(this instanceof Consul)) {
return new Consul(opts);
}
.....
};
/**
* Module exports.
*/
exports.Consul = Consul;
I find a blog entry (https://blog.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html) that states: Some packages just export a single function which you can call directly by using (:require ["thing" :as thing]) and then (thing).
That is because they export a class
probably consul/Consul
will work
eval error <eval>:-6
shadow.js.shim.module$consul.Consul()
^
TypeError: Cannot read property 'Consul' of undefined
at <eval>
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at runInThisContext (vm.js:152:38)
at global.SHADOW_NODE_EVAL (/Users/sundbp/dev/bi/permafrost/out/permafrost.js:113:30)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/sundbp/dev/bi/permafrost/target/shadow-cljs/builds/pf/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:28:1)
and consul/default
?
eval error <eval>:-6
shadow.js.shim.module$consul["default"]()
^
TypeError: Cannot read property 'default' of undefined
if i change “consul” to “consul123" it fails, so it’s doing “something” with the require..
[:pf] Compiling ...
[:pf] Build failure:
The required JS dependency "consul123" is not available, it was required by "permafrost/cli.cljs".
can you print what is in the consul object?
Can you require consul/consul
?
consul.consul
i mean
[:pf] Compiling ...
[:pf] Build failure:
The required JS dependency "consul.consul" is not available, it was required by "permafrost/cli.cljs".
You are trying this dependency right?: https://github.com/silas/node-consul
What is your target? :node
?
I am sorry I have no idea what is going wrong 😞
I have never tried node stuff with shadow-cljs
in package.json of consul package it says main = ./lib, and then in lib/consul.js is the code i pasted.
Yeah same to me
» less target/shadow-cljs/builds/pf/dev/out/cljs-runtime/shadow.js.shim.module\$consul.js
goog.provide("shadow.js.shim.module$consul");
shadow.js.shim.module$consul = require("consul");
@thheller I’ve got a feeling we’re hitting some kind of bug here in the require system. it all looks ok, but I don’t think that the require to that shim has happened at the right time or something like that. looks like it’s nil
@mitchelkuijpers i got it to work in a release build!
Aah ok
in release i can do the require, and then do (prn (js-keys (consul)))
and see the fns in the js docs
@thheller let me know when you’re around and I can describe things and perhaps we can diagnose what goes wrong in REPL case.
now next problem is to call a nested fn. i.e. I can do (let [c (consul (clj->js {...})] ...)
, but then i need to access .kv.get
in that c
object.
if i fetch out the fn via e.g. aget
and call it I get a failure as it expects this
to be set to c
during the call..
actually - got it all to work now. started again, cleaned dirs etc and got it working.
@jiyinyiyong where did you get this error? ah hmm … crap you are probably requiring cljs.test
and do deftest
somewhere in your build
shadow.test.env
is included automatically for the new test builds but not for everything else. need to fix that
@sundbp (:require ["consul" :as consul])
should have just worked. no idea why it wouldn’t.
@jiyinyiyong fixed in [email protected]
, sorry about that.