Skip to content

cljspad/depstrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clojars Project

depstrap

depstrap is a repository of open-source ClojureScript libraries that have been packaged for use in self-hosted environments.

You can use depstrap with the cljs.js bootstrapped compiler and shadow-cljs.

Visit https://deps.cljspad.dev to browse all available libraries.

depstrap is how cljspad resolves its dependencies at runtime.

Usage

Add the following dependency to your project:

[cljspad/depstrap "0.1.0"]

Note: depstrap requires shadow-cljs. This is because it wraps the shadow.cljs.bootstrap.browser API, and repository libraries have been compiled with {:target :bootstrap}. You can read more here

(require '[cljs.js :as cljs.js])
(require '[depstrap.api :as depstrap])

(defn print-result [result]
  (js/console.log result))

(defonce compiler-state (cljs.js/empty-state))

(defn eval-opts
  [compiler-state]
  {:eval cljs.js/js-eval
   :load (partial depstrap/load compiler-state)})

(defn eval-ratom []
  (cljs.js/eval-str
    compiler-state
    "(reagent.core/atom 1)"
    "[test]"
    (eval-opts compiler-state)
    print-result))

(def init-opts
  {:depstrap/dependencies '[[reagent "1.0.0-alpha2"]]
   :load-on-init          #{'reagent.core}})

(depstrap/init compiler-state init-opts eval-ratom)

Configuration options

The second argument to depstrap.api/init is an options map:

  • :load-on-init - a set of namespaces to load on initialization
  • :depstrap/dependencies - a collection of dependencies to load
  • :depstrap/repository - the repository URL that resolves the dependencies (default: https://deps.cljspad.dev)

Contributing

If you would like to submit a library to the depstrap repository, please create an EDN definition in repository/ like:

{:package [reagent "1.0.0-alpha2"]
 :entries [reagent.dom reagent.core]}