Issues with using core.async from clojurescript

I’m trying to use core.async from a clojurescript project, and for some reason, the compilation fails, complaining about the cljs.core.async namespace being missing. I’m just starting out with cljs tooling, so I’m a bit lost at the moment.

My deps.edn is as follows

{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
        org.clojure/clojurescript {:mvn/version "1.10.520"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
        com.bhauman/figwheel-main {:mvn/version "0.2.3"}
        org.clojure/core.async {:mvn/version "0.4.500"}
        reagent {:mvn/version "0.8.1"}}
 :paths ["src" "resources" "target"]
 :aliases {:fig {:extra-deps
                  {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
                   com.bhauman/figwheel-main {:mvn/version "0.2.3"}}
                 :extra-paths ["target" "test"]}
           :build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]}
           :min   {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]}
           :test  {:main-opts ["-m" "figwheel.main" "-co" "test.cljs.edn" "-m" "csio.test-runner"]}}}

And my ns form:

(ns ^:figwheel-hooks fi.varela.rtc
  (:require
   [goog.dom :as gdom]
   [reagent.core :as reagent :refer [atom]]
   [promesa.core :as p]
   [cljs.core.async :as async]
   [fi.varela.utils.audio :as a]
   [cljs.pprint :as pprint])
  (:require-macros [cljs.core.async.macros :as async-m]))

And this is what I’m getting:

[Figwheel:WARNING] Compile Exception   src/fi/varela/rtc.cljs   line:6  column:5

  No such namespace: cljs.core.async, could not locate cljs/core/async.cljs, cljs/core/async.cljc, or JavaScript source providing "cljs.core.async" in file src/fi/varela/rtc.cljs

   1  (ns ^:figwheel-hooks fi.varela.rtc
   2    (:require
   3     [goog.dom :as gdom]
   4     [reagent.core :as reagent :refer [atom]]
   5     [promesa.core :as p]
   6     [cljs.core.async :as async]
          ^---
   7     [fi.varela.utils.audio :as a]
   8     [cljs.pprint :as pprint])
   9    (:require-macros [cljs.core.async.macros :as async-m]))
  10  

I suspect I’m doing something quite stupid, but I can’t quite figure out what, exactly. Any help would be appreciated!

The namespace is clojure.core.async not cljs.core.async.

That’s strange. In all example cljs code I’ve seen using core.async, they always require it as cljs.core.async, and that namespace is in the repo (here).

No, it is cljs.core.async. clojure.core.async is just aliased to cljs.core.async automatically.

Not sure about the error though. Looks correct to me. Maybe you didn’t restart figwheel-main after adding the dependency?

Thanks @thheller! I’m pretty sure (though not 100%) I did restart everything, but I’ll give that a go when I’m back in the office. In the meantime, I got around my issue by using Promesa.

Btw, I just got my first taste of shadow-cljs earlier today, it’s great! Thanks for that as well!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.