All Projects → aengelberg → cljsee

aengelberg / cljsee

Licence: EPL-1.0 license
Backporting cljc

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to cljsee

Cljs Lambda
Utilities around deploying Clojurescript functions to AWS Lambda
Stars: ✭ 304 (+1069.23%)
Mutual labels:  leiningen
Vizdeps
Visualize Leiningen dependencies using Graphviz
Stars: ✭ 131 (+403.85%)
Mutual labels:  leiningen
doo-chrome-devprotocol
A runner for doo which runs tests in Chrome, using the Chrome Dev Protocol with no need for karma or npm.
Stars: ✭ 27 (+3.85%)
Mutual labels:  leiningen
Lein template descjop
A Leiningen template(Clojure/ClojureScript Project) for Web based desktop application with Electron (atom-shell).
Stars: ✭ 394 (+1415.38%)
Mutual labels:  leiningen
Lein Plantuml
A Leiningen plugin for generating UML diagrams using PlantUML
Stars: ✭ 43 (+65.38%)
Mutual labels:  leiningen
Antq
Point out your outdated dependencies.
Stars: ✭ 157 (+503.85%)
Mutual labels:  leiningen
asciidoctor-lein-plugin
A Leiningen plugin for generating documentation using Asciidoctor
Stars: ✭ 26 (+0%)
Mutual labels:  leiningen
vim-jack-in
cider-jack-in for vim
Stars: ✭ 42 (+61.54%)
Mutual labels:  leiningen
Lein Jupyter
A Leiningen plugin to integrate clojure with jupyter notebook
Stars: ✭ 97 (+273.08%)
Mutual labels:  leiningen
Lein Native Image
A Leiningen plugin to build GraalVM native images
Stars: ✭ 216 (+730.77%)
Mutual labels:  leiningen
Lein Ring
Ring plugin for Leiningen
Stars: ✭ 485 (+1765.38%)
Mutual labels:  leiningen
Lein Fore Prob
A leiningen plugin to make a local copy of a problem from 4clojure
Stars: ✭ 13 (-50%)
Mutual labels:  leiningen
Reagent Figwheel
Leiningen template for Reagent applications in Clojurescript with Figwheel. Optionally includes secretary, cljs.test, garden, less, cider, devcards, cljs-devtools, re-risk
Stars: ✭ 161 (+519.23%)
Mutual labels:  leiningen
Lein Test Refresh
Refreshes and reruns clojure.tests in your project.
Stars: ✭ 353 (+1257.69%)
Mutual labels:  leiningen
Google-Authenticator
Clojure program to compute your google authenticator OTP using TOTP
Stars: ✭ 23 (-11.54%)
Mutual labels:  leiningen
Radian
🍉 Dotfiles that marry elegance and practicality.
Stars: ✭ 274 (+953.85%)
Mutual labels:  leiningen
Lein Tools Deps
A leiningen plugin that lets you share tools.deps.alpha dependencies in your leiningen project
Stars: ✭ 149 (+473.08%)
Mutual labels:  leiningen
lein-jlink
A lein plugin creates and manages custom java environment
Stars: ✭ 59 (+126.92%)
Mutual labels:  leiningen
lein-jmh
Leiningen plugin for jmh-clojure
Stars: ✭ 17 (-34.62%)
Mutual labels:  leiningen
Jitpack.io
Documentation and issues of https://jitpack.io
Stars: ✭ 2,156 (+8192.31%)
Mutual labels:  leiningen

cljsee

CircleCI

Cljsee is a Leiningen plugin that aims to help library authors to write portable code in the .cljc format that can be used by projects that run Clojure 1.6 or below. It accomplishes this by parsing the cljc conditionals as a compile-time step and producing .clj and .cljs files with only the relevant code.

Cljsee performs a very similar role to the now-deprecated cljx plugin (and I've intentionally modeled cljsee's build configuration after cljx's syntax to make it easy to switch over). But users of cljsee have access to the modern reader conditionals that are official to the Clojure language, including the splicing (#?@(...)) conditional, instead of the #+clj / #+cljs syntax specific to the cljx plugin.

Unlike cljx, cljsee does not include nREPL middleware, because as long as your interactive development is done in Clojure 1.7 or above, reader conditionals will properly load at any REPL.

Usage

In your project.clj, include cljsee as a dependency, then add a cljsee build configuration.

(defproject my-cool-backwards-compatible-project
  ...
  :plugins [[cljsee "0.1.1-SNAPSHOT"]]
  :cljsee {:builds [{:source-paths ["src/"]
                     :output-path "target/classes"
                     :rules :clj}
                    {:source-paths ["src/"]
                     :output-path "target/generated/cljs"
                     :rules :cljs}]})

To compile cljc source code once:

$ lein cljsee once

To start a watcher that automatically cross-compiles when files are changed:

$ lein cljsee auto

It's encouraged to add cljsee as a "prep task" so that your cljc files get backported before critical tasks are performed such as jarring or deploying.

:prep-tasks [["cljsee" "once"]]

Note that even though the cljc format is no longer in the way of Clojure backwards-compatibility, there are other factors (such as missing features or unfixed bugs) to be careful of when supporting older versions of Clojure. To test that your library works on Clojure 1.6.0, for instance, you can add cljsee builds to your test namespaces like so:

:profiles {:old-clojure {:dependencies [[org.clojure/clojure "1.6.0"]]}
           :test {:cljsee {:builds
                           [{:source-paths ["test/cljc"]
                             :output-path "target/classes"
                             :rules :clj}
                            {:source-paths ["test/cljc"]
                             :output-path "target/classes"
                             :rules :cljs}]}}}

To then run your test cases on Clojure 1.6:

$ lein with-profile old-clojure test

Behind the scenes

Given the following cljc file:

;; my/ns.cljc
(ns my.ns
  (:require [my.helper.ns
             #?(:clj :refer
                :cljs :refer-macros)
             [my-macro]])
  #?(:clj (:import my.class)))

The following Clojure source is generated:

;; my/ns.clj
(ns my.ns
  (:require [my.helper.ns
                     :refer
                                   
             [my-macro]])
          (:import my.class) )

The irrelevant code is "whited out" in the target files. This strategy preserves the line-column placement of the remaining code, so if errors arise, you can track them down in your original cljc file.

Credits

Alex Engelberg is the author of cljsee. Issues and pull requests are welcome.

Some functions were copied from Kevin Lynagh's cljx library.

License

Copyright © 2016 Alex Engelberg

Distributed under the Eclipse Public License, the same as Clojure.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].