Fork me on GitHub
#cherry
<
2023-10-04
>
wcohen01:10:32

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

wcohen01:10:21

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

wcohen02:10:24

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.

wcohen02:10:15

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

borkdude09:10:14

yes, it should work, but let me double check

borkdude09:10:34

ah yes, a bug, let me fix that

borkdude09:10:46

Fixed in 0.1.9

wcohen21:10:29

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?

borkdude21:10:17

I'm not sure what you're referring to

wcohen21:10:09

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?

wcohen21:10:38

lovely, thank you

wcohen14:10:08

to work on generative testing, would you suggest just having a dev dependency on fast-check and doing it via js?

wcohen14:10:22

(i assume test.check is out since spec is out)

borkdude15:10:45

unless we can get test.check to compile with cherry, which I think won't work yet