nextjournal / clerk

⚡️ Moldable Live Programming for Clojure

Home Page:https://clerk.vision

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Environment setup: requiring cljc source files and possibility of using cljs

abondrn opened this issue · comments

commented

Hello all I'm having some issues with getting my clerk workflow setup and I would appreciate anyone's input on making this happen.

  1. I have my project directory managed with deps.edn. This works perfectly fine when everything (aside from external dependencies) is defined within the notebook itself, but I have not had luck :require'ing source files from elsewhere in the directory. Ideally I would import it just as I would an external dependency or perhaps just use the same namespace and all of the definitions are loaded in, but another possibility might be to define the source files as another notebook directory via :watch-paths and use some clerk-specific mechanism to execute and run. Just want to get unblocked here.

    The specifics of my case don't matter, but for generality let's say I have notebooks and src directories, where the files under src are written using the lib.{name} namespace. What additional configuration, clj commands, or clerk code do I need to execute in order use the code from src in a notebook? Bonus points if where is a demo or example repo that already demonstrates this.

  2. Is it possible to execute notebooks via ClojureScript instead of Clojure? I suspect the answer is no, but if it's a reasonable lift I can certainly help in making this happen.

Thanks!

commented

For those of you following along, turns out I was overthinking 1). Turns out, it mainly arose from the way clerk reports compile errors of upstream requirements, that being silently. You can resolve similar issues by running a checker like clj-kondo prior to spinning up the notebook. General, it might be a good idea to add hooks to check updated files via custom tooling, as default Clojure error messages are pretty opaque anyways.

EDIT: scratch that, I end up having to manually load the src file (by editing and triggering the file watcher) in order for the defs to be exported. Still, that unblocks me.

2) is still unresolved.

Some other suggestions:

  • clerk should support partial rendering. Ideally, it would render after the execution of each cell, or better yet show progress by capturing stdout and having a spinning wheel.

the way clerk reports compile errors of upstream requirements, that being silently.

Clerk should display errors in the browser. If you've been using serve with the file watcher, this might be an actual bug #616, did you happen to use the :show-filter-fn option?

execute notebooks via ClojureScript instead of Clojure?

There's some experiment (#607) in that direction to have clerk/show! evaluate notebooks in the browser via SCI. Is this topic maybe better suited for a discussion?