Is there a way to use NPM packages along with self hosted CLJS?

Hi, I’m doing some experiment to choose the correct plumbing for a new clojurescript project.
My goal is to build a single page web app that:

  • implements a library of functions for building 3d models
  • let the users edit their own clojure code that uses these functions in a textarea
  • compiles the user code on the fly and visualizes the resulting 3d model using three.js

I did various experiments so far. I started with shadow-cljs and all went fine up to the point where I had to use cljs.js/eval, which I wasn’t able to make to work,
I restarted with figwheel.main and it works, but only if I do not use the :target :bundle compiler option. (it works only if I load codemirror and other js packages I need from a tag in index.html)
If the :target is set to :bundle I get an exception as soon I use cljs.js/eval. The exception says “find-ns-obj not supported for target build”.
So, my question:
Is there any other approach I can try to have cljs.js/eval working while still loading packages from npm ?
Thanks for any hints.

For shadow-cljs you need a secondary :bootstrap build which can provide npm dependencies but I don’t know how you’d use them from self-hosted. So they’d work in namespaces you compiled but self-host defined namespaces wouldn’t.

See https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html

Loading npm packages at runtime isn’t supported in any setup though.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.