cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
dnolen 2020-05-18T12:39:43.119900Z

@bhauman re: :bundle-cmd this just exactly the kind of thing I'm not interested in working on since it's very unclear what's needed and whatever we choose might not be right in all scenarios - I don't have this problem with React Native in medium size application.

dnolen 2020-05-18T12:40:11.120600Z

and it just seems too straightforward to fix it in Figwheel or any other tool if the tool designer wants some specific semantic

dnolen 2020-05-18T12:43:21.121700Z

maybe you're agree with this sentiment, not completely sure reading over the backlog

dnolen 2020-05-18T12:43:53.122500Z

but I would say the first question everyone should ask themselves is "maybe I shouldn't use :bundle-cmd ?"

dnolen 2020-05-18T12:43:59.122700Z

and then your problems go away

dominicm 2020-05-18T13:04:40.122800Z

@dnolen just to clarify, the rn bundler doesn't care about your :output-to existing for the first run

dominicm 2020-05-18T13:18:10.122900Z

fwiw, I've ended up having to hack something to run in a figwheel post-build-hook which will start a process if it's not already running 🤕. It's a bit hacky.

dnolen 2020-05-18T13:21:21.123200Z

right but why bother?

dnolen 2020-05-18T13:21:28.123500Z

just start the watcher first manually

dnolen 2020-05-18T13:32:01.123800Z

@alexmiller website needs a bump for that AskClojure question

dominicm 2020-05-18T13:42:24.123900Z

Because people generally expect to be able to rock up at a project and jack-in without having to open a bunch of terminals to get all of the 5 processes they need running to run a project.

dominicm 2020-05-18T13:42:39.124100Z

But also, I don't think the watcher can be started first manually.

dnolen 2020-05-18T13:42:56.124600Z

modern JS development isn't like that anyway

dominicm 2020-05-18T13:42:58.124900Z

Yeah, it can't. You have to wait until after the first cljs build.

dnolen 2020-05-18T13:43:01.125Z

there's already multiple steps

dnolen 2020-05-18T13:43:20.125400Z

and you're using a bundler which you can't abstract away

dnolen 2020-05-18T13:44:01.126300Z

anyways just not interested right now, :bundle-cmd isn't going to see any further enhancement

dnolen 2020-05-18T13:44:07.126700Z

I said this when I added it

dnolen 2020-05-18T13:45:11.127200Z

I'd rather see some other tool work on this problem - discover all the issues before investing any more time in it

dominicm 2020-05-18T13:45:37.127300Z

OK. Well, I can sorta do my own bundle for now with figwheel.

alexmiller 2020-05-18T13:46:59.127400Z

done

bhauman 2020-05-18T14:23:19.131400Z

@dnolen I think @dominicm is saying that React Native bundler doesn’t require the output-to artifact at the start while webpack does. So it makes start up a little tricky, ie you can’t pop a browser client open as you have to start webpack after your first cljs compile.

bhauman 2020-05-18T14:26:29.134800Z

For this reason I’m thinking that :bundle-cmd should run just once for a watched build, as it handled the awkwardness of getting started and doesn’t incur the unneeded cost on incremental compiles. One can just restart the process, or start webpack with a --watch flag, if needed.

dnolen 2020-05-18T14:27:10.135800Z

right but I'm trying to say in this scenario why not just not use it

dnolen 2020-05-18T14:27:20.136100Z

start the watcher, run your CLJS tool

dnolen 2020-05-18T14:27:23.136300Z

the problem goes away

bhauman 2020-05-18T14:27:41.136700Z

I stated why in the preceeding paragraph

bhauman 2020-05-18T14:27:47.137100Z

you can’t start the watcher first

dnolen 2020-05-18T14:28:01.137400Z

the webpack watcher doesn't just keep watching for index.js

dnolen 2020-05-18T14:28:11.137700Z

i.e. the watcher exits if it can't find it?

bhauman 2020-05-18T14:28:24.138100Z

yep

bhauman 2020-05-18T14:28:30.138300Z

so you have to start cljs first

bhauman 2020-05-18T14:28:51.138800Z

and then start the watcher and then reload your browser

dnolen 2020-05-18T14:29:29.139200Z

what happens in webpack if you delete`index.js` while watching?

dnolen 2020-05-18T14:29:47.139900Z

anyways it stuff like this that makes doing anything here super annoying

dnolen 2020-05-18T14:29:54.140100Z

which is why I'm not that interested

dnolen 2020-05-18T14:30:48.141200Z

or rather see it sorted out elsewhere first

dnolen 2020-05-18T14:30:54.141600Z

because it's going to be a time hole

bhauman 2020-05-18T14:31:56.142700Z

Yes thats what I was thinking as well, and starting with just bundling on the first compile to facilitate launching repls etc.

bhauman 2020-05-18T14:32:42.143100Z

as its a simple straightforward behavior

dnolen 2020-05-18T14:35:37.144Z

but what if you use a different bundler that just doesn't have this problem and you want to build something that just refreshes on npm deps changes etc.

dnolen 2020-05-18T14:35:49.144300Z

anyways doing stuff mean less flexibility downstream

dnolen 2020-05-18T14:35:51.144600Z

I just don't like it sorry

dnolen 2020-05-18T14:37:12.145800Z

:bundle-cmd should make no choices

dpsutton 2020-05-18T14:37:15.146Z

> "maybe I shouldn't use `:bundle-cmd` ?" i was thinking that bundle-cmd will be the default and you need to know that you will never need npm deps to not use it?

dnolen 2020-05-18T14:37:27.146300Z

then everybody can make their own and do more interesting things for their other tooling choices

lilactown 2020-05-18T14:39:29.147700Z

my 2c: running :bundle-cmd once after the first successful compile seems the most unopinionated way of doing this

lilactown 2020-05-18T14:40:12.148400Z

solves the problem w/ tools expecting input at process start, and lets you build the rest yourself if you want something fancier

lilactown 2020-05-18T14:41:17.149500Z

it’s onerous to build a tool on top that waits for your bundle to be created and then start another process

lilactown 2020-05-18T14:41:40.150Z

on the other hand, if your tool (like metro) doesn’t care whether it’s there or not it’s still fine to wait until after the succesful build

dnolen 2020-05-18T14:42:17.150900Z

@dominicm the other reason this doesn't seem like a real problem you can make your own index.js that includes :output-to

dnolen 2020-05-18T14:42:38.151300Z

add a layer of indirection

dnolen 2020-05-18T14:43:06.151800Z

or does webpack watcher expect everything to be perfect on the first build - which seems ... wat

lilactown 2020-05-18T14:47:06.152700Z

it seems like a simple way to make it robust for the majority of cases

lilactown 2020-05-18T14:48:07.153800Z

we can’t control all the different behaviors of the tools out there, but we can control the behavior of CLJS to ensure that code is on disk before it starts up at least

đź‘Ť 1
dnolen 2020-05-18T14:53:11.154400Z

that's not the problem under discussion?

dnolen 2020-05-18T14:53:18.154700Z

there is not problem with :bundle-cmd

dnolen 2020-05-18T14:53:32.155200Z

what we're talking about is specifically the behavior of webpack watching

dnolen 2020-05-18T14:54:03.155900Z

if all you need is a separate index.js so just the watcher can start - there is nothing meaningful for CLJS to do here

dnolen 2020-05-18T14:55:28.156700Z

this is exactly how Krell works

dnolen 2020-05-18T14:55:38.156900Z

we make an index.js file once

dnolen 2020-05-18T14:56:00.157600Z

but you can't do that for ClojureScript anyway because the contents can in fact change

dnolen 2020-05-18T14:57:07.159500Z

we could do a similar thing just for :bundle , :bundle-entry or something similar

bhauman 2020-05-18T14:57:09.159600Z

This is only for w watched build, and these changes are rare and are the kinds of changes that normally require a restart

dnolen 2020-05-18T14:57:51.159900Z

a restart of what? the REPL?

bhauman 2020-05-18T14:58:03.160100Z

of the repl build process

bhauman 2020-05-18T14:58:11.160500Z

adding a package for instance

bhauman 2020-05-18T14:58:20.160700Z

adding a preload

dnolen 2020-05-18T14:59:25.161300Z

it's not necessarily true for packages

dnolen 2020-05-18T14:59:47.162300Z

In Krell you can just refresh, and the REPL handles reconnects

bhauman 2020-05-18T14:59:50.162600Z

things that one would expect might need a restart

dnolen 2020-05-18T14:59:57.162900Z

there's no reason that can't happen in the browser too

dnolen 2020-05-18T15:00:07.163400Z

you have to refresh, but you don't need to restart build or REPL

bhauman 2020-05-18T15:12:02.172Z

Just trying to preserve the start up experience and the super quick reloads the folks have come to expect, that’s why I’m going to bundle once at the beginning. And they can start a watcher in parallel if they need it.

bhauman 2020-05-18T15:12:51.173500Z

there will be a flag if they want to bundle every time

dnolen 2020-05-18T15:13:02.174Z

this seems perfectly fine for Figwheel to do it this way

dnolen 2020-05-18T15:13:12.174400Z

I've been saying that over and over again

dnolen 2020-05-18T15:13:18.174800Z

this is what I did in Krell

dnolen 2020-05-18T15:13:47.175700Z

the tool can make the decisions for the specific integration the creators believes will be most useful

dnolen 2020-05-18T15:13:53.176Z

ClojureScript doesn't give a damn about Webpack

lilactown 2020-05-18T15:14:04.176200Z

Testing out other web bundlers, parcel also exits if the entry file doesn’t exist. If a transitive file doesn’t exist, then it shows a loud error (but continues to watch).

dnolen 2020-05-18T15:14:57.176800Z

you can use Metro to build web stuff, it doesn't have this problem

dnolen 2020-05-18T15:15:30.177300Z

anyways I could go on - but there's just not good reason to do anything just yet IMO

dnolen 2020-05-18T15:16:35.177800Z

er, well that's not true, you need index.js

bhauman 2020-05-18T15:18:08.179Z

not surprising

dnolen 2020-05-18T15:18:25.179400Z

but this thing is not a ClojureScript file

dnolen 2020-05-18T15:18:28.179700Z

it never changes

dnolen 2020-05-18T15:19:26.180300Z

part of the issue is really there's several different problems under discussion

dnolen 2020-05-18T15:23:11.182600Z

anyways not convinced it's practical to untangle all these things since the specter of convenience / end user expectation is interwined

dnolen 2020-05-18T15:24:12.183300Z

I don't really like :bundle-cmd being one-shot because nothing else in the compiler config has this semantic

dnolen 2020-05-18T15:24:27.183700Z

:install-deps has the same problem

dnolen 2020-05-18T15:25:11.184200Z

and the answer there was the same - you probably don't want it

dnolen 2020-05-18T15:27:50.184900Z

the other problem is that these issues are dev issues, :bundle-cmd and :install-deps may very well be what you want for prod.

bhauman 2020-05-18T15:28:26.185200Z

my biggest issue is that people lose the current start up behavior (repl connection, browser open) if they opt out of the :bundle-cmd

bhauman 2020-05-18T15:29:34.186400Z

so maybe we need something generic an after-build-hook

dnolen 2020-05-18T15:29:55.186600Z

for Figwheel this is a UX thing - I get that

bhauman 2020-05-18T15:30:08.187100Z

well cljs has the same UX

bhauman 2020-05-18T15:30:22.187500Z

it lauches a repl

bhauman 2020-05-18T15:30:44.188200Z

oh that doesn’t work with the :bundle target

dnolen 2020-05-18T15:31:14.188900Z

it does work

dnolen 2020-05-18T15:31:24.189400Z

clj -m cljs.main -c -r variants work

dnolen 2020-05-18T15:31:45.189800Z

and :bundle is only going to run once

dnolen 2020-05-18T15:31:49.190Z

so you don't have these problems

bhauman 2020-05-18T15:32:40.190800Z

if you add a watcher?

bhauman 2020-05-18T15:32:56.191Z

bundle only runs once?

bhauman 2020-05-18T15:34:14.192500Z

anyway its interesting that the REPL works

dnolen 2020-05-18T15:34:15.192700Z

no, not going to change this (the watcher case) because of your better idea for hot-reloading

dnolen 2020-05-18T15:34:36.193300Z

@bhauman there's a been a bunch of fixes to cljs.cli because of user feedback here

bhauman 2020-05-18T15:35:48.194100Z

cool I’m going to check those changes out and get up to date 🙂

dnolen 2020-05-18T15:36:34.194700Z

@bhauman another fix is that :main is analyzed now on separate thread when you start REPL

bhauman 2020-05-18T15:36:54.195400Z

that was a recent change

dnolen 2020-05-18T15:36:58.195800Z

yes

dnolen 2020-05-18T15:37:07.196400Z

but all of this informed by -c -r

dnolen 2020-05-18T15:37:08.196600Z

usage

dnolen 2020-05-18T15:37:26.197400Z

you compile once, and then you start a REPL, and the REPL takes everything from build

dnolen 2020-05-18T15:37:38.197800Z

hot-reloading would answer any remaining issues

dominicm 2020-05-18T15:54:07.199300Z

Have you thought about bundle for the hot reload? Would that be run once or run per reload?

dnolen 2020-05-18T15:54:39.199600Z

I alluded to this above but probably not clear

dominicm 2020-05-18T15:55:15.200400Z

Hmm, maybe I figured it out. But explicit is better :)

dnolen 2020-05-18T15:55:41.201Z

we're not going to run :bundle-cmd except where we run it now

dnolen 2020-05-18T15:55:49.201300Z

at the end of a build

dnolen 2020-05-18T15:56:39.202100Z

hot-reload generally doesn't need to do anything but the file that changed and its dependents

dnolen 2020-05-18T15:57:55.202400Z

... but

dnolen 2020-05-18T15:59:19.203100Z

the requires may have changed, and we could recompute npm_deps.js which is the required node_modules

dnolen 2020-05-18T16:00:07.203500Z

in this case a watch process is going to be better anyway (because it will know that npm_deps.js has changed)

dnolen 2020-05-18T16:00:51.203900Z

you will also need a refresh and a REPL that will reconnect on refresh

dnolen 2020-05-18T16:02:56.204300Z

so long answer - I'm not sure we should re-run it

dnolen 2020-05-18T16:04:35.205800Z

but making :bundle-cmd more useful for watching workflow seems interesting - i.e. we don't wait for :bundle-cmd to return but just start a process (but has a lot of downsides for logging)

dominicm 2020-05-18T16:11:24.206Z

Hmm. So maybe figwheel should clear :bundle-cmd for subsequent builds then - to mirror that proposed behavior.

dominicm 2020-05-18T16:11:30.206100Z

Not sure what Krell does.

dnolen 2020-05-18T16:12:07.206900Z

it doesn't need :bundle-cmd because you must run npx react-native start anyway

dnolen 2020-05-18T16:13:28.208Z

having that run inside of :bundle-cmd even if we supported it has too many downsides, which why I don't even really like it for the REPL scenario above

dominicm 2020-05-18T16:20:15.208200Z

I see.

dnolen 2020-05-18T16:20:46.208700Z

yeah the problem with triggering a bundle watcher inside ClojureScript is directing the output

dnolen 2020-05-18T16:20:59.209100Z

the output is also colorized so that has to be configured

dnolen 2020-05-18T16:21:42.209800Z

this is true for :bundle-cmd right now too, for very simple builds it's sufficient

dnolen 2020-05-18T16:22:06.210500Z

but I'm skeptical about more complicated builds w/ lots of plugins whether you really want to see the failures in a Clojure stack trace

dnolen 2020-05-18T16:23:52.211300Z

though maybe we should/could do what RN does - automatically open a new terminal for running that command?

dominicm 2020-05-18T16:24:52.211400Z

Personally having one place for it to go (i.e. in my REPL / terminal) is better than checking N places on failure. I actually have non-devs (CEO & designers) working on my Cljs project - so I want to minimize their pain. In a past life I was a consultant, so I made a conscious effort to make sure I could switch projects without having to think about it.

dominicm 2020-05-18T16:25:26.211500Z

I... wonder how it does that. At least on Linux, good luck figuring out: - What my terminal is - How to run it to spawn a new command - Whether I prefer tabs, splits or new windows for my terminal

dnolen 2020-05-18T16:30:20.212400Z

sure I get that just, throwing out thoughts

dominicm 2020-05-18T16:31:27.212600Z

For sure, good to explore everything. I think the only way to work that is something like a ~/.cljs-terminal.edn where I could configure what I want to have happen

dominicm 2020-05-18T16:33:04.212700Z

One worry I have here is fragmentation. I know eventually cljs upstream will merge what works. But in the interim we'll have a few competing solutions to this problem. That just makes things more complex for people trying to use react-select in their project.

dnolen 2020-05-18T16:34:17.213700Z

honestly that seems unavoidable - and has been true for a long time anyway

dnolen 2020-05-18T16:36:12.215300Z

and IMO is in fact desirable - letting tools innovate and folding back in what works is slower but also more sustainable

dnolen 2020-05-18T17:30:03.215500Z

thanks!