This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-11
Channels
- # announcements (1)
- # aws (2)
- # beginners (43)
- # calva (7)
- # cider (5)
- # cljs-dev (1)
- # cljsrn (2)
- # clojure (68)
- # clojure-android (10)
- # clojure-conj (2)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-spec (3)
- # clojure-uk (128)
- # clojurescript (10)
- # core-async (47)
- # cursive (32)
- # datomic (35)
- # events (1)
- # fulcro (24)
- # funcool (2)
- # graphql (2)
- # jobs (3)
- # juxt (2)
- # leiningen (3)
- # luminus (1)
- # off-topic (7)
- # om (1)
- # onyx (2)
- # pedestal (32)
- # perun (2)
- # portkey (2)
- # re-frame (4)
- # ring-swagger (2)
- # rum (3)
- # shadow-cljs (137)
- # spacemacs (4)
- # testing (3)
- # tools-deps (101)
- # uncomplicate (2)
- # unrepl (5)
- # vim (2)
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
@vigilancetech you can only run Clojure functions but you created a .cljs
file. must be either .clj
or .cljc
I just looked over the hoplon impl and it pretty much seems to require boot
to work at all
@kanwei did you test clojure-1.10 beta2 yet? I assume it fixes the issue but confirmation would be nice
@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?
@vigilancetech well its important to look for the details
> :hoplon/page metadata will tell boot hoplon task to generate the HTML file for the given namespace
I don't know anything about the architecture that hoplon wants but it looks to me that is requires boot
@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.
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
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
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
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
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)
there is https://github.com/degree9/boot-shadow written by @flyboarder who is also involved in hoplon I think
but I have no idea how any of it works either and there have been issues in the past
Okay. I've talked to him before about other issues. I'll ask him for more details. Thanks.
@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
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 "clojure.spec.alpha$regex_spec_impl$reify__2436@780884b2"], :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=>
extra input? Sounds like a parens mismatch or something
or it doesn't like a doc string?
got it
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
@vigilancetech @thheller just going through the chat, what can I help with?
@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
a hoplon project
(but also because of some other features I like in shadow)
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
well, its supposed to be fairly easy once you can get the shadow cljs repl fired up
does your boot task do the shadow watch also?
that was super easy to get going, @thheller has done a great job
No I let boot handle the watch command
I have some example code, one sec
okay, cuz I think shadow has to do the watch to get the repl
you can launch the repl without watch
well, doesn't watch inject the repl stuff into your project (so you connect to the browser with your repl client)?
shadow-cljs binary might need it but boot can handle that for you
boot watch shadow/server
will keep the server running
boot watch shadow/compile
or boot watch shadow/release
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
I am just going to show you all the relevant shadow stuff for how I do it, shadow file above^
ok, thx
these tasks wrap boot-nodejs and boot-hoplon and run the boot-shadow task
thats basically it I think
have you been using the shadow cljs repl?
yep, the tricky parts all here https://github.com/degree9/enterprise/blob/master/src/degree9/repl.cljs
okay, thanks. I got some stuff here to digest 🙂
once you have the server running with the compilation environment, you can use the shadow-cljs binary to connect to the repl-server
@thheller which part can I explain better?
shadow/
is from boot-shadow
it wraps the shadow-cljs library and calls it as a boot task
boot has a “build pipeline” which is represented here
@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?
@vigilancetech the hoplon
pre-process is a boot task. you simply cannot run that from shadow-cljs.
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)
Agreed^ boot tasks cannot run in other clojure contexts
as it relies directly on the custom environment shown above
so hoplon is really complected with boot
not at all
hoplon is just clojurescript
boot-hoplon depends on boot
ok, so boot-hoplon is complected with boot. Hoplon proper is basically a cljs library. Is that essentially correct?
all things regarding boot and hoplon aside, this comes down to a problem of preprocessing
and boot-hoplon is the preprocessor
not really
boot-hoplon was its own project, we bundled it with hoplon to simplify dependencies because it does nothing if you never load the code
the preprocess task in boot-hoplon is old and uses phantom.js
so the question becomes how do I preprocess using shadow-cljs
my solution is you dont, you use boot for that
but it seems, at first glance, that hoplon's pre-processing is so simple.
is there much more to it than that?
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
not quite, HLisp is really just the dom stuff
the preprocessing happens by using an internal script to load the app in phantom and grab a snapshot of the dom
there is also the convenience macros which do some file level code manipulation
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
so I just use a static html file
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.
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
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
Also when boot does the converting from .hl to .cljs its slow…. like reeeeaaalllly slow….
I guess the reason why I'm digging so hard on this is because my eventual goal would be to use hoplon from lumo
yeah so just use it as a cljs library and dont use .hl or the (page)
macro
to jettison the JVM/transcompile situation completely
that will work well and wont be build tool specific
yeah you could drop boot entirely if you wanted
ok, thanks for the insight.
have you looked into using hoplon from lumo at all yet?
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
yeah a bit, no working projects tho
like the thing thats awesome about boot is that it’s an environment for building things not a build tool
I think boot will get ported over eventually tho
think boot will get ported over to cljs?
yeah the problem there is the classpath
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?
Well and files in zip files :)
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!
yeah me too, if you need help with a boot/shadow setup let me know, it works really well
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.
*it compiles with shadow
ah so for my projects, I start a server with boot-nodejs, because by backend is cljs
and my backend serves my frontend
you could drop in any static server as a boot task