Fork me on GitHub
#shadow-cljs
<
2020-11-03
>
nivekuil08:11:08

using a npm package with "main": "dist/index.umd.js" throws some error like Cannot read property 'createGenerator' of undefined , but it works if I use the esm instead. is that expected? can't find any mention of the difference in the user guide

nivekuil08:11:55

also I think that error only happened in dev, not release

nivekuil08:11:05

this package also has a "module": "dist/index.esm.js" in package.json which shadow-cljs seemed to ignore, preferring the umd

thheller09:11:05

@kevin842 it is intentional that it defaults to using main. compatibility is much better since not all packages provide module and mixing has been a nightmare in the past. it can work but it largely depends on the packages you use. can't say much about the createGenerator error without more information. you can make it use module via setting :js-options {:entry-keys ["module" "browser" "main"]} in the build config, the reverse is the default.

nivekuil11:11:00

ah, nice. didn't see :entry-keys mentioned anywhere. I don't know what createGenerator is doing, but I guess you've seen different behavior with umd/esm? JS packaging seems like a real nightmare

thheller12:11:35

yes, js packaging is weird and getting weirder every day almost

😆 3
colinkahn18:11:30

If i’m using :shadow {:main-opts ["-m" "shadow.cljs.devtools.cli"]} in my deps.edn to watch a build, should I get a REPL after navigating to my app? I remember getting this but haven’t seen it in awhile, and have been having issues connecting my editor and figured this was a good place to start.

thheller18:11:00

this never gave you a REPL no

colinkahn18:11:20

OK, I was following the Fireplace instructions via the Guide and when I try doing :CljEval (shadow/repl :my-app) it says shadow isn’t defined

thheller18:11:07

well the actual namespace is (shadow.cljs.devtools.api/repl :my-app)

thheller18:11:18

so wherever you are evaling likely just doesn't have that ns aliased

thheller18:11:56

it is aliased by default if you are in shadow.user but maybe you are just in user

colinkahn18:11:01

Unfortunately using the full namespace actually creates a REPL prompt as the output, but doesn’t connect my editor 😅

thheller18:11:18

sounds like you are maybe connecting to the wrong nrepl server?

thheller18:11:32

or you need to load the shadow-cljs nrepl middleware in the one you are connected to

colinkahn18:11:23

i’m using :nrepl {:port 51468} in my shadow-cljs.edn, so it should be the right one, since I explicitly connect to that port.

colinkahn18:11:41

What’s the nrepl middleware? cider/cider-nrepl?

thheller18:11:38

if you are connecting to the actual shadow-cljs nrepl server you don't need to worry about it. that will definitely have the middleware configured.

colinkahn18:11:55

Any other suggestions for debugging this? Asking another colleague seems like what we used to use for connecting via emacs isn’t working either

thheller18:11:44

I can't help with any cider/emacs related bits

colinkahn18:11:18

The error they’re getting is :missing-nrepl-middleware, so that is something outside shadow?

thheller18:11:38

that means you are definitely NOT connected to the nrepl server shadow-cljs provides

thheller18:11:11

so yeah. either configure the nrepl middleware or connect to the shadow-cljs server

colinkahn18:11:26

confirmed that I can connect using clj -Sdeps '{:deps {nrepl {:mvn/version "0.8.3"}}}' -m nrepl.cmdline --connect --host localhost --port 33333 , upgrade via (shadow/repl :my-app), so yeah, it seems like an nrepl connection issue. Thanks for taking a look, I’ll try to debug from here.