当运行此示例时
https://github.com/kommen/clojurescript-webworker-demo
使用 ClojureScript 版本 1.10.738 及更高版本时,我在 Web 控制台中收到此错误消息
ReferenceError: document is not defined dom.js:2499:3
DomHelper https://127.0.0.1:7777/out/goog/dom/dom.js:2499
getDomHelper https://127.0.0.1:7777/out/goog/dom/dom.js:87
CrossPageChannel https://127.0.0.1:7777/out/goog/net/xpc/crosspagechannel.js:94
cljs$core$IFn$_invoke$arity$1 https://127.0.0.1:7777/out/clojure/browser/net.js:575
clojure$browser$net$xpc_connection https://127.0.0.1:7777/out/clojure/browser/net.js:555
clojure$browser$repl$connect https://127.0.0.1:7777/out/clojure/browser/repl.js:347
<anonymous> https://127.0.0.1:7777/out/clojure/browser/repl/preload.js:7
CLOSURE_IMPORT_SCRIPT https://127.0.0.1:7777/mywebworker.js:3
load https://127.0.0.1:7777/out/goog/base.js:3406
loadDeps_ https://127.0.0.1:7777/out/goog/base.js:3043
loadDeps_ https://127.0.0.1:7777/out/goog/base.js:3047
load_ https://127.0.0.1:7777/out/goog/base.js:2942
require https://127.0.0.1:7777/out/goog/base.js:905
<anonymous> https://127.0.0.1:7777/mywebworker.js:7
使用版本 1.10.597 时,信息“hello from the web worker!”仍然能正确打印。
有没有简单的方法让新版本在 webworkers 中工作,或者现在最好继续使用旧版本?