Fork me on GitHub
#re-frame
<
2024-04-24
>
paul.​legato20:04:26

Hello. I’m new to CLJS and re-frame (but not to Clojure.) My first re-frame-template project was going well, until I quit the shadow-cljs REPL within Emacs. When I restart it (using M-x cider-jack-in-cljs), it appears to start up normally within Emacs, but the browser has a red banner that says Stale output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running? and indeed no changes I make in the source files appear in the browser. Anyone know what might be going on?

p-himik20:04:03

That's more of a question for #C6N245JGG. Have you tried refreshing the tab?

paul.​legato20:04:18

Yes, including empty cache / hard reload

p-himik20:04:40

Can you double-check where the files are served from? E.g. if the server serves the contents of target/dev but shadow-cljs puts its output into target/staging, you'll also see such error. Another potential cause is the server caching the files.

paul.​legato20:04:30

I don’t know what you mean by “the server” — whatever server there is is built into the re-frame-template or shadow-cljs

p-himik20:04:01

What is re-frame-template?

paul.​legato20:04:30

A scaffolding for making new re-frame projects, https://github.com/day8/re-frame-template/

p-himik20:04:18

Also, when you restarted the REPL, did you see any messages about busy ports?

paul.​legato20:04:40

No busy ports message, no. There were no warnings or errors

paul.​legato21:04:15

It appears that running npm run watch on the command line (in addition to cider-jack-in-cljs) makes it work…. I don’t recall having to do that as a seperate step the first time, but maybe I forgot.

paul.​legato21:04:11

The repl does not seem to have the usual js namespace (e.g. (js/alert "foo")), so it feels like something is still not working right…

p-himik21:04:18

I don't know how CIDER works and what it does during cider-jack-in-cljs, but shadow-cljs itself has a server. Not an HTTP server (that one it also has), but a server per project. That server process is the thing that actually does all the work. Most of the other commands, unless a specific flag is set, will use that server process. And if it's not started, such a command will start and own it. Maybe the cider-jack-in-cljs command is not aware of that behavior and somehow screws it up, I dunno. I myself always run shadow-cljs via CLI manually (by using the watch command) and then attach whatever REPL I need to the specified nREPL port. > The repl does not seem to have the usual js namespace A symptom of it being a CLJ REPL instead of a CLJS one.

paul.​legato21:04:32

Thanks for the info.. I’m also asking over in #C6N245JGG in case someone there has more info

paul.​legato21:04:14

Yes, it’s definitely a CLJ REPL (not CLJS)

p-himik21:04:48

It's better to just provide a link to the thread here since we've already started a discussion. No need to proliferate threads and risk people repeating the same things in different places.

paul.​legato21:04:37

OK, I put the link there.

paul.​legato21:04:30

For the benefit of any future searchers: I deleted the project-local shadow-cljs / Cider defaults storage file .dir-locals.el and restarted; it now works as expected, for some reason.

👍 1
vemv22:04:07

FYI - .dir-locals.el isn't a 'defaults storage file' - it's file for user preferences. If they're there, it's because someone thought they were a good idea for the given project (which of course is subject to stop being true at any point)

vemv22:04:36

The template's contents are pretty vanilla

((nil . ((cider-default-cljs-repl . shadow)
         (cider-shadow-cljs-default-options . "app"))))
"app" assumes your shadow build was named app - if it wasn't, that's the bug

paul.​legato22:04:05

User preferences are a form of defaults, are they not?

vemv10:04:30

Yeah my bad, the wording confused me

Kimo10:04:24

Hey @U0AFX5QNN, thanks for letting us know. Are you able to reproduce the issue? I can't, so far. I pushed a small fix to dir-locals.el. I don't think it will fix this, but maybe.

vemv11:04:09

It might - now that file is identical to https://github.com/reducecombine/icd.scroll/blob/master/.dir-locals.el (context - I've maintained a fair bit of this stuff in cider)

Kimo11:04:10

To try the fix: • Clear your maven cache: rm -r ~/.m2/repository/re-frame/lein-template • Make a fresh project: lein new re-frame my-repro +cider • Install packages: npm install • Go to the dir in emacs; M-x find-file my-repro • Accept the variables with ! when prompted • Jack in: M-x cider-jack-in-cljs • If the fix is in place, you shouldn't get any prompts in the minibuffer. It should just print a success message. • Kill the *cider-repl* buffer and try jacking in again?