clojure-clojurescript-buck icon indicating copy to clipboard operation
clojure-clojurescript-buck copied to clipboard

Set of macroses for Buck build system that allows building Clojure and ClojureScript

Clojure-ClojureScript-Buck

Build Status

Clojure and ClojureScript support for Buck build system. If you have Clojure/ClojureScript and monorepo then it's a thing to check

Features

  • Build Clojure/ClojureScript
  • Run tests for Clojure and choose what test runner to use with ClojureScript: doo or Planck!
  • Build and test any Clojure/ClojureScript with always the same command: buck build [module-name] && buck test [module-name]-test
  • Run REPL into the module without too much thinking about details: buck run [module-name]-repl
  • All the features from Buck build system - it's a peace of cake!

What problems does it solve

  • It allows you to use Clojure/ClojureScript inside a monorepo where different projects may depends on each other
  • With project based approach where you have one Leningen/Boot project per application/library it's sometimes difficult to reuse some part of the code between projects. Buck instead encourages you to create many small independent modules with their own dependencies/source/tests which will improve your code reuse
  • Buck allows to abstract build/test steps into functions that can be used later on across your repo

Installation and requirements

Currently only MacOS is supported. Linux/Windows support is covered in this issue 18

  • Put content of this repo to the right place in your monorepo
  • Rename clj-cljs-config/BUCK.example to clj-cljs-config/BUCK to make it processable by Buck
  • Change .buckconfig so that it will include your config file by default:
[buildfile]
  includes = //path/to-config/clj-cljs-config/config.py

Once it's done check clj-cljs-config/config.py - most likely you gonna need to change paths. Feel free to add any additional build logic there

Configuration

Idea it that clj_cljs_module is low level function and it's used always via some wrapper functions like in RULES/clj-cljs-config/config.py where you can specify custom project files, default dependencies (Clojure/ClojureScript versions), different builders or testers

How does it work

Under the hood we simply create Leiningen project and put files and parameters in the right place.

Entry point would be your custom wrapper with supplied project file on top of clj_cljs_module function in lib.py, which in turn will save all supplied parameters to info file which then would be executed by builder. For now only Planck based builder.cljs is available.

builder then:

  • Create a normal folder structure (with source files placed in a right sub-folder, etc.)
  • Collect all sub-dependencies
  • Create entry point file which requires all the existing module namespaces (including tests) which simplifies REPL and testing
  • Update project file with actual data

Status

Foundation is solid and unlikely that API gonna change in near feature. It's a second big rewrite already so most of the edge cases should be covered. Although it still missing some important things like Figwheel support

Alternatives

  • lein-monolith from Amperity - is a Leiningen plugin to work with multiple projects inside a monorepo. Doesn't require any additional tools but Leiningen, much easier to start with, although it still uses project approach.

  • Ladder developer mentioned on HN that they have their own solution for CLJ/CLJS + Buck which looks awesome but not yet open sourced and includes some hacks in CLJS compiler.

  • make - there are no tasks that you cannot do with make. If you like bare metal - then check version 1.0.0, it was implemented with power of shell,sed,grep and regexps.