This is the source for the actual NPM library citysdk
. This is a ClojureScript
project and has a few quirks that need to be handled in order to:
The development environment I use(d) to create this library is:
- Intellij IDEA Community Edition (with the Cursive plugin)
- VSCode (with CLJ Kondo and Calva extensions)
- The
shadow-cljs
npmdevDependency
, which serves to transpile the ClojureScript into JavaScript and enables using the JS runtime
The shadow-cljs
build tool is actually much more than that. It's maintained by
a single person and has to do a lot of heavy lifting. Thank you @thheller!
Here are the steps for Development in VSCode:
- Start a REPL server in terminal:
shadow-cljs node-repl
ctrl + shift + p
to pull up the tasks in VSCode- Find:
Calva: Connect to a Running REPL Server in the Project
- Proceed throught the Calva dialogs:
- select a project type:
shadow-cljs
- add port to nREPL:
localhost:3333
- select which build to connect to:
node-repl
- select a project type:
- If in the Utils, make sure to toggle the
comment off for the non
$default
node-fetch
requirement - Go into the file you wish to evaluate and right-click to find:
Load/Evaluate Current file and its Requires/Dependencies
There are some issues to be aware of that need to be understood in order for these steps to succeed in a cross-platform build (currently Node and the Browser using ES Modules)
ES Modules aren't currently supported in native ClojureScript. The Cljs
ecosystem still uses require
(instead of import
), so in order for this
library to play nice in modern ES environments, some compromises were made:
isomorphic-unfetch
uses an older version ofnode-fetch
which uses require.- In ./src/census/utils/core.cljc you'll see
in all caps
FIXME: when bundling for ESM, use the $default version
. This needs to be done before the next step, but during development (when using the REPL), the$default
flag needs to be removed
Before building for npm
, add the $default
flag back to the require statement
for isomorphic-unfetch
Once this is done you can npm run build