Fork me on GitHub
#clojurescript
<
2019-12-20
>
anonimitoraf10:12:55

Im trying to specify a private npm pkg named something like @org/some-pkg in my shadow-cljs.edn but its complaining about the @ character. Ive tried googling but to no avail

thheller10:12:15

@nicdaoraf why would you specify that in shadow-cljs.edn? where?

Eamonn Sullivan10:12:28

["@org/some-pkg" ...]

anonimitoraf10:12:48

oh, inside :dependencies

thheller10:12:00

you don't put js dependencies inside shadow-cljs.edn

thheller10:12:12

they are managed by package.json via npm/yarn

anonimitoraf10:12:59

hmm quoting didnt work, just complained that: Doesnt support "@org/some-pkg"

Eamonn Sullivan10:12:25

Yeah, I misread the question and thought you were just trying to require it.

anonimitoraf10:12:22

i thought id have to go yarn add @org/some-pkg and put it into :dependencies

anonimitoraf10:12:55

I'm looking at https://shadow-cljs.github.io/docs/UsersGuide.html > Example 1. Specify dependencies > {:dependencies [[lib "1.0"]]}

anonimitoraf10:12:02

What dependencies do they mean here?

thheller10:12:08

CLJS dependencies

anonimitoraf10:12:34

oh and those are different from "js" deps?

anonimitoraf10:12:54

> Or a `.jar` file, representing Clojure(Script) or JVM libraries. These are compressed archives containing many files (basically just a `.zip` file). These are added by your `:dependencies`.

anonimitoraf10:12:22

Also, I just realized that you're the author of shadow-cljs 🤯

Cam11:12:07

I've been looking at lighthouse performance on clojurescript apps, well, re-frame in particular. And I was really surprised to see they score pretty low. Is that just a re-frame thing? Reagent perhaps? Any tricks to improving run time performance people know of?

thheller11:12:19

@cam.asoftware did you measure a release build or a development build?

Cam11:12:26

Some deployed apps, so I'd hope they are release builds @thheller

thheller11:12:15

well how large is it? lighthouse really only measures load times and they are horrific unless you used :optimizations :advanced to build it

thheller11:12:04

I don't know .. what are you comparing exactly?

Cam11:12:25

I only ask because I'm seriously fed up with JavaScript. I looked at elm which looks great, but there is some really interesting things about clojurescript

thheller11:12:57

it is pretty easy to get 100/100 in lighthouse with any CLJS if that is your concern

Cam11:12:48

Cool! As long as it's possible, and I understand it's not the only thing to consider, then awesome! Right now I'm trying to figure out what I should use as my toolchain (that makes performance optimisation a possibility if needed) so far I see figwheel, devcards, shadow cljs.... Lol, hard to know where to begin!

Cam11:12:51

And don't start me on editor's.... That's another story. But repl type dev looks very attractive.

Cam11:12:52

I bet the "which toolchain" question gets asked a lot

Cam11:12:08

Although, from what I can tell, devcards is not really about builds.... More of a helper? Not sure

mikethompson11:12:56

@cam To reduce choice, re-frame-template might be a good place to start?

Cam11:12:21

Is that a lein template?

Cam11:12:38

Right, ok cool.

akond12:12:56

does anybody know how to disable process.env when target a browser?

akond12:12:30

apparently, it gets required by cljs

akond12:12:58

i'm using figwheel main

akond12:12:07

yes, it was i shim

p-himik12:12:38

So, you want to exclude a shim? Why?

akond12:12:12

it conflicts with another library

p-himik12:12:39

What library? What do you mean by "conflicts"?

akond12:12:24

the library relies on the fact that browser does not have process

p-himik12:12:38

If (node?) returns false, process won't be used at all.

akond12:12:42

you mean all that time i had nodejs as a target?

p-himik12:12:59

No. The *target* dynamic variable has been removed quite some time ago: https://github.com/clojure/clojurescript/blob/master/changes.md#changes-26

p-himik12:12:31

manifold-cljs needs some TLC to become compatible with the latest CLJS.

akond12:12:47

what is the official way to check for nodejs env?

akond12:12:04

i'll give him a hint

p-himik12:12:02

Actually, I may be wrong - the variable is defined differently, but it's used in the old way. I'll try to check it.

p-himik12:12:41

Yep, it seems to work just fine. Can you print the value of cljs.core/*target* in some code that gets executed?

p-himik12:12:51

Within the problematic project, of course.

akond13:12:42

i get default

p-himik13:12:32

Uhm. OK. At this point, I would start debugging CLJS in the browser. If debugging doesn't work, I would copy the relevant manifold-cljs file to my project files under the correct manifold-cljs namespace, and add a bunch of js/console.log statements in there to see what's going on.

akond13:12:52

i think i found it

p-himik13:12:17

What was it?

p-himik13:12:04

Ah, I see it in the issue tracker.

akond13:12:21

yes. anyway, thank you for your help.

👍 4
vemv14:12:30

Is there such a thing as "boxed math" in js/cljs, in the same performance-harmful way that exists in JVM clj?

lilactown14:12:32

there are tricky things with JS math but it doesn’t manifest as a boxed/unboxed distinction

👍 4
metehan14:12:30

when I deref an atom does it create full copy of the atom I have some big atoms in ref-frame app when I deref them do I cause the app use more ram or is it just a link to an immutable element?

aisamu14:12:06

It's just a link to the value

p-himik14:12:08

N.B.: Only if it's really an atom, and a bunch of other types defined by CLJS. deref just calls the -deref method of the IDeref protocol. In the general case, you cannot guarantee what it will do. E.g. delay computes some function, reagent.ratom/atom notifies some watchers, etc.

👌 4
metehan14:12:25

let [employees @(rf/subscribe employees)
customers @(rf/subscribe customers)]

metehan14:12:48

so when i do this it's just a link to value. i wont cause accidental overheat

p-himik14:12:20

That's a Reagent's reaction. It does a lot of stuff. But if the underlying values didn't change, derefing it will just return a value that has been computed during the previous deref.

p-himik14:12:24

Don't worry about "overheating" anything before you actually see any symptoms. Unless you're sure that something is a problem, that is. Like writing a O(2^n) algorithm where a O(n) would suffice.

parens 4
metehan14:12:48

thank you it's now clear

👍 4
michihuber15:12:19

My app crashes for some people in Chrome because it creates an object called XR. This name was blacklisted for renaming in the Google Closure Compiler 10 months ago, but cljs is using an older version: https://github.com/google/closure-compiler/blame/5c84f3cc92dc5369d50f0398505fa45573be125f/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L227 Is there an easy way to use a newer version of the GCC or is that usually tricky? Or can this setting be configured for cljs builds?

p-himik16:12:47

I think, the latest version of shadow-cljs uses one of the latest GCC releases for compilation.

michihuber19:12:19

meaning this shows that I can exclude gcc from cljs and specify my own version or I should switch to shadow-cljs?

michihuber06:12:01

I tried upgrading to the shadow-cljs version, which didn't work, but a version in between seems to work fine. cheers!

p-himik09:12:02

shadow-cljs does a lot of things to make sure that compilation works. And I would recommend it in general, especially if you want to use libraries from NPM.