【问题标题】:simple boot project not working with cljs and async简单的启动项目不适用于 cljs 和 async
【发布时间】:2016-10-14 19:53:39
【问题描述】:

我有一个非常简单的项目。我用 boot 和 cljs 创建了有史以来最简单的项目。它编译成功,我能够在 html 中看到正确的日志。当我添加对异步的基本支持时,我收到了消息:

No such namespace: clojure.core.async, could not locate clojure/core/async.cljs, clojure/core/async.cljc, or Closure namespace "clojure.core.async"

该项目只有以下结构:

exemplo_cljs
    html
       index.html
    src
       exemplo_cljs
           core.cljs
    build.boot

index.html的内容:

<!doctype html>
<html lang="en">
    <head>
        <title>Hello</title>
    </head>
    <body>
        <h2>Hello</h2>
        <script src="main.js"></script>
    </body>
</html>

core.cljs

(ns exemplo-cljs.core
  (:require [clojure.core.async :as async]))

(def exercise (async/chan))

;; enable cljs to print to the JS console of the browser
(enable-console-print!)

;; print to the console
(println "Hello, World 4!")

和 build.boot

(set-env!
 :source-paths #{"src"}
 :resource-paths #{"html"}

 :dependencies '[[adzerk/boot-cljs "1.7.170-3"]
                 [org.clojure/core.async "0.2.371"]])

(require '[adzerk.boot-cljs :refer [cljs]])

除了 core.cljs 文件中通道的 require 和 def 以及 build.boot 中添加的依赖项之外,原始工作项目具有相同的基本结构

【问题讨论】:

    标签: clojure clojurescript core.async boot-clj


    【解决方案1】:

    这是因为在 ClojureScript 中,core.async 位于 cljs.core.async 而不是 clojure.core.async 下。

    所以你只需要将你的 ns 表单更改为:

    (ns exemplo-cljs.core
      (:require [cljs.core.async :as async]))
    

    【讨论】:

    • 出于某种奇怪的原因,它在 lein 中起作用。当我迁移到引导时我很困惑。
    • cljs 版本是否不同?我认为 cljs/Clojure 导入命名空间的事情最近发生了变化。见:blog.fikesfarm.com/posts/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-25
    • 2021-08-24
    相关资源
    最近更新 更多