Fork me on GitHub
#shadow-cljs
<
2023-03-09
>
henrik13:03:50

Small regression in the latest version: The inspector doesn’t remember browser/pprint/edn selection for taps.

thheller20:03:13

what do you mean remember?

henrik07:03:46

@U05224H0W So, previously if you switched the inspector to pprint, for example, it would remain on pprint when using tap>, until you switched it to something else. It also remained on pprint between page refreshes. This does not seem to be the case with the new UI. Now it switches back to browser for every new tap>.

henrik07:03:57

When you want to quickly iterate over something, it’s a cumbersome to switch to the appropriate view for each evaluation you do.

henrik07:03:12

Actually, looking into it, it was never a feature.

henrik07:03:20

It might just be that this has broken/changed: https://github.com/thheller/shadow-cljs/issues/809

thheller07:03:54

so the preferred thing just doesn't work anymore?

henrik07:03:57

I had just set it to pprint and forgotten about it.

henrik07:03:59

It seems so!

thheller07:03:10

let me check 😛

🙏 2
henrik07:03:36

Looking at the comment that you want a better way to do it, you could just store the last option used in a cookie or localStorage. localStorage.setItem('myCat', 'Tom'); const cat = localStorage.getItem('myCat');

henrik07:03:01

So,

(.setItem js/localStorage "shadow-cljs.inspector.view-mode" "browser")
(println (.getItem js/localStorage "shadow-cljs.inspector.view-mode"))

thheller07:03:08

I don't like local storage, local file seems like a better solution

thheller07:03:33

but yeah there should be an option to contorl this from the UI directly

thheller07:03:42

just not in the mood to do UI coding currently 😛

👍 2
henrik07:03:11

I don’t think anyone does, but at the same time indexeddb is overkill.

thheller07:03:35

thats not the point. there is just no convenient way to set local storage

thheller07:03:46

a file anyone can edit. telling something to open the console and setting it that way sucks

thheller07:03:15

especially if you run multiple projects and local storage works on 9630 but then has to be set again at 9631

henrik07:03:24

Yeah, fair enough. If you randomize the host or change it frequently, you’ll run into trouble. That’s true of cookies as well.

thheller07:03:54

fwiw this is the problem

henrik07:03:07

To be fair, no one would be asked to edit localStorage/indexeddb/cookies directly. You’d do that via the UI by clicking the option. Additionally, the option not being portable between hosts is a lesser hurdle than the option not being remembered under any circumstance.

thheller07:03:23

let me think about how to make this cleaner for a bit

thheller08:03:44

2.22.2 has a UI settings drawer on the right. went with localstorage for now

henrik13:03:58

Thanks @U05224H0W, that’s really useful!

BorisKourt13:03:29

I am trying to separate a shadow + lein project (with :lein true ). One of the things that it did was reference an app.cljs in a prod folder for production and a different app.cljs in a dev folder for development. These configured some key startup differences between release and dev. I see that shadow-cljs frowns upon different source-paths for different build types. What is current best practice of implementing the different startup logic between release and dev.

thheller14:03:56

what is different about them?

BorisKourt14:03:46

There are some decisions that luminus made like:

(extend-protocol IPrintWithWriter
  js/Symbol
  (-pr-writer [sym writer _]
    (-write writer (str "\"" (.toString sym) "\""))))

(set! s/*explain-out* expound/printer)

(enable-console-print!)

(core/init!)

BorisKourt14:03:18

And a minor configuration detail different between dev and prod

BorisKourt14:03:37

;;ignore println statements in prod
(set! *print-fn* (fn [& _]))

(core/init!)

BorisKourt14:03:56

Also avoiding including expound

thheller14:03:33

ok, create a namespace

thheller14:03:45

load it via :preloads []

thheller14:03:09

never call core/init! yourself, instead in the build config use :init-fn your.app.core/init!

thheller14:03:26

(enable-console-print!) is never required

thheller14:03:35

so only

(extend-protocol IPrintWithWriter
  js/Symbol
  (-pr-writer [sym writer _]
    (-write writer (str "\"" (.toString sym) "\""))))

(set! s/*explain-out* expound/printer)
basically

thheller14:03:45

in the dev preload

BorisKourt14:03:21

That makes a lot of sense. Thank you for the clear overview.

BorisKourt14:03:42

Its a bit of an older codebase at this point not sure what was the whole idea 🙂

thheller14:03:44

(when ^boolean js/goog.DEBUG (set! *print-fn* (fn [])) in the init fn if you must

thheller14:03:14

but I generally recommend not messing with print-fn yourself

BorisKourt14:03:02

At some point I also switched everything to timbre, so I guess this part was actually already handled via that configuration.

BorisKourt14:03:40

thanks again!

scarytom21:03:40

Getting this error in the browser console when loading my app locally (shadow-cljs watch) since upgrading from shadow-cljs 2.21.0 -> 2.22.0:

TypeError: Cannot read properties of undefined (reading 'setDecoratorByClassName')
    at eval (control.js:106:54)
    at eval (<anonymous>)
    at goog.globalEval (app.js:430:11)
    at env.evalLoad (app.js:1387:12)
    at app.js:1656:12
ring any bells?

thheller21:03:35

could be another closure-library issue? what is control.js?

scarytom21:03:53

looks to be part of GCL itself

thheller21:03:35

yes, but which part of it are you using? 😛

scarytom21:03:41

nothing that I'm aware of; I don't think we use it directly.

thheller21:03:05

so what is app.js?

scarytom21:03:22

that's our app bundle

thheller21:03:46

which browser is this? why are there no source maps?

scarytom21:03:50

SHADOW_ENV.evalLoad("goog.ui.control.js", true, "goog.provide(\x22goog.ui.Control\x22); ...

thheller21:03:06

yikes you are using goog.ui? 😛

thheller21:03:16

hmm why do you not get the proper source maps?

thheller21:03:21

these are supposed to have source maps

scarytom21:03:40

I didn't think we were using goog.ui I don't know why we aren't getting proper source maps

thheller21:03:06

well something must be using it. create a build report and check what is importing it

thheller21:03:39

mouse over the goog.ui namespace, the hover will show you what required it

thheller21:03:06

or just go back to the older closure library version

scarytom21:03:36

generated a report, and goog.ui is nowhere in it 😕

thheller21:03:18

any preloads that might be using it? probably a dev only thing then

scarytom21:03:04

ha! I was thinking exactly the same thing. Turns out to be that. re-frame-10x is the culprit

thheller21:03:22

hmm but whats written in re-frame/reagent/react? why would it use goog.ui?

thheller21:03:24

hmm that is a lot of goog.ui

thheller21:03:15

too tired to look into that now. guess I might downgrade the closure lib again if its such a prominent lib failing

thheller21:03:24

I'll see if I can check it out over the weekend

p-himik23:03:34

It's a bit weird. goog/ui/control.js has these lines, among others:

[...]
goog.require('goog.ui.registry');
[...]
goog.ui.Control.registerDecorator = goog.ui.registry.setDecoratorByClassName;
[...]
But for some reason, the goog.ui object doesn't have a registry key when we get to that line. As if that goog.require doesn't work.

thheller06:03:07

that is odd indeed. will investigate later

scarytom21:03:21

I don't think you should necessarily jump to action here. I believe re-frame-10x has very likely fallen a long way behind, and isn't representative.

hifumi12321:03:28

I agree. re-frame-10x hasnt seen releases in a long time and has a fairly large backlog of bugs. It's also the first CLJS library I've seen making use of goog.ui 😁

scarytom21:03:54

Maybe it is time we switched from re-frame-10x to re-frisk?

p-himik23:03:16

I've tried using re-frisk maybe... 5 years ago? Didn't look like much. Your comment made me look again. And wow, it's definitely something worth checking out now.

scarytom23:03:41

yeah, seems to be much more actively maintained

p-himik12:03:59

Although IMO one should use its "remote" version: https://github.com/flexsurfer/re-frisk/issues/78

p-himik09:03:28

Hmm, or not - with lots of data, it just hangs the whole web page because it serializes the data on every change. Oh, same happens with the embedded version... Damn, completely unusable in my case then. :(

scarytom12:03:47

well, the re-frame-10x issue is resolved now

👍 2
jaide23:03:07

Any examples of using a build-hook to prepend // @ts-nocheck to some of the js files it outputs?