Code Monkey home page Code Monkey logo

Comments (18)

emezeske avatar emezeske commented on September 26, 2024

Changing this to milestone 0.1.4, because it's not as trivial as I thought. Back in 0.0.x, before the plugin was split into two parts, this would have been easy. Now, though, the cljsbuild JAR has a direct dependency on the clojurescript compiler; I'm not sure how the version could be made configurable without some gymnastics.

from lein-cljsbuild.

jenanwise avatar jenanwise commented on September 26, 2024

For what it's worth, specifying the desired clojurescript version as a normal dependency in project.clj will overwrite whatever version lein-cljsbuild specifies, at least with lein 1.7.1. I was using clojurescript 0.0.1004 with lein-cljsbuild 0.1.3 that way for a few days with no issue.

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

Hmm, that's very interesting. I'm not sure I understand why that works; I'll have to dig into the source. Once I convince myself that it should always work, I'll add a note to the docs about it!

from lein-cljsbuild.

swannodette avatar swannodette commented on September 26, 2024

I think it would be desirable to be able to specify that you want to use ClojureScript HEAD. This makes it much easier to ask people to test out changes before they go out so we can catch issues sooner. What do you think?

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

@swannodette: Yeah, being able to just specify ClojureScript HEAD would be quite nice. I think a lot of people (myself included) would be happy to accept the risk of using the bleeding edge ClojureScript to get the benefits of the most up-to-date bug fixes, etc. I wonder if there's some way to do that with a lein checkout dependency. I'll look into it.

from lein-cljsbuild.

lynaghk avatar lynaghk commented on September 26, 2024

A checkout dependency sounds great, because then you'd be able to hack directly on the ClojureScript sources and use lein-cljsbuild to test ClojureScript compiler bugfixes and new features.

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

Okay, so I found a way to achieve this without any changes on the lein-cljsbuild side of things. It turns out that you can't use clojurescript as a checkout dependency, because it does not have a project.clj file. However, you can specify the source path of a local checkout in the :extra-classpath-dirs option, and it will take precedence over the upstream JAR.

In the advanced example, I tested this by creating a checkouts/ subdirectory in the top-level project directory, and dropping a clojurescript clone into it. I then set up the project.clj with the following:

(defproject cljsbuild-example-advanced "0.1.7"
  :extra-classpath-dirs ["checkouts/clojurescript/src/clj"])

When I ran lein cljsbuild commands in the advanced project, they picked up the local checkout copy. I think this is simple enough to be a workable solution; let me know what you guys think. If you agree, I'll make sure that it gets documented somewhere.

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

One note regarding my comment above: I tested this with Leiningen 1.7. Leiningen 2.x does not have the :extra-classpath-dirs option anymore. However, I think the same behavior can be achieved by adding the checkout source dir to the :source-paths option.

from lein-cljsbuild.

lynaghk avatar lynaghk commented on September 26, 2024

Does Lein guarantee that :extra-classpath-dirs and/or :source-paths will always take precedence over namespaces provided in dependency JARs, or is that just a current implementation detail?
If it's by design, it'd be great to add a note to Leiningen's sample-project.clj documentation.
Pinging @technomancy.

from lein-cljsbuild.

technomancy avatar technomancy commented on September 26, 2024

Anything in the project will take precedence over anything external, so this should do what you want. It's a bit of an abuse of that key, but I guess clojurescript is enough of an edge case to justify it.

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

Changing this to a "Documentation" task. I need to add documentation on how to do this the versioned docs, or maybe the wiki.

from lein-cljsbuild.

Gozala avatar Gozala commented on September 26, 2024

I have tried this but I get following error

checkouts  (repl) lein trampoline cljsbuild repl-rhino                                                                                      ✭ ✱
Running Rhino-based ClojureScript REPL.
"Type: " :cljs/quit " to quit"
"Error evaluating:" (def global-hierarchy (atom (make-hierarchy))) :as "cljs.core.global_hierarchy = cljs.core.atom.call(null,cljs.core.make_hierarchy.call(null));\n"
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "fromArrays" of undefined (cljs/core.cljs#3510)
    at cljs/core.cljs:3510 (make_hierarchy)
    at cljs/core.cljs:3510

I don't get it if I run

checkouts/clojurescript/script/repljs 

from lein-cljsbuild.

Gozala avatar Gozala commented on September 26, 2024

My versions are:

Leiningen 1.7.0 on Java 1.6.0_31 Java HotSpot(TM) 64-Bit Server VM
:plugins [[lein-cljsbuild "0.1.8"]]

from lein-cljsbuild.

Gozala avatar Gozala commented on September 26, 2024

here is my project.clj

(defproject clojurescripting "1.0.0-SNAPSHOT"
  :description "Learning clojurescript"
  :url "http://documentup.com/gozala/clojurescripting/"
  :license {:name "MIT"
            :url "http://jeditoolkit.com/LICENSE" }
  :dependencies [[org.clojure/clojure "1.4.0"]]
  :plugins [[lein-cljsbuild "0.1.8"]]
  :extra-classpath-dirs ["checkouts/clojurescript/src/clj"] ;; Makes use of lates cljs
  :cljsbuild {:repl-listen-port 9000
              :repl-launch-commands {
                                     "repl" [ "open" "http://localhost:9000/repl-demo" ]
                                     }                       
              :builds [{:source-path "src"
                        :compiler {:output-to "lib/app.js"
                                   :optimizations :whitespace
                                   :pretty-print true }}]})

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

I talked to @Gozala about this in IRC, and he found out the hard way that my original example was not quite right. Both of the source directories in the clojurescript checkout need to be in the classpath:

(defproject cljsbuild-example-advanced "0.1.7"
  :extra-classpath-dirs ["checkouts/clojurescript/src/clj" "checkouts/clojurescript/src/cljs"])

[EDIT] Credit goes to yoklov in IRC for realizing this was the problem.

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

Note that for Leiningen 2.x, a couple things need to be done differently to make this hack work.

The first difference is that the clojurescript checkout should not go in the checkouts/ directory. Leiningen expects that directory to contain Leiningen projects (with a project.clj, etc), and the clojurescript compiler is not such a project. So make sure to put the checkout somewhere else.

The second difference is that instead of using the :extra-classpath-dirs option in the project.clj file to put the compiler's source paths on the classpath, the :source-paths option should be used. The clojurescript source paths should be appended to your project's normal source paths.

from lein-cljsbuild.

thomcc avatar thomcc commented on September 26, 2024

I can confirm this works. In my lein 2.0 project.clj I have something like

(defproject example "0.0.0"
  :profiles {:dev
             {:source-paths
              ["comp/clojurescript/src/clj"
               "comp/clojurescript/src/cljs"]}})

where comp is a folder which has a symlink to clojurescript inside of it

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

I consolidated this information on this wiki page: https://github.com/emezeske/lein-cljsbuild/wiki/Using-a-Git-Checkout-of-the-ClojureScript-Compiler .

I'm closing the issue now; feel free to add anything I missed to the wiki.

from lein-cljsbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.