-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add ClojureScript support #524
base: master
Are you sure you want to change the base?
Conversation
aeac036
to
38e14b1
Compare
When you get around to this:
I recommend adding new templates under The search order can then be:
It would be simpler to do the per-dialect to default fall back on a per-tier basis but that could cause a user's (Clojure) template to take precedence over the default ClojureScript one, which is not what we want. This ensures the new template machinery is purely additive and will not break anyone's existing templates, and it would also allow for |
An additional thought: when the dialect is plumbed into the creator component, it would be a good idea to add
|
1cd09ad
to
1677e9e
Compare
@tengstrand I added a couple of notes to your latest commit: there are a couple more places that need The new |
doc/templates.adoc
Outdated
@@ -107,8 +110,10 @@ This command uses the following template files to generate the new base: | |||
* `templates/bases/deps.edn` -> the new base's `deps.edn` file | |||
* no variable substitutions are provided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the deps.edn
files that currently say no variables substitutions are provided
need to be updated to say: {{dialect}}
-- the dialect, e.g. "cljs" (from the create component command)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look again and check if I got it right this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like templates/components/interface.clj
is missing the {{dialect}}
variable in the doc page.
I intended the list of variables to be indented bullets under each filename bullet but AsciiDoc didn't treat *
(<space>*
) the same as Markdown does -- should those variable lines all be **
bullets? Not sure how AsciiDoc handles that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right — I hadn't noticed that! I've now updated the sub-bullets to use ** as intended and also fixed the other issue.
When we read the source files, we are interested in the require and import statements in the namespace declaration. We use these statements to determine which interface and library dependencies each component has. When there are reader conditionals within these statements, and the workspace is configured to use both `clj` and `cljs` dialects, we need to include imports and requires for both `clj` and `cljs`. We read the source files using edamame. We can pass an option (`:features`) to edamame to choose between reader conditionals when reading the source files. However, when passing both `:clj` and `:cljs` to edamame, it takes the first match from the conditional instead of both. Luckily, it has another option, `:read-cond`, and it accepts a function that receives the complete conditional statement, and we can decide what to return in place of the conditional. I implemented a function to read both `clj` and `cljs` parts of the reader conditional when both `clj` and `cljs` dialects are enabled for the workspace. Otherwise, I use `:read-cond :allow` to rely on edamame's default implementation.
… the workspace structure.
…opment, which is also included in the test command, when there are no tests to run.
…doc sub bullet syntax.
…entence on single lines. Fix sentence. Remove note.
c2f0f7b
to
fe9de5d
Compare
(->> test-brick-names | ||
(mapcat brick-name->namespaces) | ||
(filter clj-namespace?) | ||
(map :namespace) | ||
(into [])))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(->> test-brick-names | |
(mapcat brick-name->namespaces) | |
(filter clj-namespace?) | |
(map :namespace) | |
(into [])))) | |
(into [] | |
(comp (mapcat brick-name->namespaces) | |
(filter clj-namespace?) | |
(map :namespace)) | |
test-brick-names))) |
(->> (:test namespaces) | ||
(filter clj-namespace?) | ||
(map :namespace) | ||
(into [])))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(->> (:test namespaces) | |
(filter clj-namespace?) | |
(map :namespace) | |
(into [])))) | |
(into [] | |
(comp (filter clj-namespace?) | |
(map :namespace)) | |
(:test namespaces)))) |
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:
clj
,cljs
, andcljc
files in their source files.workspace.edn
will have a new config option called:dialects
to let users restrict dialects in their workspace.poly
tool will also readcljs
files, in addition to thecljc
andclj
files, ifcljs
is enabled in the current workspace.shadow-cljs
or similar for testing.TODOs:
:dialects
config 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.cljc
files will be considered as valid code sources.clj
files using:require-macros
.package.json
files and include those dependencies in the libs command.package.json
if they use NPM dependencies.create
command to support creating ClojureScript bricks and projects.clj
sourcesclj
andcljc
sourcesclj
,cljs
, andcljc
sourcescljs
sourcescljs
source and an accompanyingclj
source with macro definitions. Thecljs
file should require aclj
file usingrequire-macros
. There should be additionalclj
files that the mainclj
file that contains the macros should require regularly.:dialects
key