Some thoughts after the devtools.fm podcast episode #10064
gioragutt
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For those who've not heard it yet, you can find it here: https://devtools.fm/episode/29
Visibility
The point of generator visibility has been brought up during the episode, and I had an idea come to mind:
Gather telemetry (locally and/or in nx cloud) about generator usage, invocations of different generators, and what flags are used.
This data can be exposed and used in different tools, such as cli completion, have a "recently/most used" section in the generators list in NxConsole, and more.
EDIT: Visibility #2
With "Negative Configuration" becoming a goal of NX, I think that it's important to make sure that visibility of what targets are available for different projects is crucial.
Much like
gradle tasks
which lists what tasks are available for a project, something likenx targets <project name>
would be nice.In general, I think that how gradle works is very similar to how NX works (in terms of cli usage, tasks===targets, etc), so I think gradle should be a great source of inspiration for NX.
Exposing metadata to tooling
When talking about NxConsole and how there are even community plugins for JetBrains products, I remembered that there's work now in NxConsole to support local plugins.
What came to mind is that everything in Nx works nicely because it builds on the fact that everything exposes metadata which enables tooling to operate well - every generator, every executor, every project, each of those has metadata that enables making very versatile tooling.
Why wouldn't NX have a mechanism for exposing such metadata that NX is aware of, so that other tools (NxConsole, f.e) will build on top of it?
Such an example would be listing all the generators usable within the workspace. As far as I can see, NxConsole does a lot of work to scan which generators are available, read their metadata, etc. If the nx core will expose this metadata (via cli or a method exposed as a library), it will benefit such external tools greatly.
This will cut down on the duplicate work said tools will have to do, and it will help reduce differences between tools that happen due to differences in the implementation of calculating this metadata.
This same method of exposing metadata that NX is aware of can help create more advanced tooling easily.
Generator "shortcuts" in IDEs
In VSCode, the NxConsole extension adds "Nx generate" and "Nx run". As far as I can see,
Nx run
is pretty thorough, but there's a small addition I think can do good for "Nx generate".When you
Nx generate
from some file, it'll know to fill "project" and "path" in the generator form, if these exist.However, there are times when generators just do not name the fields that way. One example is
componentPath
in@nrwl/react:component-cypress-spec
.I think that there should be a way, in
schema.json
of generators (and executors as well, because why not) to declare metadata about the field.Much like
"$source": "projectName"
in the following schema:It'll be cool if the same metadata can be used to fill "path" if available, regardless of the name of the field.
In the future, if there'll be more such fields that can be filled (f.e target names), the same convention can be used.
EDIT2: Generators/Executors should also export
normalizeOptions
One case I often have when reusing the official nrwl generators (and the same is true for custom generators we write, for that matter), I want to make sure that I'm operating correctly on the output of the generator.
Things like file paths may depend on input to the generator, which is often applied in the
normalizeOptions
of the generator.Having those methods exposed (alongside the generators themselves) will allow developers using the official generators to write code that is more resistant to decisions done by the internals of generators.
These are just some things that went through my head while I was listening, which IMO can help my NX's experience even better.
Beta Was this translation helpful? Give feedback.
All reactions