Fork me on GitHub
#shadow-cljs
<
2023-04-25
>
Shako Farhad05:04:56

Does anyone else have issues with using auto-animate? I can't get to resolve the dependancies no matter how much I try. I followed this guide: https://auto-animate.formkit.com/#usage-react Required it like this: ["@formkit/auto-animate/react" _:refer_ [useAutoAnimate]] and ["@formkit/auto-animate/react$default" _:refer_ [useAutoAnimate]] and many other ways, but always got this error: "The required JS dependency "@formkit/auto-animate/react" is not available," Then I tried to add this to my shadow-cljs.edn directly: _:js-options_ {_:resolve_ {"@formkit/auto-animate/react" {_:target :npm :require_ "@formkit/auto-animate/react/index.d.ts"}}} But that just gave me this error: Errors encountered while trying to parse file /home/dev/src/mono/bec-core-client/node_modules/@formkit/auto-animate/react/index.d.ts {:line 8, :column 7, :message "'async' expected"} By the way, this works: ["@formkit/auto-animate" _:as_ auto-animate] But of course that is not useful by itself. Anyone know how to properly import it with shadow-cljs and npm?

thheller05:04:12

the :resolve part is definitely wrong. .d.ts files are just the typescript type definitions, not the actual source. so they are useless and not supported

Shako Farhad05:04:18

Ok. I didn't know that. When I look at the code there are two kinds of files in the react folder. index.d.ts and index.mjs

thheller05:04:17

it appears the extension only uses mjs files, you can set :js-options {:extensions [".js" ".mjs" ".json"]} in the build config

thheller05:04:41

that might be enough

Shako Farhad06:04:52

Yes that seems to have fixed it! What does it do exactly? It now also accepts .mjs and before it didn't concider those files? IS that it?

Fredrik Andersson20:04:50

I have a node-library target that compiles to functions/index.js. It's a firebase cloud functions project. The compilation works fine but after updating all node packages to latest I suddenly got this error when running the code with the emulator:

SHADOW import error /home/fredrik/src/percap-cljs/.shadow-cljs/builds/functions/dev/out/cljs-runtime/anr.login.functions.js
I can't figure out what is wrong

thheller20:04:25

and what is the rest of the error? that is just telling you what failed to load, why should also be in there somewhere

Fredrik Andersson20:04:41

firebase gives this error:

⬢  functions: Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: TypeError: Cannot read properties of null (reading 'memory')

Fredrik Andersson20:04:56

as a result from the SHADOW error

Fredrik Andersson20:04:40

the why is probably because the

/dev/out/cljs-runtime/anr.login.functions.js
doesn't exist

thheller20:04:41

Cannot read properties of null (reading 'memory') suggests something else

thheller20:04:49

but I don't know what you are doing, so can't suggest much

Fredrik Andersson20:04:14

Let me show you a larger output

Fredrik Andersson20:04:22

From the compiler

shadow-cljs - config: /home/fredrik/src/percap-cljs/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.20.1 running at 
shadow-cljs - nREPL server started on port 42971
shadow-cljs - watching build :admin
shadow-cljs - watching build :functions
[:admin] Configuring build.
[:functions] Configuring build.
[:functions] Compiling ...
[:admin] Compiling ...
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: 
[BABEL] Note: The code generator has deoptimised the styling of /home/fredrik/src/percap-cljs/node_modules/@firebase/firestore/dist/index.esm2017.js as it exceeds the max of 500KB.
[:functions] Build completed. (169 files, 168 compiled, 0 warnings, 5.05s)
[:admin] Build completed. (346 files, 345 compiled, 0 warnings, 15.19s)

Fredrik Andersson20:04:05

Full output from emulator:

> emulators
> firebase emulators:start

i  emulators: Starting emulators: auth, functions, firestore, hosting, pubsub, storage
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database
i  firestore: Firestore Emulator logging to firestore-debug.log
✔  firestore: Firestore Emulator UI websocket is running on 9150.
i  pubsub: Pub/Sub Emulator logging to pubsub-debug.log
i  hosting[admin]: Serving hosting files from: dist/admin
✔  hosting[admin]: Local server: 
i  ui: Emulator UI logging to ui-debug.log
i  functions: Watching "/home/fredrik/src/percap-cljs/functions" for Cloud Functions...
✔  functions: Using node@16 from host.
i  functions: Loaded environment variables from .env.percap-cljs.
SHADOW import error /home/fredrik/src/percap-cljs/.shadow-cljs/builds/functions/dev/out/cljs-runtime/anr.login.functions.js
⬢  functions: Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: TypeError: Cannot read properties of null (reading 'memory')

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at                │
└─────────────────────────────────────────────────────────────┘

┌────────────────┬────────────────┬─────────────────────────────────┐
│ Emulator       │ Host:Port      │ View in Emulator UI             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Authentication │ 127.0.0.1:9099 │       │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Functions      │ 127.0.0.1:5001 │  │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Firestore      │ 127.0.0.1:8080 │  │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Hosting        │ 127.0.0.1:5000 │ n/a                             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Pub/Sub        │ 127.0.0.1:8085 │ n/a                             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Storage        │ 127.0.0.1:9199 │    │
└────────────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at 127.0.0.1:4400
  Other reserved ports: 4500, 9150

Issues? Report them at  and attach the *-debug.log files.

^C
i  emulators: Received SIGINT (Ctrl-C) for the first time. Starting a clean shutdown.
i  emulators: Please wait for a clean shutdown or send the SIGINT (Ctrl-C) signal again to stop right now.
i  emulators: Shutting down emulators.
i  ui: Stopping Emulator UI
⚠  Emulator UI has exited upon receiving signal: SIGINT
i  functions: Stopping Functions Emulator
i  hosting: Stopping Hosting Emulator
i  firestore: Stopping Firestore Emulator
i  pubsub: Stopping Pub/Sub Emulator
i  auth: Stopping Authentication Emulator
i  storage: Stopping Storage Emulator
⚠  Pub/Sub Emulator has exited upon receiving signal: SIGKILL
i  eventarc: Stopping Eventarc Emulator
i  hub: Stopping emulator hub
i  logging: Stopping Logging Emulator

thheller20:04:15

looks like the emulator is hiding the relevant output? don't know anything about that setup, so can't help much

Fredrik Andersson20:04:35

ok, ill see if i can find anything else

thheller20:04:24

does a release build work?

thheller20:04:33

maybe that gives a more useful error

thheller20:04:47

maybe with npx shadow-cljs release functions --pseudo-names

Fredrik Andersson20:04:34

first im going to revert all packages to previous versions and see if that helps

thheller20:04:19

that seems like more work than trying a release build 😉

Fredrik Andersson20:04:44

yeah, but i had already started so I have to finish 😅

Fredrik Andersson20:04:40

now I got a better error

Fredrik Andersson20:04:54

i  functions: Watching "/home/fredrik/src/percap-cljs/functions" for Cloud Functions...
>  SHADOW import error /home/fredrik/src/percap-cljs/.shadow-cljs/builds/functions/dev/out/cljs-runtime/anr.login.functions.js
⚠  TypeError: Cannot read properties of null (reading 'memory')
    at assertRuntimeOptionsValid (/home/fredrik/src/percap-cljs/functions/node_modules/firebase-functions/lib/function-builder.js:43:24)
    at Proxy.runWith (/home/fredrik/src/percap-cljs/functions/node_modules/firebase-functions/lib/function-builder.js:182:9)
    at Function.cljs$core$IFn$_invoke$arity$2 (/home/fredrik/src/percap-cljs/.shadow-cljs/builds/functions/dev/out/cljs-runtime/anr/fire/functions.cljs:19:8)
    at Function.cljs$core$IFn$_invoke$arity$1 (/home/fredrik/src/percap-cljs/.shadow-cljs/builds/functions/dev/out/cljs-runtime/anr/fire/functions.cljs:17:11)
    at /home/fredrik/src/percap-cljs/.shadow-cljs/builds/functions/dev/out/cljs-runtime/anr/login/functions.cljs:51:3
    at global.SHADOW_IMPORT (/home/fredrik/src/percap-cljs/functions/index.js:70:44)
    at /home/fredrik/src/percap-cljs/functions/index.js:1517:1
    at /home/fredrik/src/percap-cljs/functions/index.js:5:26
    at Object.<anonymous> (/home/fredrik/src/percap-cljs/functions/index.js:9:3)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
⚠  We were unable to load your functions code. (see above)

Fredrik Andersson20:04:06

From the compiler

shadow-cljs - config: /home/fredrik/src/percap-cljs/shadow-cljs.edn
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.23.2 running at 
shadow-cljs - nREPL server started on port 37427
shadow-cljs - watching build :functions
[:functions] Configuring build.
[:functions] Compiling ...
[:functions] Build completed. (171 files, 1 compiled, 0 warnings, 1.64s)
Exception in thread "async-dispatch-5" java.io.IOException: UT002002: Channel is closed
	at io.undertow.websockets.core.WebSocketChannel.send(WebSocketChannel.java:343)
	at io.undertow.websockets.core.WebSockets.sendBlockingInternal(WebSockets.java:992)
	at io.undertow.websockets.core.WebSockets.sendBlockingInternal(WebSockets.java:986)
	at io.undertow.websockets.core.WebSockets.sendTextBlocking(WebSockets.java:200)
	at shadow.undertow$fn$reify__17448$fn__17572$state_machine__6615__auto____17611$fn__17614.invoke(undertow.clj:468)
	at shadow.undertow$fn$reify__17448$fn__17572$state_machine__6615__auto____17611.invoke(undertow.clj:468)
	at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:978)
	at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:977)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:982)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980)
	at shadow.undertow$fn$reify__17448$fn__17572.invoke(undertow.clj:468)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.lang.Thread.run(Thread.java:1623)

Fredrik Andersson20:04:45

but i suppose thats just the repl

thheller20:04:10

thats likely the websocket dying because the process getting killed or something yes

thheller20:04:42

so what are you doing in anr.fire.functions line 17?

thheller20:04:57

looks to me like you are passing an invalid argument or so to a firebase thing

Fredrik Andersson20:04:28

(defn https ([fun] (https nil fun)) ([runwith fun] (-> functions (.runWith (clj->js runwith)) region (.-https) (.onRequest fun))))

Fredrik Andersson20:04:46

yes, I am aparently