Fork me on GitHub
#shadow-cljs
<
2023-08-28
>
Chris McCormick08:08:44

Hello, I am trying to use the marked markdown library with a :browser target. Details of things I tried and failures in the thread.

Chris McCormick08:08:14

["marked" :as marked]

[:app] Build failure:
Failed to inspect file
  /home/chrism/dev/yt-transcript.com/node_modules/marked/lib/marked.cjs

Errors encountered while trying to parse file
  /home/chrism/dev/yt-transcript.com/node_modules/marked/lib/marked.cjs
  {:line 2247, :column 17, :message "'identifier' expected"}

Chris McCormick08:08:52

["marked/marked.min.js" :as marked]

package marked had exports, but could not resolve ./marked.min.js
{:package #object[java.io.File 0x3550d766 "/home/chrism/dev/yt-transcript.com/node_modules/marked"], :require-from nil, :rel-require "./marked.min.js"}
ExceptionInfo: package marked had exports, but could not resolve ./marked.min.js
	shadow.build.npm/find-resource-in-package (npm.clj:807)
	shadow.build.npm/find-resource-in-package (npm.clj:793)
	shadow.build.npm/find-resource (npm.clj:923)
	shadow.build.npm/find-resource (npm.clj:847)
	shadow.build.resolve/find-npm-resource (resolve.clj:123)
	shadow.build.resolve/find-npm-resource (resolve.clj:94)
...

thheller08:08:15

is there a stacktrace for the first error?

Chris McCormick08:08:32

No that's all that is printed in the terminal. Is there something I can do to get one?

thheller08:08:50

which shadow-cljs version do you use?

thheller08:08:05

the closure compiler is choking on this line

parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);

thheller08:08:27

but I thought that was supported nowadays, so maybe you are just on an old verison?

Chris McCormick08:08:55

> which shadow-cljs version do you use? "version": "2.25.3"

thheller08:08:32

unfortunately that is often that the relevant info

thheller08:08:39

do you use deps.edn or project.clj?

Chris McCormick08:08:54

["marked/lib/marked.umd.js" :refer [parse]] > JS reload failed Error: Package subpath './lib/marked.umd.js' is not defined by "exports" Is there a way to tell it to ignore "exports"?

thheller08:08:55

npx shadow-cljs info

thheller08:08:14

there is, but umd is not a supported package format

thheller08:08:51

it also uses the same exact syntax, so it would choke the same

👍 2
thheller08:08:42

I guess it isn't supported yet then

👍 2
Chris McCormick08:08:04

If I use ["marked/lib/marked.esm.js" :refer [parse]]`` I get the same error.

Chris McCormick08:08:22

All good I can use a different markdown renderer lib.

thheller08:08:45

they all use the same syntax, so trying different files won't do anything

thheller08:08:36

you could search&replace the file and just replace .# with .

thheller08:08:53

ugly but easily done is one line bash or so 😛

thheller08:08:17

blame JS people for adding breaking syntax stuff all the time

Chris McCormick08:08:20

Ah ok so it's closure not supporting the new syntax. Understood, thanks.

Chris McCormick08:08:42

Yes I do. At night as I fall asleep I whisper curses against their names.

Chris McCormick08:08:37

This was a big issue with Python too - continuously introducing cool new syntax that turns every stack into a giant house of cards every time you upgrade any package by one version.

Chris McCormick08:08:05

Thank you for maintaining shadow-cljs in the midst of this madness.

thheller09:08:01

yeah still work in progress I guess. unfortunately not something I can influence or work around from the shadow-cljs side

Chris McCormick09:08:43

All good thanks for your help.

Chris McCormick09:08:08

I downgraded marked one version and it now imports.

zimablue16:08:04

I could be wrong, but it looks like when I send multiple eval requests through shadow-cljs nrepl quickly, I don't get a [done] message for them, which would violate nrepl spec IIUC, I'm not sure but does that sound right?

zimablue16:08:17

a stack of results, at the bottom I sent (+ 1 1) requests slowy and each returned [done], at the top I sent them quickly and didn't get a [done], it's possible that my code is responsible for this but I don't think so

thheller17:08:42

might be possible yes, I think the assumption was that the client waits for the done before sending the next eval

thheller17:08:05

you can send multiple forms at once and they'll queue correctly

zimablue17:08:25

I tested a bit more and I think it is not necessarily a speed thing always

zimablue17:08:41

Clojure evaluation is sequential by definition atm not parallel right

zimablue17:08:52

But nrepl ops can be parallel

thheller17:08:13

CLJS involves a whole lot of async, so its tough to make things truly sequential

thheller17:08:12

not impossible of course, just didn't bother since waiting for the previous result is usually what you want

zimablue17:08:16

I think sometimes I'm not certain that the reason is but waiting for the done, I thought it was sorted but now I can't see a pattern when "done" is returned and when it isn't

zimablue17:08:39

Sorry that last message was a mess

zimablue17:08:01

I don't think it's happening just when the client doesn't wait for a done, I'm also seeing it when I do want

thheller17:08:07

there is a nrepl-debug tool in shadow-cljs if you want to make sure what actually goes over the wire

zimablue17:08:31

Nice, in the web portal?

thheller17:08:32

npx shadow-cljs --force-spawn run shadow.nrepl-debug 5000 .shadow-cljs/nrepl-port while another shadow-cljs is running

thheller17:08:43

then connect your editor to port 5000

thheller17:08:10

it creates a logfile in target/nrepl-debug thats basically just a dump of all messages

zimablue17:08:49

I ran this: npx shadow-cljs --force-spawn run shadow.nrepl-debug 5000 44475 it created 20 nrepl-20.log.edn files but they all seemed to be empty, it also logged stuff like this: in the terminal output: 3] [java.io.PushbackInputStream read "PushbackInputStream.java" 136] [nrepl.bencode$read_byte invokeStatic "bencode.clj" 87] [nrepl.bencode$read_byte invokePrim "bencode.clj" -1] [nrepl.bencode$read_token invokeStatic "bencode.clj" 239] [nrepl.bencode$read_token invoke "bencode.clj" 237] [nrepl.bencode$read_bencode invokeStatic "bencode.clj" 257] I didn't understand what you meant by connecting my editor to 5000, I tried a browser to localhost:5000 that didn't work

thheller18:08:45

your nrepl client that you usually connect to the shadow-cljs port

zimablue18:08:40

Oh so it's opening another nrepl port there, got you, when I get back I'll connect to that and see what it says

zimablue19:08:44

I got back to connecting to this REPL, but am not sure what I should do with it once I am connected

thheller20:08:23

it is just a proxy that logs all nrepl messages going over the wire

thheller20:08:41

you do whatever else you were doing and get a full log of all messages going between shadow-cljs and your nrepl client

thheller20:08:54

if you want me to debug an nrepl issue I need such a log

thheller20:08:13

it probably is just what you showed above in the screenshot, but I need the full log

zimablue20:08:36

Is the log in the edn, the terminal or the repl output? None seem to be recording events from the (existing) repl in my first process, it just looks like a connection log of (itself)

thheller21:08:10

it only logs what you send over it. it writes everything to the logfile. it doesn't log anything that doesn't go over the connection, so if you are connecting your REPL to the original server then that is not logged.

andrea17:08:12

I hope x-post is ok (let me know if not), but I discovered this channel and it might be more appropriate here Mainly: Is there a way to make anonymous fns already put whatever the context is in the reported fn name for stack traces?

thheller17:08:13

there is no setting to make the compiler do that no

🙏 2
andrea17:08:33

Is that something that might be welcome in? I might attempt the implementation if so

thheller17:08:42

that would need to happen in the clojurescript compiler itself, not something shadow-cljs can easily influence

👍 2
thheller17:08:38

I vaguely remember opening a similar ticket myself and eventually not caring anymore due to source maps

thheller17:08:50

but that was like 10 years ago 😛

Chris McCormick02:08:28

Naming anonymous fns to improve stack trace is a good tip I hadn't thought of, thanks for this!