Fork me on GitHub
#shadow-cljs
<
2019-02-24
>
bbss06:02:21

I'm having an issue with closure using JavaScript from a worker. I extend a class from an external library, this works for the non :web-worker true. But when importing the class into a worker I get

Uncaught ReferenceError: $jscomp is not defined
Which seems to be part of the closure runtime. Importing the class that I extend into the worker does work. I'm not sure how to fix it, maybe I can include something manually/pass flags to closure to make this work. Any ideas?

thheller08:02:21

I'm not sure I understand what you are doing

thheller08:02:33

you have a build with multiple :modules where one uses :web-worker true?

thheller08:02:01

$jscomp is used by the closure lib for its polyfills

thheller08:02:21

it should be created in the default base module which should be imported by the worker module

thheller08:02:25

so it should be available?

bbss09:02:23

:target :browser
...
:modules    {:shared {:entries []}
                                  :worker-shared {:entries []
                                                  :depends-on #{:shared}}
                                  :app {:entries [app.client]
                                        :depends-on #{:web-shared}}
                                  :filter-worker {:entries [app.filter-worker]
                                                  :depends-on #{:worker-shared}
                                                  :web-worker true}}
I have a .js file that imports a class from the a node_modules lib and extends it. This works when importing that JS file in :app module, but it doesn't work when importing in the :filter-worker.

thheller09:02:24

can you check the shared.js? it should contain /** @const */ var $jscomp = $jscomp || {}; right at the top?

bbss09:02:02

Yes, it does.

thheller09:02:22

and filter-worker.js should contain the importScripts("shared.js") right at the top? + worker-shared.js?

bbss09:02:50

it does not

thheller09:02:03

hmm I think I never built this for a shared worker module

thheller09:02:29

filter-worker.js doesn't contain any importScripts?

thheller09:02:16

oh wait nevermind. importScripts is only for release mode

thheller09:02:25

ah yeah .. that makes sense now

bbss09:02:37

okay, it contains the string but no direct calls afaik

thheller09:02:01

yeah forgot that dev mode workers work differently

thheller09:02:08

and they just don't inject the polyfills correctly

thheller09:02:18

please open an issue. I can fix it later

bbss09:02:26

Okay sure, great!

thheller09:02:27

that should check goog-base and web-worker if you want to try fixing it

thheller09:02:29

I'll be back later

bbss09:02:51

Okay, I'll check it out! Thanks a lot!

bbss09:02:01

Making issue now.

bbss10:02:38

Including :goog-base true in my module seems to have fixed it!

chrisps12:02:20

How can I make shadow-cljs make use of clojure 1.10 ??

chrisps12:02:42

I’ve added that as a dep

chrisps12:02:00

Anything else I need to do?

thheller13:02:23

@chris.schreiner 1.10 should be used by default in recent releases?

chrisps14:02:50

@thheller Yes indeed, I was running an older version of shadow-cljs

mhuebert17:02:19

came across what appears to be an odd compiler renaming bug, https://github.com/thheller/shadow-cljs/issues/447