This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-04
Channels
- # announcements (6)
- # babashka (7)
- # beginners (2)
- # biff (5)
- # calva (2)
- # cherry (17)
- # cider (3)
- # clj-kondo (8)
- # clojure (202)
- # clojure-brasil (8)
- # clojure-europe (20)
- # clojure-norway (23)
- # clojure-uk (4)
- # clojuredesign-podcast (5)
- # conjure (1)
- # cursive (9)
- # eastwood (22)
- # events (8)
- # fulcro (3)
- # hyperfiddle (22)
- # introduce-yourself (7)
- # lsp (67)
- # malli (1)
- # matrix (1)
- # meander (6)
- # off-topic (76)
- # pedestal (8)
- # polylith (17)
- # quil (12)
- # re-frame (2)
- # reagent (8)
- # releases (3)
- # shadow-cljs (67)
- # sql (93)
- # squint (39)
- # tools-deps (46)
- # vim (7)
in a cljc file, should it work to say #?(:cljs (:require ["other-cherry-module-as-mjs" :as foo]))
and then be able to call stuff from foo
? i know it works from one normal cherry module to another, but that syntax in a cljc is yielding "ReferenceError: foo is not defined"
when trying the cljc has (js/console.log foo)
at its end to check if everything got included
if it can’t all be crammed into one cljc, i can make a parallel cherry project, but it seemed nice to not have to repeat logic between jvm-land and cherry-land
the reason i’ve got this split into two modules is the following:
• the first cherry module wraps an emscripten-built ES6 module, making cljs/js functions that cleanly interface with both the C functions and emscripten’s memory allocation in JS, and switches between WASM and JS depending on the environment’s capabilities. that cherry module both serves as the base for the second cherry module AND is functional enough to work inside graaljs so that on the JVM, if the native library isn’t available for FFI, it can run the same functions through graaljs using the mjs cherry built
• the second cherry module is the outward-facing NPM module which makes a JS-ecosystem-friendly wrapper
• in an ideal world, the cljc does two things: provides a clj/cljs API which 1) for :clj
chooses between chooses JNA FFI or the cherry-built graaljs module and handles memory allocation and deallocation consistently, or 2) for :cljs
parallels the JVM logic but instead of calling into FFI or graal just uses the first cherry module.
but if cherry can’t read a cljc file, i can just split that last step into a .clj
and .cljs
file which will have similar content
so per https://clojurians.slack.com/archives/C03QZH5PG6M/p1658760775420809, right now the way you still test output on node is to run cherry on a module that includes node:test, then run node on that output?
very fair. you’ve got node_test.cljs
— you run cherry on that, then run node on the .mjs
it spits out, which itself uses the node testing module, which then provides output?