Skip to content

Commit

Permalink
Backwards compatibility with static-app (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
sritchie committed Jun 8, 2023
1 parent 1e0c447 commit aa0f414
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,13 @@

## [unreleased]

- Upgrade Clerk in the project and the template to
## [0.5.1]

- #32 modifies `mentat.clerk-utils.build.shadow` to include
`nextjournal.clerk.static-app` only when available, adding backwards
compatibility in for previous Clerk versions.

- #31 upgrades Clerk in the project and the template to
`"5e875e256a28a6deabf27bd6fc20f44cee5dad20"`, past the sha that removed
`nextjournal.clerk.static-app` in favor of `nextjournal.clerk.sci-env`.

Expand Down
2 changes: 1 addition & 1 deletion build.clj
Expand Up @@ -18,7 +18,7 @@
;; ## Variables

(def lib 'org.mentat/clerk-utils)
(def version "0.5.0")
(def version "0.5.1")
(def pom-deps
{'io.github.nextjournal/clerk
{:mvn/version "0.12.707"
Expand Down
12 changes: 10 additions & 2 deletions src/mentat/clerk_utils/build/shadow.clj
Expand Up @@ -2,6 +2,7 @@
"Utilities for generating custom Clerk viewer CLJS builds via `shadow-cljs`."
(:require [clojure.string]
[clojure.java.shell :refer [sh]]
[clojure.java.io :as io]
[shadow.cljs.devtools.config :as shadow.config]
[shadow.cljs.devtools.server :as shadow.server]
[shadow.cljs.devtools.server.runtime :as runtime]
Expand Down Expand Up @@ -38,15 +39,22 @@
"Location of the generated JS code."
(str output-dir "/main.js"))

(defn clerk-entries
"Returns the sequence of (symbols representing) cljs namespaces required by the
loaded version of Clerk for interactive development and static publication."
[]
(cond-> ['nextjournal.clerk.sci-env]
(io/resource "nextjournal/clerk/static_app.cljs")
(conj 'nextjournal.clerk.static-app)))

(defn clerk-build-config
"Given sequence `cljs-namespaces` of symbols naming ClojureScript namspaces,
returns a `:builds` entry for a `shadow-cljs` build of Clerk's viewer JS.
The resulting build will include all supplied namespaces, plus Clerk's
`nextjournal.clerk.static-app` namespace.`"
[cljs-namespaces]
(let [entries (into ['nextjournal.clerk.sci-env]
cljs-namespaces)]
(let [entries (into (clerk-entries) cljs-namespaces)]
{:build-id build-id
:target :esm
:runtime :browser
Expand Down

0 comments on commit aa0f414

Please sign in to comment.