Fork me on GitHub
#boot
<
2016-07-04
>
richiardiandrea00:07:39

@myguidingstar: you should go to boot.user and trigger a (boot (task) (task))

timothypratley02:07:28

what's the best boot way to get started on a reagent app?

timothypratley02:07:49

I tried http://escherize.com/2016/02/29/boot-with-cljs/ but get errors... "clojure.lang.ExceptionInfo: template already refers to: #'boot.core/template in namespace: adzerk.boot-reload"

escherize02:07:31

@timothypratley: what command causes that? Was it:

boot -d seancorfield/boot-new new \
     -t tenzing \
     -a +reagent \
     -n escherize-cljs 

timothypratley02:07:08

hmmm nope, I think that part worked fine, boot dev is where things went wrong for me... I must have some config messing it up

timothypratley02:07:27

19:56 $ boot --version
#
#Sun Jul 03 19:56:14 PDT 2016
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.7.0
BOOT_VERSION=2.6.0

escherize02:07:43

Yeah I think you're right because it appears to work for me.

escherize02:07:00

with a fresh template and everything.

escherize02:07:07

do you have anything in ~/.boot ?

timothypratley02:07:52

yes: boot.properties cache profile.boot.bak (I moved it just in case it was messing with me)

escherize02:07:53

# bcm @ brmbp in ~/dv/escherize-cljs [12:58:02] C:130
$ cat boot.properties
#
#Mon Jul 04 12:56:22 EST 2016
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.7.0
BOOT_VERSION=2.5.5
BOOT_EMIT_TARGET=no

timothypratley02:07:19

hmmmm maybe I should change boot versions

escherize02:07:28

I'll try upgrading mine

escherize02:07:40

I have a meeting in 2 minutes.. >_<.

escherize02:07:54

I'll be around after incase you don't get it figured out.

timothypratley02:07:10

groovy no rush, I'll try different versions, that will no doubt fix it

timothypratley02:07:15

thanks for the help šŸ™‚

micha03:07:23

@timothypratley: you can do (ns-unmap (the-ns 'boot.core) 'template) as a workaround, if nothing else solves it

timothypratley03:07:38

ooo nice, thanks šŸ™‚ handy to know

micha03:07:40

in your build.boot file

micha03:07:58

that just removes the name from that namespace

timothypratley04:07:28

I like the new HUD šŸ™‚

escherize05:07:33

šŸ‘:skin-tone-3:

braai engineer15:07:05

Alright, guys. I need some help with boot-cljs. The output of the task has bitten me several times and I canā€™t seem to figure out how to get the JS file compiled & served properly because there are so many complected settings that interact and touch the same things, like output-to vs output-dir vs asset-path vs .cljs.edn and whatā€™s required in there - besides no target files are visible even though it compiles fine. Iā€™m sure itā€™s simple and I misunderstand a lot of it, but I struggle to get it working. In my project I have a ~/resources/public path, so I have this in my compojure api setup: (route/resources "/resources" {:root "publicā€}) Then I have ~/src/cljs/js/main.cljs.edn, which contains:

{:require [myproject.core.init myproject.core.app]
 :compiler-options {:asset-path "cljs/out"
                    :output-to "resources/public/cljs/out/main.js"
                    :output-dir "resources/public/cljs/out"
                    :parallel-build true}}
And in build.boot I have,
(set-env!
  :source-paths #{"src/cljs" "src/clj" "test"}
  :resource-paths #{"resources"}
  :target-path "target"
  :dependencies ā€˜[...
finally, with (cljs :ids #{"js/mainā€}) under my ā€œdevā€ boot task. Everything compiles fine, but my compiled .js file is not at /resources/cljs/out/main.js as I would expect. Actually I have no idea where it is because it is invisible or ā€œin the JARā€. What is going on with my project and how do I figure out where my minified JS file will be available at?

braai engineer15:07:49

OK, after some modification and after adding (target) to my dev task, I can now see that cljs is outputting files to target/js/main.out/, but its root main.js is referencing <script src="js/out/goog/base.js"></script> instead of js/main.out/ā€¦ Why does it do this? It knows where itā€™s putting the files, why does it use the wrong folder?

micha15:07:44

@petrus: what is your high-level goal?

micha15:07:03

i strongly advise against messing with :output-to etc

micha15:07:17

for the specific reason that these options are strongly coupled in weird ways in the compiler

micha15:07:23

the cljs task figures that out for you

braai engineer15:07:24

High-level goal is to get my cljs app working without 404s on the files that it compiled

micha15:07:45

ok, great, we can make that happen šŸ™‚

micha15:07:55

what is your html page uri, relative to the root?

juhoteperi15:07:37

@petrus: Don't use output-to and output-dir with boot-cljs

braai engineer15:07:47

I worked from saapasā€™ template: https://github.com/Deraen/saapas/blob/master/src/cljs/js/main.cljs.edn I took out the settings for :output-to and :output-dir. Now I have simplified to this:

:compiler-options {:asset-path "js/out"
                    :parallel-build true}
My index page lives at / and is generated by compojure. It loads but canā€™t find all the deps. My resources path is working because I can load, http://localhost:10555/cljs/out/goog/base.js, but base.js references cljs/out/goog/base.js, whereas the folder structure is cljs/main.out/goog/base.js Note: the ā€œmain.outā€ instead of /out. I suspect this has to do with (cljs :ids #{ā€œjs/mainā€})

micha15:07:22

it shouldn't be there, the out dir is not right

micha15:07:33

is your page index.html?

braai engineer15:07:46

No it lives at / and is generated by compojure

braai engineer15:07:06

(GET "/" []
      (-> (ok pages/index-page) (content-type "text/html")))

juhoteperi15:07:20

What about your resources route?

braai engineer15:07:27

(route/resources "/js" {:root "jsā€})

braai engineer15:07:40

(I went back to saapasā€™ template)

juhoteperi15:07:55

Ah, try: :asset-path "js/main.out", or even without asset-path

juhoteperi15:07:10

Boot-cljs should set asset-path automatically, though it doesn't always work correctly

micha15:07:24

the whole asset-path is just adding complexity with no benefit, imho

micha15:07:48

nobody will see the uris you load js from, no need to make it fancy

micha15:07:56

it's an implementation detail

juhoteperi15:07:12

Yeah, I wonder why I have it set at Saapas

braai engineer15:07:10

You probably have it set because cljs has no knowledge of resources folder. I took out :asset-path and now base.js is trying to load /main.out/cljs_deps.js etc. instead of /js/main.outā€¦

micha15:07:29

it should be trying to load relative paths

braai engineer15:07:15

it does load a relative path, but relative to the index.html, which is at /

braai engineer15:07:42

BOOM fixed with :asset-path "/js/main.outā€

micha16:07:33

so the fix is actually to not have main.js in the js subdir

micha16:07:46

put the .cljs.edn file in the same folder as the html file

micha16:07:05

and let boot-cljs take it from there, everything will work perfectly

micha16:07:43

the :asset-path approach is leaky, everything needs to be aware of it

micha16:07:53

so if any part of the pipeline isn't you'll have issues

micha16:07:13

but if you put the js file in the same dir as the html file it's very simple for tools to figure out on their own

micha16:07:47

and like i said it's totally an implementation detail, no real benefit in making that fancy

micha16:07:54

otherwise you can use optimizations :simple and avoid all kinds of headache

juhoteperi16:07:45

Well, that is not completely true, I still depend on classpath prefix for serving files

micha16:07:27

i just use a filter to prevent secret things from being served

micha16:07:56

especially since most resources are on cdn anyway

micha16:07:12

it's easy to make a filter middleware

juhoteperi16:07:36

Would be extra work etc. and I this case I prefer using the same solution as always

juhoteperi16:07:40

Works for me

micha16:07:20

the js/main.js situation is because of the way the cljs shim works, right?

micha16:07:31

so that's a separate issue

juhoteperi16:07:32

Yeah, IIRC our own Shim worked correctly

micha16:07:48

yeah i dont' see any reason not to use that, it was great

micha16:07:17

your hack there was genius

micha16:07:28

i was a big fan of it šŸ™‚

juhoteperi16:07:44

It is on my list to fix this, with own shim or some other solution, I'll rather support all (most) configurations rather than explain thousand times why something is not supported šŸ˜„

micha16:07:12

i have the day off today, maybe it's time to think about the webconfig?

micha16:07:00

also i'm working on a simplified ns macro for cljs, that handles the macros and all that transparently, with :refer :all and :use :exclude support

micha16:07:08

as a standalone boot task

juhoteperi16:07:07

If you write some ideas down I can look at them, but I'm not yet ready to completely put my mind into next Boot-cljs/reload

juhoteperi16:07:29

It's been super busy year and I still have few days work before summer vacation

micha16:07:37

haha yeah same here

juhoteperi16:07:11

For the first two weeks of vacation I'll probably be mostly offline but then I might start looking this

micha16:07:11

cool yeah

flyboarder16:07:29

@juhoteperi: @micha: the thing about programmers, everything is basically an extension of work šŸ˜›

richiardiandrea16:07:55

about the next boot-cljs it would be great to include cool error messaging, I'd love to help with that

juhoteperi17:07:38

Compilation errors like in Figwheel or configuration errors? Or both?

richiardiandrea17:07:46

Compilation errors

juhoteperi17:07:03

I guess there is some change that the spec for configuration will be added upstream

richiardiandrea17:07:11

both of course is ideal, I don't know if it's worth it

juhoteperi17:07:12

And there is good change I'll leverage Figwheel client code

richiardiandrea17:07:32

if this goes upstream of course there is no point in doing it now