polylith
polylith copied to clipboard
Add ClojureScript support
This PR adds ClojureScript support to the poly tool. There is a longer discussion explaining the rationale behind here.
Some of the decisions to keep the scope of the changes small without compromising the overall value:
- All components, bases, and projects live under a single Polylith monorepo regardless of the dialects used within them.
- The components and bases can mix
clj,cljs, andcljcfiles in their source files. - The
workspace.ednwill have a new config option called:dialectsto let users restrict dialects in their workspace. - The
polytool will also readcljsfiles, in addition to thecljcandcljfiles, ifcljsis enabled in the current workspace. - A component or base with a modified file will be marked as changed regardless of the dialect. As a result, all dependent components will be marked as indirectly changed.
- We decided to leave testing out of scope and rely on
shadow-cljsor similar for testing. - The Polylith team will provide a simple development setup for a mixed (or ClojureScript only) workspace using shadow-cljs. The users can choose their own way to create a classpath and start their own clj/cljs REPLs.
TODOs:
- [x] Add dialects to workspace config
- The
:dialectsconfig option works as follows. The user can define a set of dialects. Valid dialects are:"clj"and"cljs". If the dialects option is not defined or if it's an empty set, it will be treated as if it is#{"clj"}. This is necessary for backward compatibility. If it is#{"clj", "cljs},.clj,.cljs, and.cljcfiles will be considered as valid code sources.
- The
- [x] Handle require-macros case
- ClojureScript files can require macros from
cljfiles using:require-macros.
- ClojureScript files can require macros from
- [x] Ensure the default test runner works without breaking
- The external test runner will need an update for ClojureScript-enabled workspaces.
- [ ] Handle NPM dependencies in the libs command
- Read the
package.jsonfiles and include those dependencies in the libs command. - Each brick and project should have a
package.jsonif they use NPM dependencies.
- Read the
- [ ] Update the
createcommand to support creating ClojureScript bricks and projects. - [x] Add an example project under examples with corner cases.
- Project should contain:
- A component with only
cljsources - A component with
cljandcljcsources - A component with
clj,cljs, andcljcsources - A component with only
cljssources - A component with a
cljssource and an accompanyingcljsource with macro definitions. Thecljsfile should require acljfile usingrequire-macros. There should be additionalcljfiles that the maincljfile that contains the macros should require regularly.
- A component with only
- Project should contain:
- [ ] Create a sample development environment & projects with shadow-cljs
- [x] Update the documentation
- Explain
:dialectskey - Explain how to work with ClojureScript (new section)
- Explain
- [ ] Update the FAQ for ClojureScript support (gitbook)