Enabling Custom written components along with the UIDL #548
Replies: 5 comments
-
The proposal is not mainly targeted on supporting custom-components. They can do basically anything, since we get access to all the files before generated into project. We can |
Beta Was this translation helpful? Give feedback.
-
@JayaKrishnaNamburu, this looks awesome! From my understanding, the proposal you make is proposing to use two sources of information in order to generate the code: (a) UIDL, (b) custom code: I wonder if we could consider the benefits of storing the reference to the custom code in the UIDL itself: I think that the benefits of the second approach are:
One of the disadvantages of that approach is that the UIDL size can grow quite a lot, but we could mitigate this aspect with both the use of our existing imports mechanism and various compression techniques. |
Beta Was this translation helpful? Give feedback.
-
Yes i agree, by making the custom code available in the UIDL. It can helps in interoperability. We can just use UIDL to communicate between two different systems, and they still get to know about the custom written code. Now, we have two things. If we should load everything in the UIDL, or refer Loading everything in UIDLPros
Cons
Using remote references in UIDL and loading at project generation time.These are just opposite for the above approach. I would say, let us support both and so we can bring in the remote loading functionality via some project plugins. So, we have two plugins at project level
In the above two approaches, we need to introduce a new attribute in UIDL like Maintaining a custom registryHere is a small POC, that i did a year back. Maintaining a custom registry --> https://github.com/JayaKrishnaNamburu/teleport-registry Every component that users write in their respective projects are available as individual packages in a custom registry. Then we don't need to make any changes to the existing solution. The registry acts as CDN and serves the components dynamically. The end solution can be a hybrid work of https://github.com/JayaKrishnaNamburu/teleport-registry + https://github.com/teleporthq/teleport-registry-packer Pros
Common issues to address
|
Beta Was this translation helpful? Give feedback.
-
I really like the idea of offering both options for Custom Components (stored in UIDL, or injected during build-time). Let's move ahead in that direction. |
Beta Was this translation helpful? Give feedback.
-
We can already achieve this using the project plugins. So, closing the discussion for now. |
Beta Was this translation helpful? Give feedback.
-
Proposal
To support external code components in the
project-generation
phase. Currently the project/component generators can understand components fromlocal
andexternal
with the dependency attribute. But one limitation right now is.local
should be from the UIDL itself.package
should be any external one. Like anpm
dependency or amodule
loaded from external cdn etc.Problem
Let's say i have a couple of components with some complex logics, that i want to use them in the process of the project generation. But defining those components in UIDL again is not a reliable solution. What if i have a custom-component which is already completely written and i just want to use it by dropping it's code.
Writing the component again in UIIDL is not a better Developer Experience or User Experience. And we don't like to inject everything in the UIDL in strings format to use them to generate at the build time.
Solution
The one good way to handle this scenario is to enable project plugins. We have component plugins but not project plugins.
The component plugins, takes in UIDL and then generates chunks which are AST based and not string based.
Process
We will enable a new method called
addPlugin
which looks likeAnd the
customProjectContentPlugin
inheritsinMemoryFilesMap
which was introduced in v0.13, and project UIDL and few other things.So it can look something like
At the end of generating project, all these plugins are executed and thus we can inject the files into the final project.
While generating the UIDL, we can refer to these as
Beta Was this translation helpful? Give feedback.
All reactions