Server-side Web Components - The future of Enonic?


#1

I was listening to this interview with Jordan Last, and it made me think that Web Components can be used for backend too. And that this might be a paradigm changeing development.

This is the premise: Can todays JavaScript-code be wrapped in Custom Elements, so that backends be built declarativly using html (at least partly)?

We don’t have Custom Element support server side at the moment, but in the Graal-era of Enonic, this will probably be in place. And I think we might be able to use Polymer to polyfill it now. If I get time, I’d love to do a proof of concept on this in Enonic.

Here is a blogpost by Jordan Last, where he goes a bit deeper into “How and why” to do this. And here is a Youtube video covering much of the same ground.

What do you think Enonic people? Why is this a feasible idea, or why is it not? I’m interested to hear what you think.

– Tom Arild (Item Consulting)


#2

Hi Tom,

We love web components! The idea of wrapping a page component (layout, part, region etc.) inside a web component sounds natural and is actually something we’ve been discussing for a while now.

There are several major drawbacks though.
First, is browser support. Web components are not yet supported by all of the browsers and have to be polyfilled.
Second, we are kind of bound to use NodeJs because of Nashorn. I’m not aware of any successful attempts to run ExpressJs apps in JVM, but maybe it will be possible with GraalVM.
Third, rendering engine. Our components are rendered with a rendering engine that will be supposed to understand the syntax of web components.

Having said that, we are definitely considering using web components but we will start with client-side components first. We are using HTML imports in some parts of XP admin and since that feature is deprecated we will start migration to web components/ES6 modules in the nearest future.

And yes, we would love a proof of concept, thank you very much :slight_smile: