Fork me on GitHub
#boot
<
2016-10-16
>
grounded_sage05:10:44

Is it possible to use Figwheel with boot? I'd like to get the awesome error messages and helpers in the heads up display

richiardiandrea08:10:21

@grounded_sage there is a boot-fighweel task and I have wanted to try it out for long time now...I don't have any feedback yet on it, but if you try please report back ok?

grounded_sage08:10:49

Will do haven't been able to get the demo to work yet as I was wanting to use that as a baseline to work off. Going to have a little hack at it tomorrow

piotrek13:10:51

In my project I use levand/immuconf which defines custom data readers

piotrek13:10:02

When I try to run my project with following task:

piotrek13:10:21

(require ‘[example.main])
(deftask
  run-main
  []
  (with-pass-thru
    _
    (example.main/-main)))

piotrek13:10:48

I am getting following error:

piotrek13:10:54

java.lang.RuntimeException: No reader function for tag immuconf/default

piotrek13:10:13

When I start boot repl, require my namespace and run it works correctly

piotrek13:10:19

What might be wrong?

martinklepsch13:10:07

@piotrek try putting this into your build.boot: (load-data-readers!)

piotrek13:10:13

@martinklepsch Is it a boot’s function?

martinklepsch13:10:35

yeah I think it's defined in boot.core

piotrek13:10:19

Yeah, it helped. Thanks @martinklepsch

martinklepsch14:10:34

If you search the issues on github you can find out why that is required, I don't exactly remember right now :)

micha17:10:50

^^ it's because clojure itself runs its own function to scan the classpath for data_readers.clj files when clojure first starts, but in boot you mostly add dependency jars after clojure itself is already loaded, so you need to call it yourself

olegakbarov17:10:09

hi! how can i specify serve directory of boot-http within the build.boot ?

micha17:10:41

@olegakbarov usually you want to serve from the classpath i think

olegakbarov17:10:13

i’m working on a lib and would like to run different “examples”

olegakbarov17:10:00

i mean i have examples folder, and different snippets there

micha17:10:45

so you are wanting to only serve one example at a time, configured in the boot task?

olegakbarov17:10:33

yeah, that would be perfect

micha17:10:56

so the answer to the specific question you asked is that yes you can do it:

micha17:10:16

boot.user=> (doc serve)
-------------------------
pandeiro.boot-http/serve
([& {:as *opts*, :keys [help dir handler init cleanup resource-root port httpkit silent reload nrepl not-found]}])
  Start a web server on localhost, serving resources and optionally a directory.
  Listens on port 3000 by default.
  
  Keyword Args:
    :help           bool  Print this help info.
    :dir            str   The directory to serve; created if doesn't exist.
    :handler        sym   The ring handler to serve.
    :init           sym   A function to run prior to starting the server.
    :cleanup        sym   A function to run after the server stops.
    :resource-root  str   The root prefix when serving resources from classpath
    :port           int   The port to listen on. (Default: 3000)
    :httpkit        bool  Use Http-kit server instead of Jetty
    :silent         bool  Silent-mode (don't output anything)
    :reload         bool  Reload modified namespaces on each request.
    :nrepl          edn   nREPL server parameters e.g. "{:port 3001, :bind "0.0.0.0"}"
    :not-found      sym   a ring handler for requested resources that aren't in your directory. Useful for pushState.

micha17:10:23

the :dir option is the one you want

micha17:10:42

however, you may want to consider alternatives

micha17:10:10

serving files from the target directory can be annoying

olegakbarov17:10:19

should i pass it as follows?

(deftask run []
  (comp (serve {:dir “examples"})
        (watch)
        (cljs-repl)
        (reload)
        (cljs)))

pandeiro17:10:33

No curly brackets

micha17:10:43

the directory is relative to the CWD

micha17:10:47

so like for example:

micha17:10:54

(deftask run []
  (comp (serve :dir "target/examples")
        (watch)
        (cljs-repl)
        (reload)
        (cljs)
        (target)))

micha17:10:22

because :dir refers to a directory in the filesystem, rather than a path in the classpath

pandeiro17:10:49

@micha What was the rationale with doing away with the implicit target?

micha17:10:23

it can be time consuming when you don't need it and have a lot of files, and nowadays it's rarely needed

micha17:10:38

like when i develop i don't need files, i run my dev server from the classpath

micha17:10:52

and when i deploy i also don't really need files because i'm pushing artifacts to the cloud

micha17:10:56

via a task

micha17:10:08

or installing things in local maven or etc

pandeiro17:10:55

I wonder if the majority of workflows use target and would've benefited from the convention; true in my case, but I wonder if it causes problems with other use cases

micha17:10:08

@olegakbarov ^^ @pandeiro made boot-http

pandeiro17:10:17

Ah efficiency, sure

micha17:10:04

also the issue of what to do when you implicitly emit artifacts to target and there are two instances of boot running

micha17:10:20

things like that needed a lot of implicit logic that could be unintuitive

micha17:10:35

so we always had confusion around how that was handled

olegakbarov17:10:44

i got one more (newbie) question: how can i make my lib visible inside examples folder? currently got this:

adzerk.boot_cljs.util.proxy$clojure.lang.ExceptionInfo$ff19274a: ERROR: No such namespace: cljs-dnd.core, could not locate cljs_dnd/core.cljs, cljs_dnd/core.cljc, or Closure namespace "cljs-dnd.core" in file /Users/oleg/.boot/cache/tmp/Users/oleg/code/cljs-dnd/p1d/-rcsl8f/sort.cljs at file examples/sort.cljs

pandeiro17:10:02

That makes sense

micha17:10:37

@olegakbarov i'm curious why you don't have an index page that lets you choose the example you want, with all examples served?

micha17:10:08

or if you have a repo i can clone i can take a look and see

olegakbarov17:10:32

at the moment it is kinda a mess

olegakbarov17:10:44

let me try to clean this up

micha17:10:59

that's ok, programming is always a mess 🙂

olegakbarov17:10:33

5 mins, i’ll push current state to github 🙂

olegakbarov18:10:10

https://github.com/olegakbarov/cljs-dnd so my goal is to set up dev task to serve one of examples and to have cljs-dnd required as lib

olegakbarov18:10:07

pretty sure this is wrong:

(deftask development []
  ;; should run examples
  (task-options! cljs   {:optimizations :none :source-map true}
                 reload {:on-jsload 'cljs-dnd/examples.sort/mount-root})
  identity)

micha18:10:43

why not build all examples and serve them, and let the user choose which example they want to see via links from an index page?

olegakbarov18:10:21

that might work as well

micha18:10:38

that would simplify the build

micha18:10:54

so you'd just create in resources/examples one .cljs.edn file and one index.html file per example

olegakbarov18:10:31

how can i require cljs-dnd.core inside examples?

olegakbarov18:10:55

got :

ERROR: No such namespace: cljs-dnd.core, could not locate cljs_dnd/core.cljs, cljs_dnd/core.cljc, or Closure namespace "cljs-dnd.core" in file /Users/oleg/.boot/cache/tmp/Users/oleg/code/cljs-dnd/qbw/-rcsl8f/cljs_dnd/examples/sort.cljs at file src/cljs_dnd/examples/sort.cljs

micha18:10:00

is src/cljs_dnd/core.clj suppsed to be a .cljs file?

micha18:10:11

it's .clj in the repo

micha18:10:31

that could cause your issue 😉

olegakbarov18:10:50

thank you! that do solved the issue