Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multimethods #4

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open

Multimethods #4

wants to merge 41 commits into from

Conversation

malcolmsparks
Copy link
Collaborator

Tested against the JUXT website.

This trival change is to support holding on to the original krei file for passing to
build components, so debugging information has access to the krei-file
resource URL.
This is a backward compatible change that retains the existing
functionality while preparing the way for new 'providers' of build
functionality, such as shadow-cljs and JIT image resizing.
@malcolmsparks
Copy link
Collaborator Author

I forgot to mention that the result of the init! call will get passed to the notify! calls. The only rationale so far for doing this is that you were hardcoding ./target in the Sass builder. I thought I'd fix that for you.

This is a new design whereby the build configuration is passed to
krei/kick, for example, from an Aero configuration.

```clojure
  {:default {}
   :dev
   {:kick/builder
    {:kick.builder/target "target"

     :kick/sass {:sources ["public/app.scss"]}

     :kick/figwheel {:builds [{:id "main"
                               :figwheel {:on-jsload "edge.main/init"}
                               :compiler {:main edge.main
                                          :output-to "public/edge.js"
                                          :output-dir "public/edge.out"
                                          :asset-path "/public/edge.out"}}]}}}}
```

The watch and returning close function correspond directly to
`integrant.core/init-key` and `integrant.core/halt-key!`, although
there is no integrant dependency from krei/kick

IMPORTANT: Since krei can _no longer build independently_ the
production build (called by main) has been removed entirely and
consuming projects now need to provide this functionality.
@malcolmsparks
Copy link
Collaborator Author

OK, this is now ready to review. There is more context and design rationale in the individual commit messages. I've gone for a BYOD (bring your own dependency) policy for the individual providers, and none are therefore privileged. I'm planning to add shadow-cljs in due course. The point of this BYOD policy is to avoid dependency bloat (avoid paying for the cost of dependencies you don't use).

One strange thing is that Edge seems to 'work' (build the sass) without seeming to bring in

deraen/sass4clj {:mvn/version "0.3.1"}

(not sure what's going on there, but it doesn't affect this review).

Copy link
Owner

@SevereOverfl0w SevereOverfl0w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor things. Overall looks good.

I don't see a way to perform a one-time build of clojurescript with this system, that would be a big gap.

[io.dominic.krei.alpha.impl.debounce :as krei.debounce]))
[clojure.java.classpath :as classpath]
[clojure.string :as string]
[clojure.tools.logging :as log]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tools.logging isn't a dependency of the project. So this commit only compiles by coincidence.

(map #(update-in % [:compiler :output-to] (comp str target-relative))))
krei-files)}))
(build-sass)
;; @dmc what's this? still something we need?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which this? :p Presuming you mean (run! dirwatch/close-watcher krei-builders) it takes care of shutting down the file watchers.

```
----  Exception    ----
  No implementation of method: :-find-sources of protocol: #'cljs.closure/Compilable found for class: cljs.build.api$inputs$reify__6688
----  Exception Stack Trace  ----
java.lang.IllegalArgumentException: No implementation of method: :-find-sources of protocol: #'cljs.closure/Compilable found for class: cljs.build.api$inputs$reify__6688
 at clojure.core$_cache_protocol_fn.invokeStatic (core_deftype.clj:583)
    clojure.core$_cache_protocol_fn.invoke (core_deftype.clj:575)
    cljs.closure$eval45293$fn__45307$G__45284__45314.invoke (cljs_closure.clj:475)
    cljs.closure$build.invokeStatic (cljs_closure.clj:2707)
    cljs.closure$build.invoke (cljs_closure.clj:2672)
    cljs.build.api$build.invokeStatic (api.clj:208)
    cljs.build.api$build.invoke (api.clj:189)
    figwheel_sidecar.components.cljs_autobuild$cljs_build.invokeStatic (cljs_autobuild.clj:28)
```
@@ -0,0 +1,36 @@
;; Suggested dependencies:
;; thheller/shadow-cljs {:mvn/version "2.0.123"}
;; As there's a bug in tools.deps.alpha (TDEPS-26), also add:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

malcolmsparks and others added 6 commits September 17, 2018 17:38
Syntax has changed - see Edge
This makes developing with figwheel possible without loading kick in the
context of a project.
This is a convention set by Asciidoctor.
malcolmsparks and others added 18 commits October 3, 2018 13:28
This BINARY INCOMPATIBLE change is to allow finer control of the
target filename. This is required by Edge to place generated CSS files
into a directory named 'public'.

Given the fast-moving alpha status of Kick, with the ease of fixing its
(few) current dependants, simplicity has been chosen over binary
compatibility.
This prevents a bug which happens as a combination of:
- Kick being a git dependency
- Kick allowing users to bring their own dependencies
- tools.namespace loading all namespaces which are in directories

This guard prevents the namespace from exploding when required without
the required dependency present.  This is not completely ideal, due to
the confusion it will push down onto users when namespaces unexpectedly
don't work.
This causes a compilation error when starting a clojurescript REPL, as
figwheel-main attempts to compile the code in watch-dirs then.
You need the :output-dir to be produced when source maps are enabled.
clj no longer produces a clojure.libfile, and kick needs this to remove
itself from the classpath when using figwheel-main.  Newer versions of
clj instead provide a clojure.basis, which is vaguely the same as the
old basis.

Supports both in order to handle the transition period of updates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants