Fork me on GitHub
#shadow-cljs
<
2024-01-12
>
Nik05:01:51

Can some please share resource for service-worker setup? I've tried with following build setup

{...
  :builds {:app {:target :browser
                :output-dir "public/js"
                :asset-path "/js"
                :modules {:shared {:entries []}
                          :main {:init-fn testapp.core/main
                                 :depends-on #{:shared}}
                          :service-worker {:init-fn testapp.service-worker/init
                                           :web-worker true
                                           :depends-on #{:shared}}}}}
}
and I'm getting error
main.js:1 Uncaught ReferenceError: SHADOW_ENV is not defined
    at main.js:1:1

thheller07:01:01

in multi module setups like that one you need to load shared.js before main.js in your HTML, so just two script tags instead of one

thheller07:01:15

(which is what defines SHADOW_ENV)

thheller07:01:56

for service workers I think it makes more sense to make that its own build though

thheller07:01:05

so with just the :service-worker module

Nik08:01:03

Okay will try both out. Thanks!

henrik11:01:31

Upon bumping to 2.26.4, there are complaints about a package: pako The error reads:

package export wildcard match referenced a file that doesn't exist
{:rel-require "./lib/deflate", :package-dir #object[java.io.File 0x575218d0 "/node_modules/pako"], :prefix "./lib/", :match "./lib/*"}
The usage is:
(:require ["pako" :as pako])

…

(.deflate pako …)
The lib dir mentioned contains:
deflate.js  inflate.js  utils/      zlib/

thheller09:01:03

works for me? which pako version do you use? I tried 2.1.0?

Stefan09:01:19

Is this the same issue?

#14 40.26 package export wildcard match referenced a file that doesn't exist
#14 40.26 {:rel-require "./cjs/useCommittedRef", :package-dir #object[java.io.File 0x70a6c56b "/repo/node_modules/@restart/hooks"], :prefix "./", :match {"types" "./esm/*.d.ts", "import" "./esm/*.js", "require" "./cjs/*.js"}}
#14 40.26 ExceptionInfo: package export wildcard match referenced a file that doesn't exist
#14 40.26       shadow.build.npm/find-resource-from-exports-by-wildcard/fn--12475 (npm.clj:772)
#14 40.26       clojure.lang.ArraySeq.reduce (ArraySeq.java:114)
#14 40.26       clojure.core/reduce (core.clj:6885)
#14 40.26       clojure.core/reduce (core.clj:6868)
#14 40.26       shadow.build.npm/find-resource-from-exports-by-wildcard (npm.clj:761)
#14 40.26       shadow.build.npm/find-resource-from-exports-by-wildcard (npm.clj:759)
#14 40.26       shadow.build.npm/find-resource-from-exports (npm.clj:789)
#14 40.26       shadow.build.npm/find-resource-from-exports (npm.clj:785)
#14 40.26       shadow.build.npm/find-resource-in-package (npm.clj:803)
#14 40.26       shadow.build.npm/find-resource-in-package (npm.clj:793)
#14 40.26       shadow.build.npm/find-resource (npm.clj:885)
#14 40.26       shadow.build.npm/find-resource (npm.clj:848)
#14 40.26       shadow.build.resolve/find-npm-resource (resolve.clj:123)
#14 40.26       shadow.build.resolve/find-npm-resource (resolve.clj:94)
#14 40.26       shadow.build.resolve/eval13071/fn--13074 (resolve.clj:266)
#14 40.26       clojure.lang.MultiFn.invoke (MultiFn.java:244)
#14 40.26       shadow.build.resolve/find-resource-for-string (resolve.clj:81)
#14 40.26       shadow.build.resolve/find-resource-for-string (resolve.clj:70)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:464)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:447)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:700)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:693)
#14 40.26       shadow.build.resolve/resolve-deps/fn--13020 (resolve.clj:52)
#14 40.26       clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
#14 40.26       clojure.core/reduce (core.clj:6885)
#14 40.26       clojure.core/reduce (core.clj:6868)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:42)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:41)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:50)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:34)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:489)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:447)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:700)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:693)
#14 40.26       shadow.build.resolve/resolve-deps/fn--13020 (resolve.clj:52)
#14 40.26       clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
#14 40.26       clojure.core/reduce (core.clj:6885)
#14 40.26       clojure.core/reduce (core.clj:6868)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:42)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:41)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:50)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:34)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:489)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:447)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:700)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:693)
#14 40.26       shadow.build.resolve/resolve-deps/fn--13020 (resolve.clj:52)
#14 40.26       clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
#14 40.26       clojure.core/reduce (core.clj:6885)
#14 40.26       clojure.core/reduce (core.clj:6868)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:42)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:41)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:50)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:34)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:489)
#14 40.26       shadow.build.resolve/resolve-string-require (resolve.clj:447)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:700)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:693)
#14 40.26       shadow.build.resolve/resolve-deps/fn--13020 (resolve.clj:52)
#14 40.26       clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
#14 40.26       clojure.core/reduce (core.clj:6885)
#14 40.26       clojure.core/reduce (core.clj:6868)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:42)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:41)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:50)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:34)
#14 40.26       shadow.build.resolve/resolve-symbol-require (resolve.clj:687)
#14 40.26       shadow.build.resolve/resolve-symbol-require (resolve.clj:647)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:697)
#14 40.26       shadow.build.resolve/resolve-require (resolve.clj:693)
#14 40.26       shadow.build.resolve/resolve-deps/fn--13020 (resolve.clj:52)
#14 40.26       clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
#14 40.26       clojure.core/reduce (core.clj:6885)
#14 40.26       clojure.core/reduce (core.clj:6868)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:42)
#14 40.26       shadow.cljs.util/reduce-> (util.clj:41)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:50)
#14 40.26       shadow.build.resolve/resolve-deps (resolve.clj:34)
#14 40.26       shadow.build.resolve/resolve-symbol-require (resolve.clj:687)
#14 40.26       shadow.build.resolve/resolve-symbol-require (resolve.clj:647)

henrik09:01:52

@U05224H0W Yes, that’s the version. OK, weird. @UGNFXV1FA Yeah, that looks similar. Any idea what’s causing it?

Stefan10:01:05

No unfortunately not 😞

thheller10:01:40

I think I know. probably the change I did https://github.com/thheller/shadow-cljs/commit/e800cbccbb18588238d868d93c592dd38f21fc97 now locking things down too much

thheller10:01:46

weird that it works for me though

Stefan10:01:15

@U06B8J0AJ The output mentions "/repo/node_modules/@restart/hooks" so I guess it's related to that.

Stefan11:01:53

That one works again, thanks a lot @U05224H0W!

henrik12:01:07

Yes, this one works. But I couldn’t tell you why. Something to do with config perhaps. :output-feature-set :es2018?

thheller12:01:57

no that doesn't affect anything

thheller12:01:14

only option with any effect here would be :js-options {:ignore-exports true}, but since it was complaining about exports that is not an option you had set 😛