Fork me on GitHub

I'm seeing a problem with my release build where the transpiled version of goog.string/format isn't making it into the build


Uncaught TypeError: ne.format is not a function


@mattly it's not by any chance that one needs to require goog.string.format in order to use goog.string, right? (cf. text starting "Sometimes" at:


that would presumably at least cause warnings in development


it seems like it would, yes. there is theory and there is practice though, sometimes 🙂


goog.string/format is an alias to goog.string.format ?


and the compiler that this is the standard library for isn't smart enough to know that?


sorry, my bad -- i can just use the --silent flag to yarn.


@mattly the namespace structure in the closure library isn't very strict so sometimes a singular function is split into a separate "namespace" which actually is just a function. so sometimes it doesn't map cleanly to the CLJS namespacess. goog.string.format is an actual "provided name" which you require via (:require [goog.string.format]) but since it isn't an actual namespace we have to use it via (:require [goog.string.format] [goog.string :as gstr])) (gstr/format ...)

Pavel KlavĂ­k11:10:38

Hi, I am trying to get Hello world Web Worker example working from the guide, but I am getting a mysterious runtime error. My shadow-cljs.edn configuration:

{:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :modules          {:main   {:entries [orgpad.client.core]
                                                     :init-fn orgpad.client.core/init}
                                            :layout {:entries    [orgpad.client.layout.webworker.core]
                                                     :depends-on #{:main}
                                                     :web-worker true}}
                         :compiler-options {:infer-externs :auto}
                         :devtools         {:after-load orgpad.client.core/mount-root
                                            :watch-dir  "resources/public"}}
The code in orgpad.client.core/init:
(let [layout (js/Worker. "/js/compiled/layout.js")]
    (.addEventListener layout "message" (fn [e] (js/console.log "Layout message recieved:" e)))
    (.postMessage layout "Hello World!"))
The Web Worker code:
(ns orgpad.client.layout.webworker.core)

  (fn [^js e]
    (js/postMessage (.-data e))))
The runtime error:
Uncaught ReferenceError: Node is not defined
    at Object.hickory$core$node_type [as node_type] (core.cljs:37)
    at core.cljs:39
    at layout.js:2937
    at Array.forEach (<anonymous>)
    at Object.env.load (layout.js:2933)
    at layout.js:2969
to the line (aget js/Node (str type "_NODE"))) where js/Node is not known. It points to one of my dependencies [hickory "0.7.1"], not used in Web Worker at all.


it is used in the webworker


you use :depends-on #{:main} which means all the code from :main will be loaded in the worker


you should define a :shared module and have :main and :layout depend on that


:modules          {:shared {:entries []}
                   :main   {:init-fn orgpad.client.core/init
                            :depends-on #{:shared}}
                   :layout {:entries    [orgpad.client.layout.webworker.core]
                            :depends-on #{:shared}
                            :web-worker true}}


you can leave :entries empty for shared which means all code used in both :main and :layout will be moved there

Pavel KlavĂ­k11:10:23

Now i get: Uncaught ReferenceError: SHADOW_ENV is not defined at main.js:1


did you load the shared.js?

Pavel KlavĂ­k11:10:29

No, how should I load it?


need 2 script tags in the HTML


make sure shared is loaded before main

Pavel KlavĂ­k11:10:50

it seems to work, thx

đź‘Ť 4
Filipe Silva14:10:26

heya, should shadow-cljs watch test with a config such as

  {:target    :node-test
   :output-to "out/node-tests.js"
   :ns-regexp "-spec$"
   :autorun   true}}}
run the tests on every rebuild?

Filipe Silva14:10:17

I see shadow-cljs compile test building and running the tests, but shadow-cljs watch test only seems to build and rebuild, but not run them


the output may be routed incorrectly if you have a shadow-cljs server (or other watch) running elsewhere

Filipe Silva14:10:09

ah that was it!

Filipe Silva14:10:36

it was a bit unexpected to me, is it a bug or the intended behaviour?


bug I guess. watch runs in a different thread that doesn't capture the *out*/*err* bindings, so it'll use the default of the server

Filipe Silva14:10:48

I could see it going both ways really, depending on what the intended experience is (watch the server console or watch the command console)


it probably shouldn't be using *out* at all


and instead write to the build log directly


which is then routed to out or the UI or whatever


probably should be wherever the build log goes


feel free to open an issue. I'm stuck behind something else so can't fix that right now

Filipe Silva15:10:11

no urgency in this really, but I'll open an issue for it to be recorded

Pavel KlavĂ­k16:10:07

I have set :before-load and :after-load functions to restart the Web worker. It works fine when I do changes in the code outside of Web worker, but it does not reload correcly when I just update WW code. I have even tried to reload it via Shadow-cjls REPL.

Pavel KlavĂ­k16:10:24

Devtools are set as follows:

:devtools         {:after-load  orgpad.client.core/mount-root
                                            :before-load orgpad.client.core/stop-web-workers
                                            :watch-dir   "resources/public"}

Pavel KlavĂ­k16:10:56

it displays the shadow-cljs icon when changing WW code and it detects errors, but no reloading occurs


@pavel.klavik what does the browser console say?


@pavel.klavik do you maybe have the console filtering too much? it should be showing something?

Pavel KlavĂ­k20:10:31

no filtering, normally it displays shadow-cljs: load JS ..... shadow.cljs.devtools.client.browser.js:48 shadow-cljs: call orgpad.client.core/mount-root

Pavel KlavĂ­k20:10:58

I will take a look at the link but I am not likely doing anything strange

Pavel KlavĂ­k20:10:14

This is the full shadow-cljs.edn:

{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]
                [reagent-utils "0.3.3"]
                [re-frame "0.10.6"]
                [ "0.1.6"]
                [hickory "0.7.1"]
                [binaryage/devtools "0.9.10"]
                [bidi "2.1.5"]
                [com.taoensso/sente "1.14.0-RC2"]
                [venantius/accountant "0.2.4"]
                [com.cemerick/url "0.1.1"]]
 :nrepl        {:port 9000}
 :builds       {:client {:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :modules          {:shared {:entries []}
                                            :main   {:init-fn    orgpad.client.core/init
                                                     :depends-on #{:shared}}
                                            :layout {:entries    [orgpad.client.layout.webworker.core]
                                                     :depends-on #{:shared}
                                                     :web-worker true}}
                         :compiler-options {:infer-externs :auto}
                         :devtools         {:after-load  orgpad.client.core/mount-root
                                            :before-load orgpad.client.core/stop-web-workers
                                            :watch-dir   "resources/public"}}}}


yeah looks fine


any warnings? warnings would prevent a reload ... but would also log something

Pavel KlavĂ­k20:10:28

isn't the problem that the Web worker namespaces are not detected as part of the main app, so not reloaded?

Pavel KlavĂ­k20:10:23

the changes are propagated, so if I modify WW and then modify the app code, everything gets reloaded and WW is updated as well


oh right I forgot about the web worker stuff


hmm yeah still haven't found a good strategy for those


Hi, I am trying to include the zenroom npm package that uses a wasm file in shadow-cljs. There’s an example blogpost ( on how to use the library in React, where it’s described to put the .wasm file in the public folder so it’s served on /zenroom.wasm. Also some code needs to be changed so that the javascript wrapper looks for the wasm in that path, and does not try to find it locally. I did the same steps, but I get the error >failed to load zenroom_example.views.js TypeError: “C.then is not a function” This code comes from the wrapper.js:



var _zenroom = _interopRequireDefault(require("../dist/lib/zenroom.js"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var C = (0, _zenroom.default)();
Which loads some file via a relative path. It might be the case that this does not work with shadow-cljs? I had to include the npm packages core-js and regenerator-runtime in the packages.json before I got to this error. I noticed that shadow-cljs minifies all the npm packages and serves it under for example /js/compiled/cljs-runtime/module$node_modules$zenroom$dist$wrapper.js. So just to be sure I also served the wasm under js/compiled/cljs-runtime/zenroom.wasm, but that does not change anything. Is this problem related to the wasm not compiling? Or due to the relative path? I changed the relative path loading to _interopRequireDefault(require("/js/compiled/cljs-runtime/module$node_modules$zenroom$dist$lib$zenroom.js")); but that did not fix hte problem. Can anybody help me include this package with wasm and requires? Full source code is at:


@erwinrooijakkers that repo contains no sources to look at


Oops src was in gitignore for some reason


Removed it 🙂


wasm to resources and changing what was said in the blogpost was enough


you might have more luck if you just include zenroom separately with webpack or so


I'll take a closer look tomorrow if you add the sources, going to bed now


It works now so not necessary to look into it. Thanks for all the support!