This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-01
Channels
- # announcements (23)
- # babashka (66)
- # babashka-sci-dev (7)
- # beginners (24)
- # biff (2)
- # calva (19)
- # cider (10)
- # clj-kondo (12)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (37)
- # clojure-art (1)
- # clojure-europe (50)
- # clojure-gamedev (1)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-uk (7)
- # clojurescript (6)
- # conjure (28)
- # cursive (19)
- # data-science (11)
- # fulcro (21)
- # holy-lambda (12)
- # honeysql (6)
- # hyperfiddle (2)
- # jobs (1)
- # lsp (5)
- # malli (4)
- # meander (3)
- # missionary (8)
- # nbb (5)
- # off-topic (39)
- # rdf (9)
- # reitit (1)
- # releases (1)
- # sci (21)
- # shadow-cljs (42)
- # specter (1)
- # xtdb (11)
So it looks like the rules around js/SharedArrayBuffer
are starting to settle down. You have to add COOP/COEP headers to your server. So I updated my tau.alpha lib https://gitlab.com/johnmn3/tau and got the old demo working https://simultaneous.netlify.app/ on netlify. The whole lib needs a re-write, and decomposition into smaller libs, one of which is a small lib that can spawn workers programmatically, which reminded me of this response I gave to a question about https://clojureverse.org/t/webworker-as-a-librarys-dependency/8277/3?u=john_newman on Clojureverse.
For tau.alpha, I got it working in both simple and advanced compile mode https://gitlab.com/johnmn3/tau/-/blob/master/src/tau/alpha/util.cljs#L80. For a rewrite though, I'd like build a thing that works in all compile modes, and works for vanilla, figwheel and shadow-cljs build systems. I think leaning into CLJS modules/code splits might be the best way to make a thing that can be used from all different build systems and compile modes.
I wanted to check in here though and see if I could get any pointers. Any gotchas to look out for? Any shortest-paths I haven't considered? Any work desired for addition to CLJS core? On that note, I'm thinking about making a PR to allow vanilla CLJS to take a map of optional headers in the compiler options / build.edn, so you can enable COOP/COEP for enabling development with SABs - in figwheel, I'm using a custom ring.handler. Let me know if anything comes to mind.
Removing all the tau stuff, that spawn fn boils down to:
(defn create-worker-body [require-ns]
(let [multi-loader
(str "CLOSURE_BASE_PATH = '" goog/basePath "';\n"
"this.CLOSURE_IMPORT_SCRIPT = (function(global) {\n"
" return function(src) {\n"
" global['importScripts'](src);\n"
" return true;\n"
" };\n"
"})(this);\n"
"if(typeof goog == 'undefined') importScripts(CLOSURE_BASE_PATH + 'base.js');\n"
"importScripts('" (str goog/basePath "../cljs_deps.js") "');\n"
"goog.require('" require-ns "');\n")
single-loader
(str
"importScripts('" (last (scripts-src)) "');\n")]
(if (empty? goog/basePath) single-loader multi-loader)))
Wondering if there's a better, more resilient way to go about that, perhaps using code-splitting modules, that'll work in both advanced compiled mode and simple (or none), across all build tools.