-
Notifications
You must be signed in to change notification settings - Fork 0
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
POC Validation #6
Open
SRNV
wants to merge
52
commits into
master
Choose a base branch
from
feat/hello-world
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nd of the process
… create also a .eon folder where every file system actions can be made
… the used components
…, slots are supported
SRNV
requested review from
jeroenptrs,
littledivy,
a user,
martonlederer and
timreichen
November 13, 2020 16:09
littledivy
requested changes
Nov 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Eon POC validation
this pull request aims to validate the concept of Single File TSX/JSX Components. it continues the work done in #5.
the main goal was to be able to use jsx features without using VDOM, performance in mind.
for this many solutions were needed.
there's some informations to take in account.
JSX is mostly designed for React's usage. this implies some technical constraints like props typechecking, props evaluations, component importations, direct evaluation or deferred evaluation.
how to run ?
Additions
Module Identification
for components resolutions,
export const name = '...'
were required for all components.this was made for components identifications into the DOM tree.
I mean when a component A used a component B named
component-b
, the end user had to do:knowing that jsx has two way to declare elements : IntrinsicsElements and Value-based Elements. this approach makes all components considered as IntrinsicsElements.
this creates some weaknesses into the development experience because IntrinsicsElements doesn't allow property evaluations/ typechecking.
it means that if
<component-b />
requires a propertymessage
, the end user will only know it into the runtime.the end user should be able to identify type errors in the IDE and in the compiler time (Deno for instance).
so now all the components are Value-based Elements.
EonSandBox
the main addition is the new class
EonSandBox
(name can be discussed). the idea is to copy the whole current directory into a new directory named.eon/
. this one is at the same level.what this approach offers:
ModuleGetter deletion
this class is removed since EonSandBox is doing the same job but once.
DOMElementDescriber (SWC parser)
the SWC Parser is used (as a dependency) to get some ASTs.
sadly Deno doesn't expose an ast method 'cause there's no internal consensus. this is why the swc parser is used through the nestland module
deno_swc
. there's some issues into it and the maintainability is debatable. but...this one is useful for the list rendering, I mean the
Vue: v-for
orSvelte: {%each %}
statements.the idea was to be able to get all the end user's inputs, evaluated by Typescript and avoid using the VDOM solution (generate all the list, compare with the previous list, discard useless changes, etc...)
Patterns
this Pull request uses pattern files to compile part of code.
this means that we read the file and change template values with data.
please check the folder
src/patterns/
to see what is implementedthis solution is debatable.
Web-Components
Web-Components are used and defined into the runtime
Design choices
Life cycle
this part is debatable, this Pull request includes some Life cycle hooks:
the end user would have to set those life cycles has static methods of the
class VMC
. like followingmaybe we can rename some for consistency like:
beforeDestroy | desroyed
.Props
IMO props type checking is mandated, so the choice made is to require an export default for each Single File TSX/JSX components, like Typescript mention it in it's doc, the first argument of a component is used for props definition.
the constraint is, since we are not re-using the export default on every reactions, we can't reassign
props
the first choice made was to add a static method to the
class VMC
which would handleprops
reactionsReactivity
the reactivity solution is Proxy based, for deep observations of nested objects/arrays
there's many way to implement reactivity:
I decided to implement the Proxies because some time you will need to pass the component's vmc into an external module
myModule(this);
and nobody knows what will happen to the data of the component.Svelte's approach requires to parse the AssignmentPattern, in every files, every modules or to make an assignment after each suspected modifications, + arrays aren't reactive.
React's approach requires to pass the helper everywhere.
List rendering
list rendering is the most complex feature for a front-end framework. keeping in mind that we have to keep focus on performance. Performance become a thing when you will have to render, update, remove 1000+ items, the solution can quickly be expansive in term of performance.
basically list rendering is why we shouldn't use VDOM. knowing that every time there is a change all the list is re-rendered and compared to the previous DOM (think you have 10 000 objects).
so what's the solution Eon is using
React
first regarding this code, you can read that everytime
setList(Array.from(new Array(10 000)))
is used, React will update the DOM by using again the function, this basically implies another call to useState, another array creation and the re-rendering oflist.map(...)
Eon
the main difference is that Eon uses once the function. why once ? just to get the DOM tree and update the DOM surgically.
while walking into the DOM, if it catch a dynamic list (we need to find a name) , the list will be transpiled and wrapped into an element ( need improvements) and then whenever the end user set a new list, the length of the new list and
element.children.length
are compared. if it's bigger new elements are created one by one, if it's smaller elements are removed one by one.Ideas
Eon could use prototypes instead of
class VMC
:this idea allows a lighter component. instead of exporting two important things
template function & class VMC
; you will only have to export default one prototype function.how can Eon use prototype functions ?
considering the export default as
DefaultPrototype
Todos
Known Issues
for directives
are not renderedstatic props
when the end user tries to assign a prop there is no reaction:this.todo = props.todo // no reaction