Clojurians
#cljs-dev
<
2018-02-25
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

bhauman15:02:53

freaking Jira. I just spent a half an hour composing a thoughtful ticket for the browser-repl supplying a index.html and Jira completely ate it due to session time out.

bhauman15:02:47

a less elegantly phrased ticket

dnolen17:02:52

@bronsa you need a :excludes for read+string I think

bronsa17:02:53

sorry was not testing on 1.10 yet

bronsa17:02:32

releasing alpha2

dnolen17:02:25

@bronsa I note the behavior of tools reader is different from Clojure

dnolen17:02:42

for read+string, with tools.reader I get the newlines, with Clojure I do not

bronsa17:02:06

oh I hadn't noticed clojure trimmed the output

dnolen17:02:07

@bronsa happy to test via deps.edn to make sure everything looking alright before you cut another release

bronsa17:02:21

I just pushed a fix for that

dnolen18:02:27

@bronsa I think you introduced a bug somewhere, I get empty strings now

dnolen18:02:23

@bronsa 0618158132cc8a997143d73395dceeb1bdfeb833 gives me empty strings

dnolen18:02:24

f87e8db5dea5b1ebbe3e628a4de660d067ae1082 does not

bronsa18:02:50

sorry haven't had much time to test this

dnolen18:02:43

@bronsa that works yes

dnolen18:02:55

@bhauman I left a comment on CLJS-2553, I think we should just emit index.html if not present - I don’t think we need to overthink this, browser REPL looks for index.html in the current directory - we should just do that - means fewer changes

dnolen18:02:41

@bronsa there’s also a bug here in Clojure that you copied

dnolen18:02:15

if arg count is 1 you have to unpack and reverse order to call read

dnolen18:02:37

otherwise there’s no way for me to invoke arity 2 with the read cond stuff

bronsa18:02:02

gah, the arity is reversed

bronsa18:02:08

is there already a ticket for clojure?

bronsa18:02:36

give current master a try

dnolen18:02:10

@bronsa everything appears to be working now

bronsa18:02:30

will cut alpha3

bronsa18:02:34

thanks for trying it out

dnolen19:02:29

I’m sure someone has mentioned this before, but this works clj -J-Dclojure.server.repl="{:port 5555 :accept cljs.repl.node/-main}"

bhauman19:02:36

and that should work for the prepl as well

dnolen19:02:00

clj -J-Dclojure.server.repl="{:port 5555 :accept cljs.core.server/io-prepl}"

bhauman19:02:23

so the browser repl looks for the index.html in the :static-dir's which are overridable

bhauman19:02:58

you are saying just gen the html to "." regardless

bhauman19:02:10

which seems fine

dnolen19:02:11

@bhauman we do need a flag to disable the generated file, but it should default to true

bhauman19:02:30

again this makes me think serving it may be a simpler solution

dnolen19:02:48

hrm, but then the user has to know what will go in there if they need to provide their own …

bhauman19:02:39

The tradeoff seems thin for a 3 line html file. That everyone has to learn to write anyway. Serving it will work no matter what the config is, and adding a flag to prevent an unwanted index.html seems not the best

bhauman19:02:27

a flag to generate it is interesting ...

bhauman19:02:06

but that doesn't help the original problem

mfikes19:02:09

Looking over the prepl stuff, I think self hosted environments can choose to implement their own version of cljs.core.server/io-prepl (which involves self-hosted eval) and those supporting Socket REPL can allow users to hook into prepl via :accept. Perhaps an interesting consequence of all of this is that cljs.core/tap> and related fns, are really there for self-hosted environments, unless I'm thinking about this incorrectly.

bhauman19:02:21

They are there for both environments as far as I know.

mfikes19:02:47

Ahh... I can't yet see how the cljs.core/tap> works for non-self-hosted.

bhauman19:02:49

the repl implementation has to forward the message back

bhauman19:02:24

and then call tap> on the "server" side

dnolen19:02:47

@bhauman yeah ok, let’s go with serving

bhauman19:02:49

darn I really have to play with it a bit

bhauman19:02:59

@dnolen good to hear

dnolen19:02:36

@mfikes well REPLs can call add-tap on the client side of their integration, so not just for self-hosted

mfikes19:02:11

OK. I'll read more code and see how it all hooks together :slightly_smiling_face:

mfikes19:02:20

When I do

clj -J-Dclojure.server.repl="{:port 5555 :accept cljs.core.server/io-prepl}"
in the root of the ClojureScript source tree, I get an exception indicating
Unable to resolve symbol: PrintWriter-on in this context
Will dig further or write a ticket.

bhauman19:02:37

that's clojure 1.10

mfikes19:02:47

Ahh thank you

dnolen19:02:09

and we can’t actually invoke io-prepl directly like that at the moment

dnolen19:02:28

need to supply repl-env

mfikes19:02:36

(I suppose I can also just use Clojure 1.10 as a model as well.)

mfikes19:02:38

Like this

$ java -Dclojure.server.repl="{:port 5555 :accept clojure.core.server/io-prepl}" -jar clojure.jar

dnolen20:02:31

I updated master to make this easier

dnolen20:02:34

clj -J-Dclojure.server.repl="{:port 5555 :accept cljs.server.node/prepl}"

mfikes20:02:41

Cool. Thanks!

bhauman20:02:58

oh dang serving the browser repl index.html is a sweet experience

mfikes20:02:36

This will be good for Quick Start :slightly_smiling_face:

mfikes20:02:14

IMHO, Quick Start today has the potential to turn away people who are not patient enough to make it through it. With this new stuff, devs who want instant gratification will be happy.

dnolen20:02:51

but also it’s making it easier for everyone

mfikes20:02:12

Definitely true. Even for experts. :slightly_smiling_face:

dnolen20:02:26

when you just want to try something quick, the new stuff makes it a lot easier

mfikes20:02:00

For example, I think I spent 10 to 15 minutes figuring out index.html. Life it too short for that.

bhauman20:02:17

@dnolen @mfikes should we add an <div id="app"></div>

mfikes20:02:32

I have no clue

dnolen20:02:02

I don’t think so, we’re just doing this so you get something if you don’t provide index.html

mfikes20:02:26

Did you find that you needed to make src match -o's value? (Curious.)

bhauman20:02:43

yeah just made it output-to

bhauman20:02:25

making the patch now

mfikes20:02:50

Cool. I suppose -o / --output-to is required for browser REPL (dunno)

mfikes20:02:41

(If it defaults to "out/main.js" or somesuch, even easier.)

dnolen20:02:49

hrm I haven’t use -o with browser REPL

dnolen20:02:58

"out/main.js" is the default

mfikes20:02:13

Cool. So Bruce's patch will honor -o if the user specifies it.

bhauman20:02:01

it requires :main and :output-to to be in the compiler options

bhauman20:02:26

my god what an improvement

dnolen20:02:03

testing it now

mfikes20:02:11

So am I :slightly_smiling_face:

bhauman20:02:45

clj -m cljs.main -re browser -c example.core -r

bhauman20:02:54

was how I was using it

mfikes20:02:08

Cool. It doesn't even write to the filesystem

bhauman20:02:13

too bad I can't do clj -m cljs.main -re browser -r

mfikes20:02:33

Yeah, you need to compile something... hrm

bhauman21:02:05

I'm requiring a main to be present

dnolen21:02:23

@bhauman I don’t think main has to present

bhauman21:02:25

so that its a boostrap script

dnolen21:02:55

you always get a bootstrap script

dnolen21:02:59

unless target :none

bhauman21:02:06

oh yeah yeah

dnolen21:02:12

@bhauman so clj -m cljs.main -re browser -r

dnolen21:02:17

could work now if you remove the need for :main

dnolen21:02:33

k will wait then, otherwise patch looks good

mfikes21:02:16

Everything is working for me. (It honors -o, leaves index.html there if it exists.)

mfikes21:02:08

:local/root deps rock (I just applied the patch and ran things without even building ClojureScript)

mfikes21:02:35

(from another project - Coal Mine)

bhauman21:02:42

so the default :optimizations is :simple ?

dnolen21:02:59

@bhauman only for the client script

dnolen21:02:05

(which goes in the iframe)

dnolen21:02:32

default optimizations is always :none

dnolen21:02:02

@mfikes nice

mfikes21:02:39

Safari is still doing that thing where you sometimes need to refresh your http://localhost:9000 page (but this is not a regression, this seems to have always been the case)

bhauman21:02:50

this is taking a bit longer than expected

dnolen21:02:17

@bhauman so dropping :main requirement creates some other problem?

bhauman21:02:55

yeah for clj -m cljs.main -re browser -r there is no output-to

bhauman21:02:03

in the compiler options

bhauman21:02:53

which leaves the generated script in the repl under its hash EF9FE3E.js

bhauman21:02:21

and so I'd have to require goog.base

dnolen21:02:37

the problem is this is -r but without -c

dnolen21:02:48

so that’s a different code path in cljs.cli

bhauman21:02:03

even with -o set it won't work

bhauman21:02:14

I think the original patch is the way to go

bhauman21:02:29

unless you want to pull from the .repl dir

dnolen21:02:47

this is not a limitation of what we have but how we manage the commands in cljs.cli

bhauman21:02:52

which is possible but I'd need a name for the script

dnolen21:02:50

@bhauman just drop the main bit from the patch, I think I know how to make this work

bhauman21:02:49

I have to say I think maybe adding an output-to to the client.js compile and then pulling the output-to from .repl dir might be a good solution because it doesn't couple the browser repl behavior to cljs.main

dnolen21:02:47

I don’t think is problem though

dnolen21:02:22

browser REPL is different from other REPLs - you need to generate bootstrap file

dnolen21:02:43

oh hrm …

dnolen21:02:36

yeah, it’s a fundamentally different case

dnolen21:02:28

… but browser REPL server could serve out/main.js if it doesn’t exist same as index.html

dnolen21:02:19

nothing needs to be in there except loading goog.base & the deps files

dnolen21:02:58

that’s what we should do - then no change to anything else

bhauman21:02:28

so are you taking this over?

bhauman21:02:41

that'd be fine by me

dnolen21:02:41

I can do that bit sure

bhauman21:02:54

you still want me to update the patch?

bhauman21:02:24

I think with what you are doing you don't even need to require output-to

mfikes21:02:00

An extremely nice consequence of the synthetic generation of index.html is that the code being compiled can now be a git dep. (This did not work previously because, even if you had an index.html in the git repo, it wouldn't be in the working directory. Now that it is synthetically created, things just work.)

bhauman21:02:57

now back to documenting rebel

bhauman21:02:55

@mfikes by the way I don't know if you tried running rebel-readline.main and then launched a rebel-readline.cljs.repl/repl from inside it

bhauman21:02:02

its' pretty sweet

bhauman21:02:38

nesting works perfectly

mfikes21:02:39

No, but I plan to mess with it some more :slightly_smiling_face:

mfikes21:02:30

I'd like to make a "one line git dep" demo of this synthetic index.html generation. I don't know web tech enough to know if I can dynamically add a canvas element so that I cal slap the CLJS logo into the browser (using the bit of code at the bottom of http://blog.fikesfarm.com/posts/2017-04-29-clojurescript-ejecta.html)

bhauman21:02:07

sure you can

bhauman21:02:18

but you can just request an image?

mfikes21:02:30

I'm thinking you run clj -Sdeps ...` and then go to localhost 9000 in your browser and see something cool

bhauman21:02:58

yeah you can just append an image element to body

bhauman21:02:16

that points to one of the currently hosted logos

mfikes21:02:51

Cool. I might try that. A browser-based version of something like https://twitter.com/mfikes/status/967038906893045760 to get more people interested in cljs.main and git deps, etc.

bhauman21:02:29

the first answer to that question should do it

mfikes21:02:34

Actually if it started playing Flappy Bird via Figwheel automatically. :slightly_smiling_face:

mfikes21:02:59

I'll try a simple CLJS logo demo for now. :slightly_smiling_face:

bhauman21:02:03

well that's possible

bhauman21:02:21

if you need me to commit a deps to the repo let me know

bhauman21:02:07

but no figwheel not yet

bhauman21:02:37

oh darn I didn't try the watcher yet

bhauman21:02:31

man there is very little in the way of args checking a simple check that prints a message non existence of needed paths would do wonders

bhauman21:02:22

watching with the repl attached is dang cool as well

bhauman21:02:43

the shared compiler env makes it sweet

bhauman21:02:15

define a new fn in your source, reload the browser, and call it from the repl, with no compile warning

richiardiandrea22:02:00

Oh that's cool indeed as does it work in node as well?

mfikes23:02:32

Here is a cool demo of synthetic index.html (David will recognize it):

clj -Sdeps '{:deps {github-mfikes/chambered {:git/url "" :sha "7a04b48900041b6aefa8dbed6079d18952db5ee5"}}}' -m cljs.main -re browser -c chambered.core -r