Fork me on GitHub
#shadow-cljs
<
2020-06-12
>
thheller07:06:18

@darwin you are the chrome extension expert: do you know if there is any way for a chrome devtools extension to talk directly to workers? I mean eval code in a running worker? I can only find things to eval in page?

tony.kay13:06:15

@thheller I’m using latest shadow…it messed with my package.json…why?

tony.kay13:06:34

as in: it did a thing that very likely broke my program

dpsutton13:06:46

“It did a thing”

tony.kay13:06:48

@dpsutton you really think “changed package.json” isn’t enough of a description?

tony.kay13:06:01

given the delicate nature of the madness that is npm

dpsutton13:06:16

Did it add a dep? Reorder them? Put white space? Remove entries? Chop half the file? Rot 13 it? Just wondering what it did.

tony.kay13:06:53

running: yarn add --exact @js-joda/[email protected]

tony.kay13:06:17

I spent some hours getting js-joda working right, and I don’t feel very good about my versions being messed with. I don’t know that this broke something, but it gives me a strong sinking feeling (I now have to go test things to see what might have broken), and is not what I want my build tools doing to me.

tony.kay13:06:03

Esp at 6am before coffee 😜

Andy Heywood13:06:56

what’s the diff of your package.json?

Andy Heywood13:06:23

like, it was in state (a), you ran a shadow-cljs cmd, now it’s in state (b) - what’s the difference between a and b, and what command did you run?

Derek13:06:49

I’d assume a cljs dependency you’re using has a deps.cljs file

thheller14:06:03

@tony.kay it will only install dependencies if they aren't already in your package.json but are declared in a deps.cljs in some library you use

thheller14:06:33

but there seems to be a caching problem with npm deps I haven't yet figured out https://github.com/thheller/shadow-cljs/issues/727

thheller14:06:56

but shadow-cljs will not modify your package.json if the deps are already in there ... you can also set :npm-deps {:install false} in the top level of shadow-cljs.edn. then it won't even do that.

tony.kay14:06:35

ah, ok. Good to know there’s a toggle. I figured you had thought it through…just a little jarring.

thheller14:06:26

what is exactly? I mean the JS dep seems to be required right? do you want to install it yourself and have your app break?

tony.kay14:06:47

in this case js-joda is moving from non-scoped to scoped names

tony.kay14:06:58

and the whole mess seems a bit fragile

tony.kay14:06:15

so if someone declares the scoped one and I am using unscoped, it gets scary

thheller14:06:55

sure I get that ... but I also don't see how shadow-cljs is at fault here? 😛

tony.kay14:06:01

now that I think of it, I upgrade shadow at the same time as some other libs…so it was certainly one of those libs that did it to me 😛

tony.kay14:06:26

it’s early…I thought perhaps your new inspect tool wanted something in package.json or something

thheller14:06:09

don't you have your package.json in git? I mean what exactly happened should be easy to tell no?

tony.kay14:06:15

but it was the first time I saw it auto-change packge.json as well

thheller14:06:25

inspect doesn't have any JS deps

tony.kay14:06:41

it changed js-joda from unscoped to scoped and bumped the version

thheller14:06:09

It certainly won't change. It may add.

tony.kay14:06:28

oh wait…actually, I think you’re right…I think I ended up with both

tony.kay14:06:40

which was even a bit more scary, since this is js-land

thheller14:06:10

well that wouldn't be any different in JVM land either if you add a dep under a different name

tony.kay14:06:43

well, but in js-land I don’t trust that package authors keep things out of the global space…so then I’m not sure what I have

tony.kay14:06:34

like I said: not sure that anything broke, but just so very tired of the js ecosystem’s fragility

thheller14:06:42

well its actually not that common that things end up in global somewhere but you may be passing non-scoped things to other things that expect the new scoped things

thheller14:06:05

so that would be a problem but the origin seems to be in some other dep you bumped as well as shadow 😛

tony.kay14:06:35

yeah, like I said, it was just a combo of that (changed versions on mulitple things at once), and it being the first time I’d noticed shadow changing my package.json

tony.kay14:06:31

well, and it being 6am after getting woken up at 3am 😕

thheller14:06:01

yeah, but the behavior is safe IMHO. add the dep only if it is not already listed, otherwise leave it alone.

thheller14:06:19

but yeah I'm not a fan of :npm-deps in deps.cljs at all ... but also have no better ideas 😛

tony.kay14:06:28

Cool. js-joda has add-ons (like locales) that seem to plug into the base, so changing from non-scoped to scoped seems like potential breakage.

thheller14:06:30

maybe just a build error would be safer

tony.kay14:06:58

having both seems insane

tony.kay14:06:24

and the whole js-joda thing seems in flux…like not everything is ported yet

tony.kay14:06:39

but yeah, in the past I’ve been perfectly happy with a build error like “react-dom” not found. Is it in your package.json? That’s what shadow used to do, right?

thheller14:06:46

the :npm-deps behavior is reaaally old. it always worked like that. the only thing I added recently is the ability to turn it off.

tony.kay14:06:21

it was added during that SoC thing, right? I think Antonio was involved as well?

tony.kay14:06:09

I thought you had to turn it on…didn’t realize it had been on all this time. esp since I’ve seen any number of compiler errors about things missing from package.json over the years

thheller14:06:19

3 years ago .. so really not that new 😛

tony.kay14:06:33

Love it: “[WIP] :npm-deps, still not a fan”

thheller14:06:42

no this case of :npm-deps has nothing to do with the :npm-deps in CLJS

thheller14:06:13

its just about installing deps nothing more

thheller14:06:55

otherwise libs can't declare their npm dependencies anywhere

thheller14:06:28

its also how it works in CLJS normally nowadays. it just used to do a bit more.

tony.kay14:06:58

ah, for someone that helped you with the book and has been maintaining cljc libs for 5 years…you’d think I’d have caught up on this one 😄 So, the deps.cljs was your invention, and now adopted in regular Clojurescript? That was never clear to me. I just remember trying that early mess in stock cljs builds where it tried to do the backflips with npm.

thheller14:06:20

not my invention no

tony.kay14:06:32

that was so horrible that I just glazed over any time I see :npm-deps

thheller14:06:52

just used to do more than one thing in regular CLJS. In shadow-cljs it only ever had one function.

tony.kay14:06:46

I see…thanks for catching me up. I’ve been avoiding this topic ever since I tried to get that mess to work 4-5 yrs ago (before I discovered shadow). Been happy with the “manually manage package.json, and fix it when shadow tells me to”

thheller14:06:27

yeah I guess its not nice to sneakily install new dependencies like this

tony.kay14:06:07

I’m not a huge fan of convenience that can bust my stuff 😄

tony.kay14:06:56

but opt-out is fine

Wilson Velez14:06:08

can I use the same code base for two targets? :browser and react-native? or they are two completely different worlds?

David Pham16:06:26

Can webworkers connect to shadow CLJS dev server on 9630? So that we can tap> with them as well?

thheller16:06:18

@neo2551 they should already do that yes.

thheller16:06:07

@wvelezva thats fine yes. depends on how you want to organize the code I guess. I know some people prefer to keep it in one project and others prefer to split.

David Pham16:06:09

Cool! It makes it easier to use them haha. I wonxer if we could even hook re-frame-10x to them.