-
Notifications
You must be signed in to change notification settings - Fork 486
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
Module with declare and import #5968
Conversation
d4b6599
to
a73e2e3
Compare
Hey there 👋 Looks like this is going to require a new cup of coffee for the day 😅 I realize it might not be a simple task to split this in logical increments, but could we offer some guidance here to help people who haven't followed development take a closer look?
|
Added this to my todo today. |
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.
First off, thank you for working on this! This is a lot closer to being mergeable compared to the first few efforts, but I still have some comments that I would like to see resolved, and I've done a first round of review covering those.
A brief summary of my findings:
-
I'm concerned that everyone is working with a different set of definitions for what a new module is, and I think we need to have a chat offline as a group to get aligned on this.
-
I'm worried there's too many differences in between native/non-native components and local/non-local modules that is leaking into the Loader implementation. Refactoring to make these constructs behave more identically and remove specialized knowledge from the Loader is likely in order.
-
I find the amount of code added for passing around Flow config strings fairly alarming; we should make changes to convert those strings into ASTs as soon as we can and pass the AST around instead.
More detail about the above (and some other small comments and nits) are in the comments below.
I'll do a second final review round after the big bullet points here are cleared up.
component/component_provider.go
Outdated
@@ -93,8 +93,8 @@ type Info struct { | |||
// this component depends on, or is depended on by, respectively. | |||
References, ReferencedBy []string | |||
|
|||
Registration Registration // Component registration. |
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.
Can we not remove this field? I think it's an important part of this API to be able to know what the arguments/exports types of a builtin component are, as this will come into play in the future when we explore plugins and other tooling around components.
Keeping this the same also means we'll have even more consistency between native and non-native components, which I find ideal.
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.
But the registration does not have the types? It has "Args Arguments" and "Exports Exports" which are already inside of the Info struct as "Arguments Arguments" and "Exports Exports". Removing the Registration field removes this repetition and the "Build" function (which should not be there because retrieving info about a particular instance of a component to create a new component of the same type should not be a correct way to create a component)
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.
But the registration does not have the types?
The registration does have the types; it holds the zero value for the arguments and exports types of a given component, and it's used for unmarshaling. In the future, those fields could also be used for additional validity checking without instantiating components (e.g., #3844).
(which should not be there because retrieving info about a particular instance of a component to create a new component of the same type should not be a correct way to create a component
I agree, but I also didn't suggest that the registration from this API would be the way to construct new components; just for the full set of information associated with a component.
Let me think about this a bit. This is a public API, which I think we need to be cautious about changing. I need to consider what the future implications are for not including the registration in this API, particularly around whether that limits us with the web UI or any other future services.
We should change APIs deliberately and not to make another feature easier. So if we're going to change this API, we should make sure it's the right change.
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.
In builtin component, the args and exports are initialized by the registration when the node is created. That means that they also have the types and that we don't need the registration object.
Also registration is currently something specific for the builtin components. It is not used by the custom components so that would require some workaround to keep it in the component_provider info
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.
I went through only part of this PR so far. I think we need to put more work into making this readable - I'm worried it will make maintenance in the future much harder. Let's start with adopting the new naming convention and adjusting the logic around nested imports as discussed recently. Let me know when it's ready to review further!
New modules with import and declare keywords.
Old modules are left untouched by the changes.
Fixes #5547
Note for reviewers
This PR is pretty big and not easy to review but we wanted to have most of the functionalities on one branch to be sure that the approach was the correct one. Follow-up PRs will be made to handle nits, missing functionalities, and refactors which are no blockers for the PR.
Description
A description of the functionality can be found here.
Most relevant code changes:
-Previously only componentNodes could have dependants. Now customComponentNode and importConfigNodes can also have dependants. They implement the interface NodeWithDependants.
TODO (possibly in following PRs)
PR Checklist