leonoel/cloroutine

Requires ClojureScript dependency on classpath

Closed this issue · 5 comments

impl.cljc requires cljs.analyzer and cljs.env for cljs macros.

To avoid this problem, one approach would be:

  • split up impl.cljc so that it provides an impl_clj and impl_cljs entrypoint namespace
  • require the respective ns using a reader conditional from core.cljc

Keep in mind we need to support :

  • clojure compiler targeting clojure
  • clojure compiler targeting clojurescript
  • clojurescript compiler targeting clojurescript

File extensions and reader conditionals are about the compiler language, but what we want is to conditionally require based on the target language.

https://github.com/cgrand/macrovich can be used as a tool or reference (code is very little) to avoid potential problems, however the clj based cljs compiler only reads clj for macroexpansion, if required by previously read cljs.

Hello,
I would also love to use Missionary and build a standalone uberjar without 20 Mb of Clojurescript/Google cruft.

I have tried macrovich but was not able to make the code usable from clj and cljs at the same time 🤔

I have tried the core.async solution, which is to create a separate namespace. Obviously a big disadvantage is the huge duplication of code. But at least, everything works correctly. You can see my commit on branch split-cljcljs-duplicate.

I have tried to dynamically require Clojurescript dependencies when available to provide a dedicated analyze implementation function. No code duplication but it may be a bit slower (could we use caching?). You can see my commit on branch split-cljcljs-dynamic.

I have tested my two branches with an external simple project and everything seems to work fine.

What do think about those solutions?

Hello @leonoel,

Using the cloroutine branch with dynamic loading and moving missionary clojurescript dependency to the cljs-test alias I was able to run missionary Clj tests and Cljs tests (clojurescript & planck) without errors.

The dynamic loading solution look promising. What do you think?

Fixed in 12