Add ClojureScript Support #525
Replies: 4 comments 4 replies
-
I've updated my external test runner to leverage this in a PR and I'll track dialect progress. |
Beta Was this translation helpful? Give feedback.
-
Trying it out and it's pretty good! Here's one questionable issue that I noticed so far: In a pb_mucklet component I have the following ifc.cljc: (ns bankng.pb-mucklet.ifc
#?(:clj (:require [bankng.pb-mucklet.client :as client])
:cljs (:require [bankng.pb-mucklet.server :as server]))) With the following client: (ns bankng.pb-mucklet.client
(:require [bankng.proto-tools.ifc :refer [map->proto proto->map]]
[mount.core :refer [defstate]]
[bankng.config.ifc :refer [config]])
(:import [io.grpc Grpc InsecureChannelCredentials ManagedChannel]
[bankng.mucklet LookupCharacterRequest MuckletGrpc SendMessageRequest MuckletGrpc$MuckletBlockingStub])) poly info will report |
Beta Was this translation helpful? Give feedback.
-
How will dialects affect the The existing Selmer-based template code (merged to master) still has a hardwired set of files that get generated for each Is the current thinking for this "simplest possible solution" to leave that as-is (and require users change the file extensions as needed) or that a |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
We have discussed several times how to best support ClojureScript. You can see the earlier discussion here and the follow-up discussion here. Ultimately, we decided to implement the simplest possible solution to give Polylith users the best experience and flexibility while working with ClojureScript or mixed Clojure/ClojureScript workspaces. We want to support all different kinds of use cases, but at the same time, we want to come up with a simple solution to make it easier for us to maintain and explain it quickly to newcomers. Regardless of your current choice of tooling and setup, you should be able to adopt Polylith in your projects using Clojure and/or ClojureScript.
After talking to many community members, we decided to keep Polylith simple and not introduce multiple workspace support. You can see that discussion and the reasoning behind it here. This led us to find a solution in which we consider a brick a brick regardless of whether it has Clojure, ClojureScript, or both, as sources. In our solution,
clj
,cljs
, andcljc
files can live side by side, in any combination, inside a base or component. It’s your choice whether you want to mix dialects within a brick or to have pure Clojure and ClojureScript bricks. We think it’s essential to support all these use cases.Another key decision we made, after much thorough thinking, was not to provide a default test runner for ClojureScript. In many cases, ClojureScript developers have a file system watcher running in the background, continuously running the tests in the browser and the NodeJS environment. Great tools exist around this, shadow-cljs being one of the examples worth mentioning. It will still be possible to support ClojureScript testing via external test runners.
We, as a team, try to avoid introducing breaking changes. To keep it that way, you will need to tell the poly tool to support ClojureScript explicitly. One thing that we couldn’t avoid was related to external test runners. If the ClojureScript support is enabled for a workspace, the external test runners will break because they will try to run ClojureScript tests unless they explicitly exclude them. We updated the default Clojure test runner so that it ignores ClojureScript tests. It is an easy fix, and external test runner maintainers should be able to address it quickly. Also, please note that if you do not enable ClojureScript support for the workspace, everything will work as before (including external test runners). This is how we update the default Clojure test runner to exclude
cljs
test namespaces:polylith/components/clojure-test-test-runner/src/polylith/clj/core/clojure_test_test_runner/core.clj
Lines 13 to 32 in 6ca059f
To enable ClojureScript support, you will add a new option called
:dialects
in yourworkspace.edn
. We expect a set or a vector of dialects as string values there. Currently,"clj"
and"cljs"
are the only allowed values..cljc
files are always included regardless of the dialect. If:dialects
is left out, it will be set to#{"clj"}
. You can see an example here. You can clone thecljs-frontend
branch of the Realworld example project and runclojure -M:poly
to test the ClojureScript support.We still have a few more things that we’d like to implement. Those are:
package.json
files to list NPM dependencies in thelibs
command.create
command to choose whether to createclj
orcljs
files. This may be implemented using the Selmer templating support.When ClojureScript support transitions from experimental to final state, we will update all the necessary parts of the documentation.
It would be helpful if the community tested this version. You can see the current implementation in this PR. You can already start using it by:
As always, we are looking forward to your feedback.
Joakim & Furkan
Beta Was this translation helpful? Give feedback.
All reactions