Comments (18)
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.
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.
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.
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.
@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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
- Custom tagged literals cause build failure HOT 1
- Fails on Java 9? HOT 2
- :asset-path isn't documented HOT 1
- Circular dependencies : Warn user when a namespace requires itself HOT 2
- Adding 'monger' dependency breaks cljsbuild. HOT 2
- Possibility to add cli options to closure compiler. HOT 2
- reload-clojure causes compilation failure in portable projects HOT 4
- Could not write JavaScript nil HOT 1
- Exception (...)/objectutil.js is not a relative path HOT 7
- Consider exposing :watch-fn compiler option? HOT 1
- :prep-tasks dont work when running `lein cljsbuild ...`
- Miraculously disappearing dependencies when using lein cljsbuild auto. HOT 2
- warning-handlers: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn HOT 2
- Duplicate input error HOT 1
- Recompiling compiled app with different optimization type
- Simple example project does not compile HOT 1
- `lein trampoline cljsbuild repl-rhino` fails with jdk 11 HOT 1
- cljsbuild-example-simple didnt run with lein 2.9.5 and Java version > 11 & 15 HOT 1
- cljsbuild cannot find reagent HOT 1
- Fails with ClojureScript newer than 1.10.764 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lein-cljsbuild.