Clojure Build Tools - Leiningen, Boot, Shadow CLJS & Figwheel
Since Clojure is hosted, it can tap into ecosystems of other languages. This has led to multiple build tools for different ecosystems. Choosing the right build tool might get tough for a beginner as the pros and cons might not be known. In this module, we'll learn about the general state of build tools in Clojure and choose the right tool for our project.
Get the project source code below, and follow along with the lesson material.
Download Project Source CodeTo set up the project on your local machine, please follow the directions provided in the README.md
file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.
This lesson preview is part of the Tinycanva: Clojure for React Developers course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to Tinycanva: Clojure for React Developers, plus 70+ \newline books, guides and courses with the \newline Pro subscription.
[00:00 - 00:16] Closure gives you the power to tap into existing ecosystems, but to wield that power, we need a build tool. There are many build tools available, and we'll walk through the famous ones, understanding their pros and cons.
[00:17 - 00:31] The oldest and probably the most mature is line-in-game, or line-in-shot. It helps you manage dependencies and project-specific tasks similar to NBM scripts.
[00:32 - 00:50] It is particularly suited to JVM dependencies, but can also be modified to work with JavaScript dependencies from the CLJS JS repo. Line-in-game has built-in support to package your app into jar files or JavaScript files, and it can also run a repo for you.
[00:51 - 01:05] The only downside is that line-in-game runs one JVM process for every application. If you have a large project with multiple sub-applications, you'll have to run one JVM instance to run each application.
[01:06 - 01:21] Boot is similar to line and scope, with the added advantage that it only runs one JVM for multiple applications. With Boot, you might have 15 applications running, but only one instance of the JVM will be used.
[01:22 - 01:32] Boot configuration is more verbose than line-in-game, and some people prefer it because of that. The official solution to manage dependencies is DEPS CLI.
[01:33 - 01:44] It is not as mature or as old as boot or line, but it is the recommended way going forward. It is focused on manning JVM dependencies, but can also be used with JavaScript .
[01:45 - 01:57] Unlike line-in-game or boot, DEPS CLI is more of a do-it-yourself solution. DEPS CLI give you the ability to pick your components and mix and match them as you see fit.
[01:58 - 02:11] The CLJ command that we have been using so far is a part of DEPS CLI. Line, boot and DEPS are more focused on the JVM aspect of the closure, but ShadowCLJS is optimized for JavaScript.
[02:12 - 02:22] Shadow lets you seamlessly inter-rop with NPM packages. You can yarn-install any package from NPM as you would in a JavaScript project and import it in your closure code.
[02:23 - 02:47] Just like line, Shadow also helps you package your application and run a repo, and along with that, it also has some JavaScript-specific development tools that help with hot module reloading, code splitting and dynamic imports. There also exists an extension for line called Figwheel that adapts line-in- game for JavaScript development.
[02:48 - 03:02] It introduces features like hot module reloading, code splitting and a few other things to line-in-game. Although there are many build tools to choose from, depending on the runtime you want to target, the basic principles remain the same.
[03:03 - 03:15] If you get a hang of fun build tools, you can easily use all others. On the JVM side, you cannot go wrong with either of the three options, but on JavaScript side, we recommend that you use Shadow.