Clojure到JavaScript转换器(Leiningen)

Clojure to JavaScript Converter (Leiningen)

本文关键字:Leiningen 转换器 JavaScript Clojure      更新时间:2023-11-13

我已经安装了Leiningen,项目已经全部就绪。有人告诉我使用"lein-cljsbuildonce"命令将Clojure转换为JavaScript。这并没有完全回答我的问题,因为我很难理解项目的文件夹结构。

这是我的项目。clj:

    (defproject proj "2.3.4"
  :plugins [[lein-cljsbuild "1.0.1-SNAPSHOT"]]
  :cljsbuild {
    :builds [{
        ; The path to the top-level ClojureScript source directory:
        :source-paths ["src"]
        ; The standard ClojureScript compiler options:
        ; (See the ClojureScript compiler documentation for details.)
        :dependencies [[org.clojure/clojure "1.5.1"]]
        :main project.clj
        :compiler {
          :optimizations :whitespace
          :pretty-print true}}]})

我对它的理解是,它自动检测在"src"文件夹中找到的文件,并将它们输出到target/clojudescript-main.js(或类似的东西)。我把我想转换的文件放在src文件夹中,它似乎编译了一些东西。当我检查目标文件夹时,它包含project.clj中的文件集,但不包含我期望的JavaScript代码(我看到的只是与我想要转换的文件无关的goog.methods)。

我的问题是:什么是合适的文件夹结构?我必须将源路径设置为例如"src/filename.clj"吗?

提前感谢

我认为你必须阅读文档

https://github.com/clojure/clojurescript/wiki/Quick-Start

这也将帮助您:
http://swannodette.github.io/2013/10/27/the-essence-of-clojurescript/