Now that we understand the general requirements for hosting FE assets and backend functionality with Pages, let’s figure out how to get that working with Fulcro.

Pages has a long list of supported frameworks, but, perhaps unsurprisingly, none of them are a CLJS framework. Luckily, remembering from the Pages overview post, we can either build the assets ourselves and commit them to our repo, or, possibly, we can specify a custom build command that will build the assets for us as part of the Pages infrastructure.

In this post, we’ll do the following:

  1. Get a barebones Fulcro app that we can build and view locally
  2. Sort out how we can build this via the Pages CI/CD infrastructure.

Barebones Fulcro App

Originally, this section was going to be about creating a barebones app with the Fulcro Template, but after going down that route for a bit I realized that the frontend code relies on having the backend code running, which isn’t what I need or want at the moment.

So instead of that, we’re going to follow the Fulcro book to get the bare minimum frontend code working.

I’ve created the autoflare repo to house the code for this project.

To get this barebones Pages app to work, we need:

  • an index.html file in whatever our build directory is
  • said index file to have the necessary Fulcro things – a div to attach to, and a script tag pointing at the generated js file

Generating the frontend assets

With this commit we’ve got a barebones Fulcro app that we can see locally via npx shadow-cljs server and for which we can generate a JS file via npx shadow-cljs compile :main or, to pass it through the Closure Compiler’s optimizations, npx shadow-cljs release :main.

After experimentation with the Cloudflare Pages build environment, I discovered that it has neither a JDK nor the Clojure binary, the first of which is necessary no matter what, and the second we can skip – if we want to – by defining our dependencies in just the shadow-cljs.edn file.

I’m not exactly sure how that’ll play out with my dev environment, but the docs seem to indicate that it should be fine. The dev process was:

  1. First, move dependency management into the shadow-cljs.edn file
  2. Next, try installing the jdk with apt, first without sudo and then with sudo, though neither of those worked out
  3. Finally, I discovered that the JDK can work just from an archive file, so I downloaded it and (after fixing a typo), got a successful build!

Summary and next steps

So the build environment comes with the necessary versions of NPM/Yarn, we add a JDK via an archive file, and then Shadow CLJS does the rest. If we ever need or want to use deps.edn in our build process, we can likely download a binary for Clojure in much the same way we dl’ed the JDK.

Next up is:

  • Learning about how Functions work
  • Figuring out how to incorporate that into the build process
  • Figuring out how that fits into the dev experience

See you next time!