Fork me on GitHub
#clojurescript
<
2018-10-20
>
ikitommi12:10:04

Hi. Is there a way to work mutually recursive specs with ClojureScript? here’s the issue: https://github.com/metosin/reitit/issues/127

ikitommi12:10:47

works ok with Clojure

mfikes12:10:35

It is generally true, that ClojureScript will want to follow Clojure where at all possible, and if it isn't for any good reason, it would be treated a bug

igrishaev13:10:24

Can anybody help me with linking a js file into a cljs project aimed at NodeJs? What I did: 1) created a file src/aaa.js

function AAA() {
    return 42;
}
2) added a compiler option
:foreign-libs [{:file "src/aaa.js"
                         :provides ["aaa"]}]
3) In my code:
(ns some.ns
  (:require
   [aaa]

...
(print (js/AAA))
but then I get goog.nodeGlobalRequire is not a function what did I do wrong?

mfikes13:10:06

@igrishaev On the surface, your approach looks correct. Seeing if I can repro locally...

igrishaev13:10:14

talking more precisely, this is a re-natal project run on iOS =)

mfikes13:10:27

$ clj -m cljs.main -co '{:foreign-libs [{:file "src/aaa.js" :provides ["aaa"]}]}' -r
ClojureScript 1.10.339
cljs.user=> (require 'aaa)

cljs.user=> (js/AAA)
42

mfikes13:10:05

OK, will try with re-natal; it should work there too.

mfikes13:10:25

(I've used foreign libs this way with in such a project, but will check for this example.)

mfikes13:10:06

@igrishaev I was able to repro the goog.nodeGlobalRequire issue. Now looking at my older project to see what's up. Perhaps there is a regression in ClojureScript.

mfikes13:10:21

(Repro'd with re-natal.)

mfikes13:10:09

@igrishaev I was mistaken; I don't have an older project that works this way. But, it is possible to work around the issue by removing :target :nodejs from the compiler options. I'll log a ticket in re-natal where we can futher explore what is going on here.

igrishaev13:10:23

@mfikes hm, will the project work if I remove the :target :nodejs expression?

mfikes13:10:49

Yes, so long as you don't really need that for anything else. It was introduced with re-natal 0.9.0 and may have other consequences.

igrishaev13:10:35

ok, let me recompile

igrishaev13:10:29

@mfikes unfortunately, the project didn’t compile when I commented the target option, got lots of errors. Perhaps I’ll figure out some other way.

igrishaev13:10:12

anyway, thanks a lot, I though it was my clumsy hands

mfikes14:10:36

@igrishaev No problem. I think the fundamental problem is that ClojureScript assumes that if :target :nodejs, then bootstrap_nodejs.js is being used with Node (which defines nodeGlobalRequire) but this is not the case in for the Node environment being used with re-natal

pez19:10:01

I just released a module for scroll position management in SPAs, Clerk. Feedback welcome: https://clojureverse.org/t/say-hello-to-clerk-in-page-navigation-for-single-page-applications/3041