Fork me on GitHub
#clojurescript
<
2018-09-08
>
dazld13:09:30

hey, having a hard time trying to get an external lib loaded - I’ve made an extern for it, but can’t seem to help the compiler find it - https://github.com/dazld/hello-hdom/blob/master/project.clj < any ideas?

dazld13:09:01

clojure.lang.ExceptionInfo: No such namespace:`

dazld13:09:51

(am giant noob, apologies in advance)

mfikes14:09:51

@dazld It is complaining that it can’t find the hdom namespace here, right? https://github.com/dazld/hello-hdom/blob/master/src/hello_hdom/core.cljs#L4

mfikes14:09:07

Yeah, I see what you are doing @dazld; you don’t require externs files like that

mfikes14:09:19

Ahh, you have hdom set up as a foreign lib, sorry. Misunderstood.

mfikes14:09:11

@dazld Since you are using figwheel.main and not cljsbuild, your compiler options would go into, say, dev.cljs.edn, I would imagine

mfikes14:09:36

To be honest, if using figwheel.main, I woudln’t bother with lein at all.

mfikes14:09:58

Just use deps.edn and clj to drive the whole show.

dazld14:09:04

thanks @mfikes - I’ll try that out 🙂

dazld14:09:00

that’s closer!

dazld14:09:28

now getting:

Compile Warning src/hello_hdom/core.cljs
Use of undeclared Var hello-hdom.core/hdom

dazld14:09:38

I’d like to stick with lein if possible, as this will have some server side elements too

dazld14:09:24

WARNING: JavaScript file found on classpath for library `hdom`, but does not contain a corresponding `goog.provide` declaration: file:/Users/dan/projects/cljs/hello-hdom/foreign/hdom.js

dazld15:09:56

sigh, can’t get this thing to work at all.

dazld15:09:29

sure it’s something small

dazld15:09:32

but.. no idea what

dazld15:09:59

if anyone knows how to fix this - would welcome a PR

dazld15:09:48

thanks for help anyway

dazld15:09:57

it's a js package I'd like to get working with cljs

dazld15:09:15

comes from here... sec

dazld15:09:07

have made a umd build and an extern to work from, but.. yeah.

thheller15:09:10

so did you try either using https://clojurescript.org/guides/webpack or shadow-cljs?

dazld15:09:51

kind of want to keep it minimal if possible

thheller15:09:27

more minimal than npm install @thi.ng/hdom and (:require ["@thi.ng/hdom" :as hdom])? 😉

dazld15:09:44

no umd build sadly

dazld15:09:08

but! if that works it would be awesome

dazld15:09:05

(generally, that is)

thheller15:09:44

it works in shadow-cljs

thheller15:09:54

it also works via webpack but that requires a bit more work on your end

dazld15:09:31

OK.. it sounds cool, but would love to get this going first

mfikes15:09:31

@dazld So it is evidently loading your foreign library now, but you want to reference symbols in it…

mfikes15:09:27

You should be able to access it via js/hdom

dazld15:09:38

(have to run, but will check in later)

mfikes15:09:44

But, you can make that a little more idiomatic by using :global-exports

mfikes15:09:00

Then in your code it should be as simple as

(ns ...
  (:require [hdom]))

(hdom/clearDOM)

mfikes16:09:43

@dazld Ahh, you needed to simply put the compiler options directly in the Figwheel compiler options file (not under a :compiler-options key). Sent a PR with that and example of how to use :global-exports

💥 4
p4ulcristian16:09:46

Hello, can anybody help me on this stackoverflow post? https://stackoverflow.com/questions/52237173/reagent-uikit-dropdown-use Any help is appreciated 🙂

john18:09:26

Is there a quick hack to bring foreign deps into maria.cloud?

john18:09:15

I'd like to bring in a js wast interpreter, to test a wast dsl in cljs https://www.maria.cloud/gist/23d9a94fb30ceda55bb62367775e2f73

john18:09:32

That's a dsl based on the wah method here: https://github.com/tmcw/wah/blob/master/doc/intro.md

john18:09:30

The maria.cloud gist experiments with fixing up the float interpretation using reader tags. Doesn't really work with how macros work out in maria.cloud though.

john18:09:25

I've also implemented a version based on https://deque.blog/2017/01/26/catamorph-your-dsl-clojure/ and another that just composes strings on strings. I'd like to get versions of each up on maria.cloud. But it'd be more useful if produced ast forms could be compiled to wasm in browser and tested live.

john18:09:23

I'm guessing I can just xhr a dep and inject it in the document

stvnmllr220:09:23

does javascript have namespaces yet?

john20:09:42

es6 modules I believe are JS's answer to namespaces, though closures are the old school hack to make things private

rsslldnphy21:09:22

hello 👋. has anyone had any success working out how to do snapshot testing in re-frame?

rsslldnphy21:09:38

we started using jest snapshot tests in a js react app at work and it has been a revelation - solves so many of the problems i’ve experienced with f/e tests in one fell swoop - and i’m just starting a new cljs/re-frame app and i’d really like to be able to write snapshot tests for it too

rsslldnphy21:09:01

my attempts so far have involved using react-test-renderer-shallow like this:

rsslldnphy21:09:05

(ns caseworker.core-test
  (:require [cljs.test :refer-macros [deftest testing is]]
            [caseworker.core :as core]
            [caseworker.home.views :as layout]
            [reagent.core :as reagent]))

(deftest snapshot-test
  (testing "snapshot test attempt"
    (is (= []
           (-> (js/ReactShallowRenderer.)
               (.render (-> [home/page]
                            (reagent/as-element))))))))

rsslldnphy21:09:27

(ignore the empty vector, just trying to get a failing test so i can see the output printed)

rsslldnphy21:09:04

this works to a point, but it doesn’t descend into nested components in the page component, so is of limited utility

rsslldnphy21:09:51

this is the output from that test:

rsslldnphy21:09:54

#js{:$$typeof #object[#object[Symbol]],
	                :type "div",
	                :key nil,
	                :ref nil,
	                :props #js{:children #js[#js{:$$typeof #object[#object[Symbol]],
	                                             :type #object[#object[Function]],
	                                             :key nil,
	                                             :ref nil,
	                                             :props #js{:argv [#object[#object[Function]]]},
	                                             :_owner nil,
	                                             :_store #js{}}
	                                         #js{:$$typeof #object[#object[Symbol]],
	                                             :type "div",
	                                             :key nil,
	                                             :ref nil,
	                                             :props #js{:className "container-fluid"},
	                                             :_owner nil,
	                                             :_store #js{}}]},
	                :_owner nil,
	                :_store #js{}})

rsslldnphy21:09:47

i was wondering if there’s a way to evaluate a reagent component that recursively calls the custom components inside it until you’re left with just “keyword hiccup”, for want of a better way of describing it? haven’t been able to find one yet but not sure what to search for