Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
edited by

When running this example:

https://github.com/kommen/clojurescript-webworker-demo

using ClojureScript release 1.10.738 or newer, I receive this error message in the web console:

ReferenceError: document is not defined dom.js:2499:3
    DomHelper http://localhost:7777/out/goog/dom/dom.js:2499
    getDomHelper http://localhost:7777/out/goog/dom/dom.js:87
    CrossPageChannel http://localhost:7777/out/goog/net/xpc/crosspagechannel.js:94
    cljs$core$IFn$_invoke$arity$1 http://localhost:7777/out/clojure/browser/net.js:575
    clojure$browser$net$xpc_connection http://localhost:7777/out/clojure/browser/net.js:555
    clojure$browser$repl$connect http://localhost:7777/out/clojure/browser/repl.js:347
    <anonymous> http://localhost:7777/out/clojure/browser/repl/preload.js:7
    CLOSURE_IMPORT_SCRIPT http://localhost:7777/mywebworker.js:3
    load http://localhost:7777/out/goog/base.js:3406
    loadDeps_ http://localhost:7777/out/goog/base.js:3043
    loadDeps_ http://localhost:7777/out/goog/base.js:3047
    load_ http://localhost:7777/out/goog/base.js:2942
    require http://localhost:7777/out/goog/base.js:905
    <anonymous> http://localhost:7777/mywebworker.js:7

With release 1.10.597, the message "hello from the web worker!" was still printed correctly.

Is there an easy solution to make the newer release work with webworkers, or is it better to keep using the older release for now?

1 Answer

+1 vote
by

The error you're seeing is due to ClojureScript trying to inject a browser repl into the webworker build. I don't know why or what changed regarding the defaults and the behaviour around the cljs.main commandline options.

However, building the demo with the included build.clj script works also with the newest ClojureScript version 1.10.773.

I have updated the demo repository with the ClojureScript version and also the instructions in the readme.

by
Thank you, it works.
...