Fork me on GitHub
#shadow-cljs
<
2018-10-11
>
vigilancetech01:10:20

can someone here tell me what I'm missing? my shadow-cljs.edn

;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 [
  [binaryage/devtools "0.9.10"]
  [adzerk/env                "0.3.1"          :scope "test"]
  [com.rpl/specter "1.1.1"]
  [hoplon/hoplon "7.3.0-SNAPSHOT"]
  [cljsjs/markdown                          "LATEST"]
  [vigilancetech/ui "0.3.0-SNAPSHOT"]
  ]

 :builds
 {:app { :target :browser
        :compiler-options {:language-in :ecmascript5-strict }
        :output-dir "public/assets/app/js"
        :asset-path "/assets/app/js"
        :build-hooks [(build.hop/foo)]
        :modules {:main {:entries [guardian.dashboard]}}}}}
under src/build/hop.cljs
(ns build.hop
  (:require [shadow.cljs.devtools.api :as shadow]
            [hoplon :refer hoplon]))

(defn foo
  {:shadow/requires-server true}
  [build]
  (hoplon/hoplon)
  (shadow/watch (keyword build)))
With the command line:
shadow-cljs run build.hop/foo app 
I'm getting the error:
failed to load namespace: build.hop 

thheller06:10:08

@vigilancetech you can only run Clojure functions but you created a .cljs file. must be either .clj or .cljc

thheller06:10:54

and your :build-hooks is not correct

thheller06:10:07

either you use run or :build-hooks but the same function cannot be used for both

thheller07:10:27

also there is no such thing as a hoplon namespace as far as I can tell?

thheller07:10:40

I just looked over the hoplon impl and it pretty much seems to require boot to work at all

thheller10:10:26

@kanwei did you test clojure-1.10 beta2 yet? I assume it fixes the issue but confirmation would be nice

vigilancetech14:10:26

@thheller thanks for your observations. It looked to me like hoplon was just a preprocessor to finesse the files to get some of its libraries in context (like to address a shortcoming in clojurescript refer) and expand some macros (another shortcoming in earlier clojurescript). https://github.com/hoplon/hoplon/wiki/How-is-a-hl-file-different%3F I'm fairly new to this. You see something different?

thheller14:10:48

@vigilancetech well its important to look for the details

thheller14:10:49

> could be replaced with the following .cljs file

thheller14:10:02

so you could write that .cljs files and shadow-cljs will understand it no problem

thheller14:10:13

> :hoplon/page metadata will tell boot hoplon task to generate the HTML file for the given namespace

thheller14:10:38

the "boot hoplon task" requires boot and won't be executed without it

thheller14:10:54

so I don't know how useful to standalone .cljs file really is

thheller14:10:14

I don't know anything about the architecture that hoplon wants but it looks to me that is requires boot

vigilancetech14:10:06

@thheller IIRC the boot tasks are fairly generic (e.g. its simple to make your own custom ones) but you've given me a direction to focus on, thanks.

thheller14:10:27

it doesn't matter how generic they are .. they still require boot

thheller14:10:01

but as far as I can tell it doesn't do any CLJS compilation on its own

thheller14:10:20

so the default result is to generate a bunch of .cljsand .html files

vigilancetech14:10:12

I think there's just one of each, and from my observation the html file never changes as its just a launcher for the resultant js

vigilancetech14:10:14

what appears to me is the big thing about boot is the ability to customize in your own commands and the encapsulation it gives them and each part of the compile process

thheller15:10:32

yes as long as you stay within boot that is true

vigilancetech15:10:13

but from what I can tell there's been very little attention in that community given to keeping a REPL going for a long time and I prefer being able to go directly to NPM like you're doing. Also I'm sick of having to restart the JVM each time I tinker with the build.boot file

thheller15:10:46

well yeah boot fundamentally is a build tool on its own. a REPL is a long running process which doesn't exactly fit into the whole build tool theme where each task runs after each other but is supposed to finish

vigilancetech15:10:43

it seems like the whole hoplon/boot community de-emphasizes needing a REPL but I'm too much of a noob to really be able to do without one (and I'm dealing with a fairly sophisticated existing application code base which essentially makes my work more akin to reverse-engineering; a task that's virtually impossible without one)

thheller15:10:13

there is https://github.com/degree9/boot-shadow written by @flyboarder who is also involved in hoplon I think

thheller15:10:16

maybe he can help

thheller15:10:35

but I have no idea how any of it works either and there have been issues in the past

vigilancetech15:10:11

Okay. I've talked to him before about other issues. I'll ask him for more details. Thanks.

vigilancetech16:10:12

@thheller I've commented out the :build-hooks, renamed my hop.cljs to hop.clj, and tried to "run" foo and I'm still getting

failed to load namespace: build.hop

thheller16:10:58

if you still have [hoplon :refer hoplon] then its because it can't load that

thheller16:10:16

try running shadow-cljs clj-repl instead and (require 'build.hop)

vigilancetech16:10:42

yeah, looks like you're right:

[12:0]~shadow.user=> (require 'build.hop)
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec:
In: [1] val: ((:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon])) fails spec: :clojure.core.specs.alpha/ns-form at: [:args] predicate: (cat :docstring (? string?) :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses),  Extra input
 #:clojure.spec.alpha{:problems [{:path [:args], :reason "Extra input", :pred (clojure.spec.alpha/cat :docstring (clojure.spec.alpha/? clojure.core/string?) :attr-map (clojure.spec.alpha/? clojure.core/map?) :clauses :clojure.core.specs.alpha/ns-clauses), :val ((:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon])), :via [:clojure.core.specs.alpha/ns-form], :in [1]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x780884b2 "[email protected]"], :value (build.hop (:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon])), :args (build.hop (:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon]))}, compiling:(build/hop.clj:12:1) 
[12:0]~shadow.user=> 

vigilancetech16:10:33

extra input? Sounds like a parens mismatch or something

vigilancetech16:10:53

or it doesn't like a doc string?

thheller16:10:35

it doesn't like [hoplon :refer hoplon]

thheller16:10:43

:refer is always a collection of symbols

thheller16:10:55

but the hoplon ns doesn't exist in the first place

thheller16:10:21

[hoplon :refer (hoplon)] would be correct use of :refer but hoplon is still invalid

vigilancetech16:10:17

does it matter if the symbols are a list or a vector? Cuz other than in some of your code I seem to recall only seeing them in a vector

thheller16:10:55

I personally always use lists for :refer but it can be a vector too yes

flyboarder16:10:17

@vigilancetech @thheller just going through the chat, what can I help with?

vigilancetech16:10:07

@flyboarder I was trying to swap out boot for shadow-cljs on a project so I can take mostly take advantage of the latest cider release

vigilancetech16:10:17

a hoplon project

vigilancetech16:10:34

(but also because of some other features I like in shadow)

flyboarder16:10:56

Ah I have recently migrated all my work to shadow-cljs via the boot task mentioned above, I have not used cider so I am not sure how that would fit in

vigilancetech16:10:20

well, its supposed to be fairly easy once you can get the shadow cljs repl fired up

vigilancetech16:10:39

does your boot task do the shadow watch also?

flyboarder16:10:42

that was super easy to get going, @thheller has done a great job

flyboarder16:10:59

No I let boot handle the watch command

flyboarder16:10:14

I have some example code, one sec

vigilancetech16:10:16

okay, cuz I think shadow has to do the watch to get the repl

flyboarder16:10:29

you can launch the repl without watch

thheller16:10:43

no you can't?

vigilancetech16:10:12

well, doesn't watch inject the repl stuff into your project (so you connect to the browser with your repl client)?

flyboarder16:10:19

shadow-cljs binary might need it but boot can handle that for you

flyboarder16:10:30

boot watch shadow/server

flyboarder16:10:40

will keep the server running

flyboarder16:10:03

boot watch shadow/compile or boot watch shadow/release

vigilancetech16:10:43

what I was thinking is to not use boot at all, but just get shadow to "preprocess" my source files with hoplon, but hoplon doesn't appear to be/have a namespace so shadow run barfs

flyboarder16:10:43

I am just going to show you all the relevant shadow stuff for how I do it, shadow file above^

flyboarder16:10:39

these tasks wrap boot-nodejs and boot-hoplon and run the boot-shadow task

flyboarder16:10:14

thats basically it I think

vigilancetech16:10:21

have you been using the shadow cljs repl?

vigilancetech16:10:38

okay, thanks. I got some stuff here to digest 🙂

flyboarder16:10:10

once you have the server running with the compilation environment, you can use the shadow-cljs binary to connect to the repl-server

thheller16:10:25

I have absolutely no clue what is happening in this code

flyboarder16:10:00

@thheller which part can I explain better?

thheller16:10:18

(comp (shadow/compile :build :client)) what is this?

thheller16:10:28

thats not a valid shadow-cljs API anywhere?

flyboarder16:10:58

shadow/ is from boot-shadow it wraps the shadow-cljs library and calls it as a boot task

flyboarder16:10:39

boot has a “build pipeline” which is represented here

vigilancetech16:10:02

@flyboarder can you describe the reasoning behind your decision to use boot to drive shadow rather than just trying to run the hoplon pre-process from shadow and eliminate boot completely?

thheller16:10:54

@vigilancetech the hoplon pre-process is a boot task. you simply cannot run that from shadow-cljs.

flyboarder16:10:18

Sure, we have a 1 language rule, everything on the development side is done in clojure (boot) and everything within the project compiles to clojurescript (nodejs/hoplon/feathers)

flyboarder16:10:47

Agreed^ boot tasks cannot run in other clojure contexts

flyboarder16:10:01

as it relies directly on the custom environment shown above

vigilancetech16:10:04

so hoplon is really complected with boot

flyboarder16:10:18

hoplon is just clojurescript

flyboarder16:10:34

boot-hoplon depends on boot

vigilancetech16:10:09

ok, so boot-hoplon is complected with boot. Hoplon proper is basically a cljs library. Is that essentially correct?

flyboarder16:10:26

all things regarding boot and hoplon aside, this comes down to a problem of preprocessing

vigilancetech16:10:28

and boot-hoplon is the preprocessor

flyboarder17:10:31

boot-hoplon was its own project, we bundled it with hoplon to simplify dependencies because it does nothing if you never load the code

flyboarder17:10:50

the preprocess task in boot-hoplon is old and uses phantom.js

flyboarder17:10:53

so the question becomes how do I preprocess using shadow-cljs

flyboarder17:10:06

my solution is you dont, you use boot for that

vigilancetech17:10:54

but it seems, at first glance, that hoplon's pre-processing is so simple.

vigilancetech17:10:17

is there much more to it than that?

vigilancetech17:10:07

isn't the html that's generated (by hoplon-boot reading the ^{:hoplon/page "index.html"}) just a launcher for the js that's created by the hlisp, etc...? https://github.com/hoplon/hoplon/wiki/HLisp

flyboarder17:10:17

not quite, HLisp is really just the dom stuff

flyboarder17:10:09

the preprocessing happens by using an internal script to load the app in phantom and grab a snapshot of the dom

flyboarder17:10:01

there is also the convenience macros which do some file level code manipulation

flyboarder17:10:11

my experience with shadow has been to ignore the file generating that boot-hoplon does because it really doesn’t align with how shadow handles the directory structure

flyboarder17:10:37

so I just use a static html file

vigilancetech17:10:36

yeah, that seems similar to the index.html I've found that hoplon/boot creates by default. Thanks for explaining the purpose of the prerendering. That was going to be my next question.

flyboarder17:10:23

yeah it’s best to just use hoplon as a cljs lib with shadow, which work really well it’s just you need to manually configure a bunch of things

flyboarder17:10:04

I am sure there is probably a perfect configuration of shadow that would let boot-hoplon do its thing but I have yet to find it

flyboarder17:10:10

Also when boot does the converting from .hl to .cljs its slow…. like reeeeaaalllly slow….

vigilancetech17:10:27

I guess the reason why I'm digging so hard on this is because my eventual goal would be to use hoplon from lumo

flyboarder17:10:18

yeah so just use it as a cljs library and dont use .hl or the (page) macro

vigilancetech17:10:37

to jettison the JVM/transcompile situation completely

flyboarder17:10:43

that will work well and wont be build tool specific

flyboarder17:10:06

yeah you could drop boot entirely if you wanted

vigilancetech17:10:29

ok, thanks for the insight.

vigilancetech17:10:23

have you looked into using hoplon from lumo at all yet?

flyboarder17:10:30

I like the idea of just using javascript, but the problem I see is already happening in the js ecosystem, we get all these tools that kinda do the same thing

flyboarder17:10:49

yeah a bit, no working projects tho

flyboarder17:10:19

like the thing thats awesome about boot is that it’s an environment for building things not a build tool

flyboarder17:10:04

I think boot will get ported over eventually tho

vigilancetech17:10:03

think boot will get ported over to cljs?

flyboarder17:10:17

yeah the problem there is the classpath

flyboarder17:10:33

solve that for me and I’ll put in the time to port the rest

👍 8
richiardiandrea21:10:55

Btw lumo has a translation layer from file (node modules) to classpath so maybe that port is not that far away...at the end of the day it is files right?

👍 4
richiardiandrea21:10:51

Well and files in zip files :)

vigilancetech17:10:34

that would be cool and a significant step to getting into lumo. I'll keep it in mind for my almost non-existent spare time!

flyboarder17:10:42

yeah me too, if you need help with a boot/shadow setup let me know, it works really well

vigilancetech17:10:25

thanks, I probably will. Actually looking at my app, it already doesn't use *.hl/(page) and it compiles. I just can't figure out how to get the shadow web server to serve it yet. It does have the ^{:hoplon/page "index.html"} metadata on (ns) however. The build.boot does call (hoplon) in the "develop" task tho.

vigilancetech17:10:42

*it compiles with shadow

flyboarder18:10:56

ah so for my projects, I start a server with boot-nodejs, because by backend is cljs

👍 4
flyboarder18:10:11

and my backend serves my frontend

flyboarder18:10:37

you could drop in any static server as a boot task

kanwei18:10:58

@thheller yup fixed in beta2 as expected

👍 4
kanwei18:10:02

thanks for looking into it

Bravi23:10:57

hi everyone. is it correct to put [binaryage/devtools “0.9.4”] in my dependencies? will this be automatically removed in release build?

Bravi23:10:14

thank you