shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
nivekuil 2020-11-03T08:32:08.252800Z

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

nivekuil 2020-11-03T08:34:55.253Z

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

nivekuil 2020-11-03T08:52:05.253100Z

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

thheller 2020-11-03T09:34:05.255100Z

@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.

nivekuil 2020-11-03T11:07:00.255200Z

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

thheller 2020-11-03T12:57:35.255900Z

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

😆 1
2020-11-03T18:27:30.257600Z

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.

thheller 2020-11-03T18:31:00.257800Z

this never gave you a REPL no

2020-11-03T18:33:20.258900Z

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

thheller 2020-11-03T18:34:07.259700Z

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

thheller 2020-11-03T18:34:18.260Z

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

thheller 2020-11-03T18:34:56.261100Z

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

2020-11-03T18:35:01.261200Z

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

thheller 2020-11-03T18:35:18.261500Z

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

thheller 2020-11-03T18:35:32.261800Z

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

2020-11-03T18:36:23.262400Z

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.

2020-11-03T18:36:41.263Z

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

thheller 2020-11-03T18:37:38.263500Z

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.

2020-11-03T18:38:55.264700Z

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

thheller 2020-11-03T18:39:44.265Z

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

2020-11-03T18:44:18.265800Z

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

thheller 2020-11-03T18:44:38.266200Z

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

thheller 2020-11-03T18:45:11.266700Z

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

2020-11-03T18:54:26.267700Z

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.