cloroutine icon indicating copy to clipboard operation
cloroutine copied to clipboard

Requires ClojureScript dependency on classpath

Open lgrapenthin opened this issue 3 years ago • 4 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

lgrapenthin avatar May 29 '21 09:05 lgrapenthin

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.

leonoel avatar May 31 '21 08:05 leonoel

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.

lgrapenthin avatar May 31 '21 13:05 lgrapenthin

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 :thinking:

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?

kawas44 avatar Mar 10 '24 14:03 kawas44

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?

kawas44 avatar Mar 12 '24 21:03 kawas44

Fixed in 12

leonoel avatar Mar 26 '24 16:03 leonoel