This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-31
Channels
- # aws (1)
- # beginners (70)
- # boot (12)
- # calva (45)
- # cider (45)
- # clara (1)
- # cljdoc (10)
- # cljs-dev (133)
- # clojure (315)
- # clojure-dev (2)
- # clojure-europe (2)
- # clojure-italy (16)
- # clojure-nl (1)
- # clojure-spec (23)
- # clojure-uk (19)
- # clojurescript (48)
- # cursive (11)
- # data-science (5)
- # datomic (18)
- # figwheel-main (3)
- # fulcro (18)
- # graphql (14)
- # jackdaw (1)
- # juxt (1)
- # kaocha (1)
- # off-topic (10)
- # other-languages (3)
- # pathom (2)
- # pedestal (7)
- # re-frame (23)
- # reagent (1)
- # reitit (4)
- # ring-swagger (12)
- # rum (4)
- # shadow-cljs (26)
- # specter (6)
- # speculative (12)
- # tools-deps (44)
- # vim (8)
- # yada (2)
I’m trying to run https://github.com/Olical/cljs-test-runner with jsdom pre-loaded so that the code that references window
etc can be loaded. I tried passing these options to the compiler
{:verbose true
:optimizations :none
:npm-deps {:jsdom "13.2.0"}
:install-deps true}
but then I need a preload to require jsdom, right?
thanks. Alright, so my options now are:
{:verbose true
:preloads [test.preload]
:optimizations :none
:npm-deps {:jsdom "13.2.0"}
:install-deps true}
and preload.cljs is:
(ns test.preload
(:require [jsdom :as dom]))
(js/console.log jsdom)
but I get:
Compiling /Users/sideris/devel/work/gt/taz/dev/test/preload.cljs to cljs-test-runner-out/test/preload.js
#error {
:cause No such namespace: jsdom, could not locate jsdom.cljs, jsdom.cljc, or JavaScript source providing "jsdom" in file /Users/sideris/devel/work/gt/taz/dev/test/preload.cljs
...
@borkdude yes it’s node. It worked! the documentation mentions that :require
works, but clearly that’s not the case
and by “documentation”, I mean this article: https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
:npm-deps
is alpha with a lot of edge cases. so it is supposed to work via ns require but doesn't for some reason
thanks!
I’m taking a second stab at thinking about how to do conditional-ish load of a namespace (in this case, clojure.datafy)
I’m thinking of having some kind of indirection, where normally my library doesn’t use clojure.datafy, but by requiring a namespace it replaces the implementation with dataficationy things
trying to think of the best way to do the indirection though. using an atom feels weird. multimethods don’t seem right
not sure what your point is? the clojure.datafy
namespace is tiny why is that something you want to eliminate?
@thheller maybe it’s not as important as I think, but I’m trying to support versions less than what’s in master right now
@lilactown you could try this. I haven't tested it much though https://clojurians-log.clojureverse.org/cljs-dev/2019-01-08/1546981037.172600
well I could force them in order to use my cool awesome library!! 😛 but that sounds like hubris
@john yeah I remember that. I’m wary of it, seems like something that at the very least I would not want to troubleshoot if it broke peoples builds or whatever
I suppose. There’s just a relatively small surface area of my lib that actually uses datafy/nav, so it seems like something that would be easy enough to just elide if not there 😞
and exist?
may not work with 3rd party libs, depending on load order. datafy
should exist prior to all 3rd party libs though, if at all.
if you only implement it because some tool may use it during development you are doing it wrong (IMHO)
I guess things are easier in Clj: https://github.com/tonsky/clojure-future-spec/blob/master/src/clojure/future.clj
yeah, I abuse the more dynamic nature of CLJ all the time. unfortunately not possible in CLJS or rather JS I should say 😞
for posterity, this is my preload now:
(ns test.preload)
(def jsdom (js/require "jsdom"))
(js/console.log (.-JSDOM jsdom))
(set! js/window (new (.-JSDOM jsdom)))
(js/console.log js/window)
test suite still fails, but for a new reason 😄 Error: React module should be required before createClass
if you use the metadata protocol support to implement the datafy/nav protocols, it will have no dependencies on the datafy namespace
it’s just metadata with a map of symbols to functions
people without datafy are none the wiser, but people with datafy get the impl
we do this in some spots in the aws-api lib - https://github.com/cognitect-labs/aws-api/blob/9ac5c2cdfad0518e60f49eb8f4f52da05f0aeaa5/src/cognitect/aws/service.clj#L76-L77
oh, well that’s different :)