Fork me on GitHub
#shadow-cljs
<
2024-02-16
>
Russell00:02:40

does anyone know how I can make shadow-cljs emit an unprefixed global variable declaration? I want to get js like var Module = {...} but I can't seem to figure out the right way to do it. The context for this is that I want to write a worker that interacts with an Emscripten-compiled wasm/js module. The idea is to declare Module before I importScripts the emscripten js in the worker.

thheller06:02:04

what is emscripten js?

thheller06:02:42

you can do (unchecked-set js/goog.global "Module" whatever-module-is-supposed-to-be)

thheller06:02:07

that effectively creates a global variable

thheller06:02:36

or (set! js/globalThis -Module whatever-module-is) when in a modern browser ESM context

Ryan19:02:22

Is there an easy way to clear js console on hot reload, specifically in Chrome?

thheller20:02:12

(defn ^:dev/before-load clear-console! [] (js/console.clear)) somewhere

Ryan20:02:28

perfect, thanks!