cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
dnolen 2020-06-04T13:22:17.110Z

@bhauman hrm, I can't reproduce https://clojure.atlassian.net/browse/CLJS-3258 with either master or 773

dnolen 2020-06-04T13:25:41.111900Z

maybe you should add -Srepro to your clj command?

dnolen 2020-06-04T13:40:10.112300Z

I couldn't reproduce this one either https://clojure.atlassian.net/browse/CLJS-3253, I made something minimal no warnings for me

dnolen 2020-06-04T13:41:02.113200Z

both of seem like issues that were fixed sometime ago - like you're not running the version of ClojureScript you think you are - but that may be a bad hunch

dnolen 2020-06-04T13:51:34.114200Z

@dominicm I don't think you added whether this ticket was a regression or not https://clojure.atlassian.net/browse/CLJS-3255?

bhauman 2020-06-04T14:01:58.118Z

@dnolen hmmm thats really strange about https://clojure.atlassian.net/browse/CLJS-3258 , as it was reported to me, and then I reproduced it twice in 773 in two separate builds

bhauman 2020-06-04T14:02:38.119300Z

did you look at the compiler output?

dnolen 2020-06-04T14:02:42.119500Z

yep

dnolen 2020-06-04T14:02:53.119900Z

but you know what it might be cache bug?

dnolen 2020-06-04T14:03:04.120200Z

delete ~/.cljs

dnolen 2020-06-04T14:03:06.120400Z

and try again

bhauman 2020-06-04T14:03:12.120600Z

hmmmmmmm

dnolen 2020-06-04T14:03:42.120800Z

ah yes

dnolen 2020-06-04T14:03:49.121100Z

probably that but please confirm

dnolen 2020-06-04T14:03:56.121500Z

it's because :target will always be :nodejs

dnolen 2020-06-04T14:04:03.121800Z

there's nothing to differentiate

dominicm 2020-06-04T14:06:38.123300Z

@dnolen every version I checked was broken, I got a different error at some point. I think it was arity, but not sure.

dnolen 2020-06-04T14:06:58.123700Z

@dominicm right just not supported ok, going to clarify

dominicm 2020-06-04T14:07:23.124300Z

Fwiw, it works for advanced, but not dev.

bhauman 2020-06-04T14:07:27.124400Z

@dnolen oh dammit

bhauman 2020-06-04T14:08:56.124900Z

yeah it works, and its using the global “React”

dnolen 2020-06-04T14:09:00.125200Z

k

bhauman 2020-06-04T14:09:13.125500Z

so its a cache bug

bhauman 2020-06-04T14:09:57.125800Z

well that’s really go to know

bhauman 2020-06-04T14:10:22.126400Z

I thought I tried :aot-cache false in my testing but oh well

dnolen 2020-06-04T14:10:29.126500Z

@bhauman try master

bhauman 2020-06-04T14:10:38.126800Z

cool will do

bhauman 2020-06-04T14:13:23.127300Z

@dnolen I have to populate the cache with something bad first right?

bhauman 2020-06-04T14:14:00.128200Z

How do I get to that place?

dnolen 2020-06-04T14:14:11.128500Z

no

dnolen 2020-06-04T14:14:12.128700Z

to test

dnolen 2020-06-04T14:14:26.129300Z

just switch between :target :bundle and :target :nodejs

dnolen 2020-06-04T14:14:40.129600Z

it should always work

bhauman 2020-06-04T14:14:50.129900Z

gotcha

dnolen 2020-06-04T14:20:40.130100Z

I mean you can try to run it but it's really not necessary

dnolen 2020-06-04T14:20:42.130400Z

just check the output

bhauman 2020-06-04T14:28:44.131600Z

ok it works

bhauman 2020-06-04T14:29:09.132200Z

actually not

bhauman 2020-06-04T14:29:37.132800Z

the bug occurs when you change from one kind of dep to another

bhauman 2020-06-04T14:30:11.133400Z

I.E. when you are shifting between cljsjs libs to node libs

bhauman 2020-06-04T14:30:30.133700Z

ah that’s hard

bhauman 2020-06-04T14:31:00.134300Z

and it will be common when folks are porting their apps

bhauman 2020-06-04T14:31:33.134900Z

the cached version of reagent will be depending on the global react

bhauman 2020-06-04T14:32:08.135300Z

or vice versa

bhauman 2020-06-04T14:36:57.136100Z

so I can reproduce this by switching the type (cljsjs or node) of dependency for a given library

dnolen 2020-06-04T15:42:09.137400Z

@bhauman master should address this problem - look at the output

dnolen 2020-06-04T15:42:22.137800Z

:nodejs-rt should be in the first line now where it wasn't before

bhauman 2020-06-04T15:42:30.138100Z

I saw that

dnolen 2020-06-04T15:42:48.138600Z

but when you switch everything gets recompiled

dnolen 2020-06-04T15:43:02.139100Z

oh

bhauman 2020-06-04T15:43:07.139400Z

yep

dnolen 2020-06-04T15:43:10.139600Z

but maybe cache-keys lemme check

dnolen 2020-06-04T15:46:30.139900Z

@bhauman nope - it should part of the cache key now

dnolen 2020-06-04T15:46:37.140300Z

so I do not understand what you are saying yet

dnolen 2020-06-04T15:46:56.140900Z

there's no such thing as "cached reagent"

bhauman 2020-06-04T15:46:57.141100Z

OK if I have react installed node modules

dnolen 2020-06-04T15:47:09.141500Z

that's not cached according to all build affecting options

bhauman 2020-06-04T15:47:10.141600Z

and the I remove react from node_modules

bhauman 2020-06-04T15:48:14.142400Z

so this isn’t reflected in the build options

bhauman 2020-06-04T15:48:21.142600Z

I’m not changing build options

bhauman 2020-06-04T15:49:12.143300Z

its affected by the presence or absence of a node_module

bhauman 2020-06-04T15:50:00.144300Z

in one case reagent is compiled referencing a node_module, and in another it is compiled referencing a global React

bhauman 2020-06-04T15:50:30.145200Z

so it gets cached one way or the other

bhauman 2020-06-04T15:50:55.145700Z

even though they both have nodejs-rt false

dnolen 2020-06-04T15:51:42.146500Z

the waters are getting muddied right now by this description, let describe how I think it can actually go wrong.

dnolen 2020-06-04T15:51:55.147Z

here's what I think will happen normally

dnolen 2020-06-04T15:53:11.148800Z

Scenario A: User has built Reagent w/ React CLJSJS w/o :target :bundle

dnolen 2020-06-04T15:53:39.149700Z

1. The switch to :target :bundle (and installed React into node_modules everything will be recompiled everything will be cached on a new path

dnolen 2020-06-04T15:54:13.150300Z

@bhauman ^ do you agree this is a happy path for most people?

bhauman 2020-06-04T15:55:40.151200Z

I’m trying to think of the best way to communicate this

dnolen 2020-06-04T15:55:54.152Z

let's just go w/ what I'm saying

dnolen 2020-06-04T15:56:08.152500Z

is this the happy path - yes or no?

dnolen 2020-06-04T15:56:21.152900Z

then we can describe things that could wrong because of missed steps

bhauman 2020-06-04T15:56:45.153400Z

I think the normal case is that they switch to bundle and build

bhauman 2020-06-04T15:57:06.154300Z

without adding the node_modules

dnolen 2020-06-04T15:57:14.154600Z

I'm just trying to describe a minimal reproducer, let's just ignore all the things that can go wrong

bhauman 2020-06-04T15:57:22.155Z

oh

dnolen 2020-06-04T15:57:25.155100Z

I understand you're interested in the UX but we only need a reproducer

bhauman 2020-06-04T15:57:26.155300Z

cool

dnolen 2020-06-04T15:59:01.156700Z

ok - so the above scenario works

dnolen 2020-06-04T15:59:43.157800Z

2. what happens is that if the user never runs the install step - they will cache something that points to CLJSJS

bhauman 2020-06-04T15:59:47.157900Z

I’m actually having to move a TV, I’ll be back

dnolen 2020-06-04T15:59:54.158100Z

k!

bhauman 2020-06-04T16:31:42.158500Z

@dnolen OK back

bhauman 2020-06-04T16:32:21.159400Z

sorry bout that, ping me when you’re ready 🙂

dnolen 2020-06-04T16:33:46.159700Z

ready

dnolen 2020-06-04T16:33:51.159900Z

do you agree about 2. ?

bhauman 2020-06-04T16:34:29.160100Z

yes that can happen 🙂

dnolen 2020-06-04T16:35:12.160800Z

do you agree that all other cases are really some form of 2. ?

bhauman 2020-06-04T16:35:52.161700Z

yes caching something under :nodejs-rt false

dnolen 2020-06-04T16:36:11.162100Z

the order may change what gets cached - but in the end it doesn't really matter, they all look like 2.

bhauman 2020-06-04T16:36:11.162200Z

or just caching something

bhauman 2020-06-04T16:36:24.162400Z

yes

bhauman 2020-06-04T16:37:32.163Z

well they can cache something that points to CLJSJS or a node modules require

bhauman 2020-06-04T16:37:42.163300Z

that’s a more general 2

bhauman 2020-06-04T16:38:48.164300Z

more specifically a library that exists outside of the project like reagent gets cached that way

dnolen 2020-06-04T16:44:57.164900Z

so here's the thing - I don't actually see any good answers to this problem yet - let's point out some basic assumptions

dnolen 2020-06-04T16:45:34.165700Z

1. Realated, AOT Cache can't understand macro time configuration because it is file specific, not build specific

dnolen 2020-06-04T16:45:54.166200Z

2. AOT Cache caches along build configuration computed path only, no file specific stuff as stated in 1.

bhauman 2020-06-04T16:46:27.166900Z

I understand that

dnolen 2020-06-04T16:46:31.167100Z

3. Whether we use node module or CLJSJS is in fact exactly the same same problem as 1., a file specific thing

bhauman 2020-06-04T16:46:56.168Z

yep

dnolen 2020-06-04T16:46:57.168100Z

4. it's allowed that what's in node_modules is never specified

bhauman 2020-06-04T16:47:18.168500Z

cool you understand the problem then

bhauman 2020-06-04T16:47:39.169300Z

I totally get that it may not be fixable

dnolen 2020-06-04T16:48:19.170100Z

well it points a bunch of prior choices that make it appear incompatible with a simple caching strategy

dnolen 2020-06-04T16:49:28.171400Z

one alternative is validation to prevent cache corruption

dnolen 2020-06-04T16:49:42.171700Z

i.e. break 4. or at least supply a flag to break 4.

dnolen 2020-06-04T16:50:29.172300Z

that is you can't use something not both in :npm-deps and in node_modules

bhauman 2020-06-04T16:51:44.173300Z

doesn’t sound ideal either

bhauman 2020-06-04T16:52:03.174100Z

in practice there is a rough patch when folks are switching over

dnolen 2020-06-04T16:52:04.174300Z

let's be clear to

dnolen 2020-06-04T16:52:12.174800Z

this only affects any tool default to :aot-cache true

dnolen 2020-06-04T16:52:16.175100Z

which is not true by default

bhauman 2020-06-04T16:52:19.175200Z

and are unaware of what libraries depend on what

dnolen 2020-06-04T16:52:34.175600Z

you don't need to know what depends on what

dnolen 2020-06-04T16:52:41.176Z

upstream :npm-deps is a thing

bhauman 2020-06-04T16:52:53.176400Z

cljs.main defaults to :aot-cache true

dnolen 2020-06-04T16:53:09.176800Z

no burden on the user other than installing the deps and specifying their own

dnolen 2020-06-04T16:53:49.177700Z

yes cljs.main specifically designed for people who are going to audit their deps because we don't care about the macro build time problem

dnolen 2020-06-04T16:54:34.178700Z

so we're already just saying you're on own - I don't really care that much about this caching problem and order stuff because it's a one time thing

dnolen 2020-06-04T16:55:15.179500Z

but I do care that downstream tooling can provide better UX if that's desired

dnolen 2020-06-04T16:56:12.180100Z

but breaking 4. is not as bad it sounds - it's more disciplined and would in fact catch simple mistakes

dnolen 2020-06-04T17:02:20.181700Z

really 4 is just :enforce-deps - either :install-deps is true, or the libs are present at the top level

dnolen 2020-06-04T17:02:52.182400Z

this means it's not possible to use Reagent w/o installing the deps first - because you're saying they must come from there not elsewhere

dnolen 2020-06-04T17:03:04.182800Z

since node_modules wins over foreign libs

dnolen 2020-06-04T17:14:46.184500Z

just noting that changing caching is quite unattractive because you would be generated useless cache files while you're changing your deps at the beginning of the transition

dnolen 2020-06-04T17:15:10.184800Z

better to just turn it off during transition

bhauman 2020-06-04T17:17:06.186600Z

the cache is not build dependent so this gets tricky

dnolen 2020-06-04T17:17:37.187100Z

yes it doesn't know anything about builds - just build affecting options

dnolen 2020-06-04T17:19:41.188200Z

because you want the cache to be available to all builds

dnolen 2020-06-04T17:20:32.189400Z

again this is due to dependency ambiguity

dnolen 2020-06-04T17:20:51.190Z

which isn't generally true for Clojure(Script) stuff, just libs that don't enforce one or the other

dnolen 2020-06-04T17:21:10.190600Z

so this once again the same problem rearing it's head

bhauman 2020-06-04T17:21:40.191300Z

buts its only because the way of requiring the dependency is in the file itself

dnolen 2020-06-04T17:21:48.191700Z

no

bhauman 2020-06-04T17:21:51.191900Z

it its not abstracted

dnolen 2020-06-04T17:21:55.192200Z

it has nothing to do with that

dnolen 2020-06-04T17:22:06.192600Z

it's a dependency ambiguity plain and simple

bhauman 2020-06-04T17:22:06.192700Z

OK bear with me

bhauman 2020-06-04T17:22:12.193100Z

yes I hear that

dnolen 2020-06-04T17:22:15.193200Z

you don't know know where the dependency is coming from

bhauman 2020-06-04T17:22:22.193400Z

hold on

bhauman 2020-06-04T17:23:08.194200Z

if the code for requiring the cljsjs dependency and the node dependency was rendered the same in the output this isn’t a problem

dnolen 2020-06-04T17:23:24.194400Z

completely unrelated

dnolen 2020-06-04T17:23:36.194900Z

think about a two Maven dependencies with the same package name

dnolen 2020-06-04T17:23:42.195100Z

you don't know what you're going to cache

dnolen 2020-06-04T17:23:48.195400Z

this happens with Clojure AOT

bhauman 2020-06-04T17:24:43.196200Z

I’m saying that if this line

reagent.impl.component.global$module$react = goog.global["React"];

bhauman 2020-06-04T17:24:54.196800Z

was the same for both node and cljsjs

bhauman 2020-06-04T17:25:04.197200Z

then they are caching the same thing

dnolen 2020-06-04T17:25:08.197300Z

I'm just pointing out you're talking about solutions

bhauman 2020-06-04T17:25:39.198300Z

yes

bhauman 2020-06-04T17:25:54.198900Z

i get that you are addressing fundamentals

dnolen 2020-06-04T17:25:59.199100Z

yes

dnolen 2020-06-04T17:28:39.201300Z

to your point - I just don't see anything fruitful around how we "link" the library

dnolen 2020-06-04T17:30:08.202200Z

but maybe you see something, all ears

bhauman 2020-06-04T17:31:35.203800Z

having external libs be linked in a similar manner is kinda interesting to me

dnolen 2020-06-04T17:32:02.204500Z

sure but I don't see anything that would work?

bhauman 2020-06-04T17:33:34.206Z

well under bundle we have npm_deps, why not have cljsjs libs scoped to a JS object?

bhauman 2020-06-04T17:34:08.206600Z

it kinda sucks that these things are global anyway

bhauman 2020-06-04T17:35:41.208Z

there are problems with backward compatibility here, which is a real practical problem

dnolen 2020-06-04T17:36:02.208400Z

also load order w/ webpack

dnolen 2020-06-04T17:36:07.208600Z

we are async webpack isn't

dnolen 2020-06-04T17:37:26.210200Z

also maybe a node_module DCE issue?

dnolen 2020-06-04T17:38:05.210800Z

anyways this would be moving around a lot of chairs

bhauman 2020-06-04T17:38:12.211100Z

yeah nothing simple

dnolen 2020-06-04T17:38:25.211500Z

so it's not very enticing

bhauman 2020-06-04T17:39:01.212100Z

we couldn’t have the npm_deps.js inline the cljsjs lib could we?

bhauman 2020-06-04T17:39:20.212500Z

nah load order

bhauman 2020-06-04T17:39:25.212700Z

never mind

bhauman 2020-06-04T17:39:29.212900Z

welll

dnolen 2020-06-04T17:39:39.213300Z

I think maybe load order isn't an issue

dnolen 2020-06-04T17:39:57.213700Z

because webpack ensures everything is present - this works for the REPL

bhauman 2020-06-04T17:39:58.213800Z

yeah yeah

dnolen 2020-06-04T17:40:45.214600Z

but for DCE and code splitting ... changing stuff is probably a bad idea

dnolen 2020-06-04T17:41:38.215400Z

you really don't want foreign libs to go into one place for code splitting

dnolen 2020-06-04T17:42:26.216700Z

for :bundle npm_deps.js is dev time only, so the door remains open for DCE improvements later

dnolen 2020-06-04T17:42:56.217200Z

so there's just a bunch of considerations in the way of making this easy

dnolen 2020-06-04T17:42:59.217400Z

only to make everything else hard

bhauman 2020-06-04T17:43:10.217700Z

good points

dnolen 2020-06-04T17:45:15.218700Z

one other option probably has it's own issues is emitting require for foreign libs

dnolen 2020-06-04T17:46:27.219900Z

but then you need to configure your bundler so that's moving work around

dnolen 2020-06-04T17:47:28.220500Z

I think the issue need more stewing

dnolen 2020-06-04T17:49:05.221Z

hrm though webpack can handle relative require so maybe no config

dnolen 2020-06-04T17:52:14.222200Z

I think the blocker here is that many foreign libs are probably packaged expecting to be global?

dnolen 2020-06-04T17:52:44.222700Z

fixing up a bunch of libraries when you're transitioning away doesn't sound very valuable

dnolen 2020-06-04T17:56:47.223700Z

@juhoteperi I think worth pondering dropping the Reagent explicit dependency on cljsjs/react users can always add it

juhoteperi 2020-06-13T14:52:00.279200Z

I think it will be better for users to maintain cljsjs react versions themselves, I'm not updating Reagent whenever a new React version is available. This is in fact similar to JS world, libraries only have peerDependency on React, and the application must provide React version.

dnolen 2020-06-04T17:57:08.224200Z

I think pointing to both things creates more problems than it's worth as the backlog will show

dnolen 2020-06-04T17:57:57.224900Z

@bhauman I think the simplest answer is to just have libraries just choose one dependency

dnolen 2020-06-04T17:58:09.225200Z

then the problem just goes away

juhoteperi 2020-06-04T19:27:08.227200Z

@dnolen Yes, I've been planning to drop the cljsjs dependency

juhoteperi 2020-06-04T19:27:31.227400Z

Probably before final 1.0 release

dnolen 2020-06-04T19:35:59.227600Z

k