[Feature] Add support for different Clojure platforms. #168
Replies: 9 comments 5 replies
-
|
Hi Nikolas! Thank you for working on this difficult problem. With that said, we lack a clear problem formulation here and it would be nice if you could elaborate a bit more around what problem you are trying to solve before jumping into the implementation. This is what we came up with at today's meeting:
Polylith tries to solve a number of problems, like code sharing and to speed up the feedback loop. A lot of that is already addressed by the dynamic nature of frontend development. For example, Polylith solves sharing by introducing components and interfaces that are used from projects, by combining a set of bricks. The equivalent to Polylith projects in e.g. We looked at the production frontend codebase at Furkan's company and saw:
As you can see, only 15% of the codebase could partially benefit from Polylith. We also don't have a clear idea about how to fit in the We think that Polylith is not a good fit for a frontend codebase and we believe that solutions should come from a need or a problem that people currently have in their workflow. We are always open for suggestions and willing to discuss them. It would be helpful if you could elaborate more on which problems you are trying to solve. We think the main problem you are trying to solve is about sharing code between backend and frontend via The Polylith Team |
Beta Was this translation helpful? Give feedback.
-
|
I'm interested in using polylith for a shadow-cljs based Node.js project, just as a point of anecdotal interest. I imagine that many of the same advantages accrued from using it with a Java-based project will apply for a project like this as well. |
Beta Was this translation helpful? Give feedback.
-
|
The poly tool is already prepared to support multiple languages. If you go to the core namespace of poly-cli and read the comment there, you will see the steps that is performed to read a workspace: The The idea here is that a new language, e.g. Kotlin, can be supported by adding a As I see it, the path forward for you would be to implement a Why I think it’s a good idea to keep each language in its own workspace:
|
Beta Was this translation helpful? Give feedback.
-
|
The front-end code re-use story is more clear when an app targets different platforms. E.g. using So being able to using the same deps tool for a monorepo setup in front-end would be useful. Building for these platforms is indeed more complicated, but that can be left to user space. |
Beta Was this translation helpful? Give feedback.
-
|
For an example codebase take a look at DevHub: https://github.com/devhubapp/devhub It's a JS app and they use typescript to handle the builds, but you can see how much more logic is split into separate packages to accommodate re-use across platforms. |
Beta Was this translation helpful? Give feedback.
-
|
I haven't seen my use cases mentioned, so here goes: I've been using Malli models as a single source of truth for both front and back ends in a monorepo. I template component code for both the front and back ends from the models.
I stole my monorepo layout ideas from metosin's reitit repo: I started out using lein-parent for common dependency management, but switched to tools.deps as soon as I could. I use cljc files as much as possible to make pure functions testable on the JVM for simplicity's sake. My back end code already has interfaces because I use Duct. I wish Poly would embrace Duct because it not only defines components, it allows you to reason about them ™️ . I recognize that there are philosophical differences between the two, but only two tools I use have ever demanded interfaces around components for abstraction purposes.I wish one could provide tooling over the other. Would I like tooling to help me keep my garden of EDN clean? I certainly would. There's a lot of cognitive load in the config stack which i would love to outsource to a tool. What would I like most from Poly? A shadow-cljs project type and clj / cljc / cljs agnosticism. Thanks for making Poly even though I can't currently use it. It has given much food for thought. |
Beta Was this translation helpful? Give feedback.
-
|
I second @colliderwriter's sentiments. However I don't think the Moving to At the moment I can't use I would much prefer |
Beta Was this translation helpful? Give feedback.
-
|
FYI. We have made another proposal where we discuss how to best support ClojureScript, and it should be a good base for adding support for other Clojure dialects in the future. |
Beta Was this translation helpful? Give feedback.
-
|
I'm closing this discussion in favor of #525 where we're continuing the conversation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been thinking for a while on how to add support for different platforms (Clojurescript, cljc or any other platform that Clojure can run now or in the future) to the poly tool, and I (hopefully) came up with a suggestion that will not end up as a breaking change or an infinite amount of maintenance.
The idea is to add an additional
:platformsconfiguration inworkspace.ednand a newplatform:<insert_platform>named argument.So a default workspace generated by the poly tool would look like this:
{:top-namespace "test-ws" :interface-ns "interface" :default-profile-name "default" :compact-views #{} :vcs {:name "git" :auto-add false} :tag-patterns {:stable "stable-*" :release "v[0-9]*"} :projects {"development" {:alias "dev"}} :platforms {:default :clj :clj {:bases-path "bases" :components-path "components" :projects-path "projects" :file-extension "clj"}}}:defaultkey indicates which "platform" will be used by default when theplatformargument is not given in poly tool's commands:bases-pathindicates where base bricks will be created for the given platform. (In the above case there's only one platform ("clj") which will create the brick under the./bases/directory.:components-pathindicates where component bricks will be created for the given platform. (In the above case there's only one platform ("clj") which will create the brick under the./components/directory.:projects-pathindicates where projects will be created for the given platform. (In the above case there's only one platform ("clj") which will create the brick under the./projects/directory.:file-extensiondesignates the extension of the Clojure source files that are generated within the brick. For the above example it will generateinterface.cljandcore.cljsource files (same for tests).Thus with the addition of the above
:platformskey, compatibilty would not break for the current users of the poly tool.If one would want to have a full-stack Clojure(Script) polylith workspace that would entail having a mix of .clj, .cljs and .cljc files. With the new feature he would be able to have a
workspace.ednthat would look like this:{:top-namespace "test-ws" :interface-ns "interface" :default-profile-name "default" :compact-views #{} :vcs {:name "git" :auto-add false} :tag-patterns {:stable "stable-*" :release "v[0-9]*"} :projects {"development" {:alias "dev"}} :platforms {:default :clj :clj {:bases-path "bases/clj" :components-path "components/clj" :projects-path "projects/clj" :file-extension "clj"} :cljs {:bases-path "bases/cljs" :components-path "components/cljs" :projects-path "projects/cljs" :file-extension "cljs"} :cljc {:bases-path "bases/cljc" :components-path "components/cljc" :file-extension "cljc"}}}which would result in a directory tree looking like the following:
When using reporting commands like
poly infothe output would be separated for each "platform" like so:Additionally the
platformnamed argument could be introduced in reporting/testing commands as well.For example running
poly info platform:cljwould only output information regarding bricks of thecljplatform, orpoly test platform:cljwould only run tests ofcljbricks.Furthermore, this could open up to other niceties as well, for example having a
:default-project-depskey that would be used like this:{:top-namespace "test-ws" :interface-ns "interface" :default-profile-name "default" :compact-views #{} :vcs {:name "git" :auto-add false} :tag-patterns {:stable "stable-*" :release "v[0-9]*"} :projects {"development" {:alias "dev"}} :platforms {:default :clj :clj {:bases-path "bases/clj" :components-path "components/clj" :projects-path "projects/clj" :default-project-deps {org.clojure/clojure {:mvn/version "1.10.1"} org.clojure/tools.deps.alpha {:mvn/version "0.12.985"}} :file-extension "clj"} :cljs {:bases-path "bases/cljs" :components-path "components/cljs" :projects-path "projects/cljs" :file-extension "cljs"} :cljc {:bases-path "bases/cljc" :components-path "components/cljc" :file-extension "cljc"}}}so that when a new project is created for that specific platform, the generated
deps.ednwould use the:default-project-depsmap instead of having it hard-coded within the poly tool's implementation. This is only one of different kind of utilities that can be built upon this suggested feature.A (partially at the moment) implementation of this can be found in this fork: https://github.com/DrBuchkov/polylith/tree/feature/platforms
Current status:
Beta Was this translation helpful? Give feedback.
All reactions